TokenLab

視頻與素材

取得任務 (Volc 相容)

透過 cgt 任務 ID 取得 Seedance 相容性任務。

GET
/api/v3/contents/generations/tasks/{id}

概覽

使用建立時回傳的 cgt-... ID。當任務狀態為 queued 或 running 時,請每隔幾秒進行輪詢。當任務狀態變為 succeeded、failed、cancelled 或 expired 時停止輪詢。

請勿在此處重複使用統一的 v1 任務列舉 (enum) 或回應結構。/v1/tasks/{id} 使用 pending、processing、completed 和 failed;此 v3 端點使用上述官方列舉。在 v3 JSON 物件中,duration 若存在則為字串,error 則是選用的錯誤詳情欄位。嚴謹的 Go 客戶端應將 Duration 宣告為 string 並加上 JSON 標籤 duration,omitempty,並在每個 v3 終止狀態時停止。

請參閱 Seedance 2.0 影片模型 與 影片生成。

狀態值

  • queued: 已接受並等待執行。
  • running: 正在生成中。
  • succeeded: 結果已就緒,且 content.video_url 存在。
  • failed: 生成失敗;請檢查 error.code 和 error.message。
  • cancelled: 任務在完成前已被取消。
  • expired: 任務在完成前已過期。

回應欄位

  • id: 相容性任務 ID,以 cgt- 開頭。
  • model: 為相容性而回傳的模型識別碼。
  • status: 上述狀態值之一。
  • content.video_url: 成功時的最終影片 URL。
  • content.last_frame_url: 僅在請求且可用時提供。
  • usage: 可用時的 token 使用量。
  • created_at 與 updated_at: 任務時間戳記。
  • error: 選用的錯誤詳情。有值時查看 error.code 和 error.message,不要僅依 status 推斷此欄位是否存在。

回應中絕不會包含 TokenLab 的欄位,例如 progress、return_last_frame、watermark、priority 或 camera_fixed。

範例

curl https://api.tokenlab.sh/api/v3/contents/generations/tasks/cgt-20260102030405-a1b2c \
  -H "Authorization: Bearer $TOKENLAB_API_KEY"
{
  "id": "cgt-20260102030405-a1b2c",
  "model": "doubao-seedance-2.0",
  "status": "succeeded",
  "content": {
    "video_url": "https://example.com/result.mp4"
  },
  "usage": {
    "completion_tokens": 123456
  }
}
Go
type SeedanceTask struct {
    ID       string `json:"id"`
    Status   string `json:"status"`
    Duration string `json:"duration,omitempty"`
}

func isTerminal(status string) bool {
    switch status {
    case "succeeded", "failed", "cancelled", "expired":
        return true
    default:
        return false
    }
}
curl -X GET "https://example.com/api/v3/contents/generations/tasks/string"
{  "id": "string",  "model": "string",  "status": "queued",  "content": {    "video_url": "http://example.com",    "last_frame_url": "http://example.com"  },  "seed": 0,  "resolution": "string",  "ratio": "string",  "duration": "string",  "frames": 0,  "framespersecond": 0,  "generate_audio": true,  "tools": {    "type": "web_search"  },  "safety_identifier": "string",  "draft": true,  "draft_task_id": "string",  "service_tier": "string",  "execution_expires_after": 0,  "usage": {    "completion_tokens": 0,    "total_tokens": 0,    "tool_usage": {      "web_search": 0    }  },  "error": {    "code": "string",    "message": "string"  },  "created_at": 0,  "updated_at": 0}

授權

BearerAuth
AuthorizationBearer <token>

API Key 驗證。請在 Dashboard > API > API Keys 建立或管理 API 金鑰。

位置: header

路徑參數

id*string

由建立端點回傳的相容性任務 ID。ID 以 cgt- 開頭。

回應

application/json

application/json

application/json

application/json