在 CometAPI 上透過 GET /v1/videos/ 以 id 輪詢 Seedance 影片任務。適用於 Seedance 1.0 Pro、1.5 Pro 與 2.0 任務。會回傳目前狀態、進度,以及在任務達到 SUCCESS 後的已簽名 video_url。
curl https://api.cometapi.com/v1/videos/<TASK_ID> \
-H "Authorization: Bearer <COMETAPI_KEY>"{
"id": "task_abc123",
"model": "doubao-seedance-2-0-fast",
"object": "video",
"status": "IN_PROGRESS",
"progress": 45,
"created_at": 1776567610,
"completed_at": null
}id 是建立呼叫回傳的值,無論該任務是由哪個 Seedance 模型產生。
SUBMITTED 與 IN_PROGRESS 為非終止狀態;SUCCESS、FAILED 與 ERROR 為終止狀態,任務之後不會再變動。
| Status | 含義 | 終止 |
|---|---|---|
SUBMITTED | 已接受並排入渲染佇列。 | 否 |
IN_PROGRESS | 正在渲染中。 | 否 |
SUCCESS | 已完成。回應中會包含 video_url。 | 是 |
FAILED | 提供者拒絕了該任務。 | 是 |
ERROR | 內部錯誤導致無法完成。 | 是 |
import time
import requests
TASK_ID = "<TASK_ID>"
headers = {"Authorization": "Bearer <COMETAPI_KEY>"}
TERMINAL = {"SUCCESS", "FAILED", "ERROR"}
while True:
response = requests.get(
f"https://api.cometapi.com/v1/videos/{TASK_ID}",
headers=headers,
timeout=15,
)
response.raise_for_status()
data = response.json()
if data["status"] in TERMINAL:
print(data.get("video_url"))
break
time.sleep(10)
status — 決定你的輪詢迴圈何時停止。progress — 介於 0 到 100 的整數,你可以在 UI 中顯示。video_url — 已簽名的下載 URL,僅在 SUCCESS 時出現。簽名具有時效性;請在簽名過期前下載或重新代管該檔案。completed_at — 一旦任務達到終止狀態後會填入的 Unix 時間戳。model — 回顯建立任務時所使用的 Seedance model id。400 且 message: "task_not_exist" 表示該 id 不存在。請確認你已從成功的 POST /v1/videos 回應中取得 id,並且原樣使用。401 表示 bearer token 缺失或無效。請檢查請求標頭是否為 Authorization: Bearer <COMETAPI_KEY>。Bearer token authentication. Use your CometAPI key.
Task id returned by POST /v1/videos.
Current task state.
Task id.
Object type, always video.
Model id that generated the task.
Task status. SUBMITTED and IN_PROGRESS are non-terminal. SUCCESS, FAILED, and ERROR are terminal.
SUBMITTED, IN_PROGRESS, SUCCESS, FAILED, ERROR Completion percentage.
0 <= x <= 100Task creation time as a Unix timestamp in seconds.
Signed download URL for the finished video. Present only when status is SUCCESS. The signature is time-limited, so download or re-upload the file to your own storage soon after you receive it.
Task completion time as a Unix timestamp in seconds. null while the task is non-terminal.
curl https://api.cometapi.com/v1/videos/<TASK_ID> \
-H "Authorization: Bearer <COMETAPI_KEY>"{
"id": "task_abc123",
"model": "doubao-seedance-2-0-fast",
"object": "video",
"status": "IN_PROGRESS",
"progress": 45,
"created_at": 1776567610,
"completed_at": null
}