跳轉到主要內容
GET
/
v1
/
videos
/
{id}
cURL
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
}
使用此端點可讀取透過 建立 Seedance 影片 建立的任務狀態。路徑中的 id 是建立呼叫回傳的值,無論該任務是由哪個 Seedance 模型產生。

狀態機制

任務會經過下列其中一種狀態。SUBMITTEDIN_PROGRESS 為非終止狀態;SUCCESSFAILEDERROR 為終止狀態,任務之後不會再變動。
Status含義終止
SUBMITTED已接受並排入渲染佇列。
IN_PROGRESS正在渲染中。
SUCCESS已完成。回應中會包含 video_url
FAILED提供者拒絕了該任務。
ERROR內部錯誤導致無法完成。

輪詢頻率

每 10 到 20 秒輪詢一次。大多數工作會在 1 到 3 分鐘內完成,實際時間取決於模型、時長與解析度。
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。

常見錯誤

  • HTTP 400message: "task_not_exist" 表示該 id 不存在。請確認你已從成功的 POST /v1/videos 回應中取得 id,並且原樣使用。
  • HTTP 401 表示 bearer token 缺失或無效。請檢查請求標頭是否為 Authorization: Bearer <COMETAPI_KEY>

授權

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

路徑參數

id
string
必填

Task id returned by POST /v1/videos.

回應

Current task state.

id
string
必填

Task id.

object
string
必填

Object type, always video.

model
string
必填

Model id that generated the task.

status
enum<string>
必填

Task status. SUBMITTED and IN_PROGRESS are non-terminal. SUCCESS, FAILED, and ERROR are terminal.

可用選項:
SUBMITTED,
IN_PROGRESS,
SUCCESS,
FAILED,
ERROR
progress
integer
必填

Completion percentage.

必填範圍: 0 <= x <= 100
created_at
integer
必填

Task creation time as a Unix timestamp in seconds.

video_url
string | null

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.

completed_at
integer | null

Task completion time as a Unix timestamp in seconds. null while the task is non-terminal.