透過 TokenHub 統一 API 存取 ByteDance Seedance 2.0 影片生成 model。支援文字轉影片、圖片轉影片、影片編輯、音訊驅動生成等功能。本指南將帶您完成完整的整合流程。
th-xxxxxxxxxxxx...)https://tokenhub.store/api/v1所有請求都需要在標頭中包含 API Key:
Authorization: Bearer th-your-api-keyPOST/videos/generations建立影片生成任務,回傳任務 ID
GET/videos/generations/{task_id}查詢任務狀態,成功時回傳影片 URL
| 模型 ID | 輸入 | 價格 | 說明 |
|---|---|---|---|
| doubao-seedance-2.0 | 無影片輸入 | $6.970/1M (1080p $7.727) | 旗艦 model,品質最高。支援 1080p。 |
| 含影片輸入 | $4.242/1M (1080p $4.697) | 支援影片輸入的旗艦版,成本效益高。 | |
| doubao-seedance-2.0-fast | 無影片輸入 | $5.606/1M | 快速 model,生成更快。 |
| 含影片輸入 | $3.333/1M | 支援影片輸入的快速 model,最實惠。 |
計費詳情:
範例:doubao-seedance-2.0 在無影片輸入(≤720p)下,生成一段 5 秒影片約耗 1M tokens → 成本約 $6.970
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
| model | string | 必填 | Model ID,例如 "doubao-seedance-2.0" |
| prompt | string | 必填 | 影片描述文字。英文提示通常能獲得更好的效果 |
| duration | number | 選填 | 影片時長(秒),範圍 4–15,預設 5 |
| resolution | string | 選填 | "480p"、"720p" 或 "1080p"(預設 720p;僅 doubao-seedance-2.0 可使用 1080p) |
| aspect_ratio | string | 選填 | 長寬比:"adaptive"(預設)、"16:9"、"9:16"、"1:1" 等 |
| image_url | string | 選填 | 參考圖片 URL(image-to-video) |
| image_urls | string[] | 選填 | 多個參考圖片 URL 陣列 |
| video_url | string | 選填 | 參考影片 URL(影片編輯 / video-to-video) |
| video_urls | string[] | 選填 | 多個參考影片 URL 陣列(最多 3 個) |
| video_durations | number[] | 選填 | 每個影片的時長陣列,單位秒,例如 [3, 5] |
| input_video_duration | number | 選填 | 輸入影片總時長,單位秒(video_durations 的替代欄位) |
| audio_url | string | 選填 | 參考音訊 URL(背景音樂 / SFX) |
| audio_urls | string[] | 選填 | 多個參考音訊 URL 陣列(最多 3 個) |
| generate_audio | boolean | 選填 | 是否生成音訊,預設為 true |
| watermark | boolean | 選填 | 是否添加浮水印,預設為 false |
| content | array | 選填 | 媒體資產陣列。每個項目:{ type: "image_url", image_url: { url }, role }。支援的角色:first_frame(最多 1 個)、last_frame(最多 1 個)、reference_image、reference_video、reference_audio |
你可以自由組合文字、圖片、影片和音訊作為輸入。請注意以下限制:
最基本的用法——用文字描述場景來生成影片。
curl -X POST https://tokenhub.store/api/v1/videos/generations \
-H "Authorization: Bearer th-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedance-2.0",
"prompt": "A golden retriever running on a sunny beach, waves crashing in the background, cinematic slow motion, 4K quality",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9",
"watermark": false
}'回應:
{
"id": "xxxxxx-task-id",
"object": "video.generation.task",
"model": "doubao-seedance-2.0",
"status": "queued",
"created": 1719900000
}影片生成是非同步的——請輪詢狀態直到完成。
# Poll task status using the task_id from creation response
curl https://tokenhub.store/api/v1/videos/generations/YOUR_TASK_ID \
-H "Authorization: Bearer th-your-api-key"任務進行中:
{
"id": "YOUR_TASK_ID",
"object": "video.generation.task",
"model": "doubao-seedance-2.0",
"status": "running",
"created": 1719900000
}任務已完成(已收到影片 URL):
{
"id": "YOUR_TASK_ID",
"object": "video.generation.task",
"model": "doubao-seedance-2.0",
"status": "succeeded",
"created": 1719900000,
"data": [
{
"video_url": "https://tokenhub-data.tos-cn-hongkong.volces.com/user_sd_file/YOUR_TASK_ID.mp4",
"cover_image_url": "https://tokenhub-data.tos-cn-hongkong.volces.com/user_sd_file/YOUR_TASK_ID_cover.jpg"
}
],
"usage": {
"video_duration": 5
}
}import requests
import time
API_BASE = "https://tokenhub.store/api/v1"
API_KEY = "th-your-api-key"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# Step 1: Create video generation task
payload = {
"model": "doubao-seedance-2.0",
"prompt": "A majestic eagle soaring over snow-capped mountains, golden hour lighting, cinematic aerial shot",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9",
"watermark": False
}
resp = requests.post(f"{API_BASE}/videos/generations", json=payload, headers=headers)
task = resp.json()
task_id = task["id"]
print(f"Task created: {task_id}, status: {task['status']}")
# Step 2: Poll for result
while True:
resp = requests.get(f"{API_BASE}/videos/generations/{task_id}", headers=headers)
result = resp.json()
status = result["status"]
print(f"Status: {status}")
if status == "succeeded":
video_url = result["data"][0]["video_url"]
duration = result["usage"]["video_duration"]
print(f"Video ready! Duration: {duration}s")
print(f"URL: {video_url}")
break
elif status == "failed":
print(f"Failed: {result.get('error', {}).get('message', 'Unknown error')}")
break
time.sleep(5)const API_BASE = "https://tokenhub.store/api/v1";
const API_KEY = "th-your-api-key";
const headers = {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
};
// Step 1: Create task
const createResp = await fetch(`${API_BASE}/videos/generations`, {
method: "POST",
headers,
body: JSON.stringify({
model: "doubao-seedance-2.0",
prompt: "A majestic eagle soaring over snow-capped mountains, cinematic aerial shot",
duration: 5,
resolution: "720p",
aspect_ratio: "16:9",
watermark: false,
}),
});
const task = await createResp.json();
console.log("Task created:", task.id);
// Step 2: Poll for result
const poll = async () => {
while (true) {
const resp = await fetch(`${API_BASE}/videos/generations/${task.id}`, { headers });
const result = await resp.json();
console.log("Status:", result.status);
if (result.status === "succeeded") {
console.log("Video URL:", result.data[0].video_url);
console.log("Duration:", result.usage.video_duration, "seconds");
return result;
}
if (result.status === "failed") {
console.error("Failed:", result.error?.message);
return result;
}
await new Promise(r => setTimeout(r, 5000));
}
};
await poll();import requests, time
API_BASE = "https://tokenhub.store/api/v1"
headers = {
"Authorization": "Bearer th-your-api-key",
"Content-Type": "application/json"
}
# Image-to-Video with a single reference image
payload = {
"model": "doubao-seedance-2.0",
"prompt": "The woman in the photo turns to face the camera and smiles warmly, her hair gently blowing in the wind",
"duration": 5,
"resolution": "720p",
"image_url": "https://your-bucket.com/portrait.jpg",
"watermark": False
}
resp = requests.post(f"{API_BASE}/videos/generations", json=payload, headers=headers)
task_id = resp.json()["id"]
print(f"Task: {task_id}")
# Poll for result
while True:
r = requests.get(f"{API_BASE}/videos/generations/{task_id}", headers=headers).json()
if r["status"] == "succeeded":
print(f"Done: {r['data'][0]['video_url']}")
break
elif r["status"] == "failed":
print(f"Error: {r.get('error', {}).get('message')}")
break
time.sleep(5)當你的輸入圖片包含真人時,TokenHub 會自動將請求路由至支援真人生成的上游。無需變更客戶端。
當上游內容過濾器在輸入圖片中偵測到真人時,會自動觸發。
請求格式與一般 image-to-video 完全相同 — POST /v1/videos/generations 的 body 也相同。
GET 輪詢完全相同 — 使用 POST 回傳的任一 id 呼叫 /v1/videos/generations/{id},直到 status 為 succeeded 或 failed。id 重寫由伺服器端處理;在整個請求生命週期內,你始終會看到相同的 id。
當你的帳號未設定可支援真人的 provider 時,會以 status 400 回傳。請聯絡你的管理員以啟用支援的 provider。
當上游資產準備超過 5 分鐘時,會透過 GET 以 status: failed 回傳。可安全重新嘗試該請求。
pat-id 對你的用戶端而言是不可解析的 — 請持續輪詢直到 status 變更。
# POST
curl -X POST https://tokenhub.store/api/v1/videos/generations \
-H "Authorization: Bearer $TH_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedance-2.0",
"prompt": "let her dance and spin",
"duration": 8,
"resolution": "480p",
"content": [
{ "type": "image_url", "image_url": { "url": "https://example.com/portrait.png" }, "role": "first_frame" }
]
}'
# → {"id":"pat-abc123","status":"queued"}
# GET (asset still uploading)
curl https://tokenhub.store/api/v1/videos/generations/pat-abc123 -H "Authorization: Bearer $TH_KEY"
# → {"id":"pat-abc123","status":"queued"}
# GET (upstream task running)
# → {"id":"pat-abc123","status":"running"}
# GET (complete — id stays pat-, video_url in data)
# → {"id":"pat-abc123","status":"succeeded","data":[{"video_url":"..."}]}建議格式:[主體] + [動作] + [環境/背景] + [攝影機/風格]
"A young woman walking through a cherry blossom garden, petals falling in slow motion, soft natural lighting, cinematic 35mm film look""Close-up of hands pouring latte art into a ceramic cup, steam rising, warm cafe ambiance, shallow depth of field""Aerial drone shot of a winding river through autumn forest, golden and red leaves, morning mist, 4K cinematic"© 2026 TokenHub · Powered by ByteDance Seedance 2.0 · support@tokenhub.store