建立影片生成
從原始碼生成 POST /video-generations 的鑑權、欄位、響應、錯誤與安全呼叫參考。
本頁目錄
操作
POST /video-generations
operationId: create_video_generation_v1_video_generations_post
啟動付費非同步任務。先報價並取得使用者批准,立即儲存任務 ID;202 僅代表已接受。響應不明時複用同一冪等鍵、憑據身份與未修改的請求。建立時重新計價;API 報價不鎖價,max_credits/quote_id 不是 API 請求欄位。遵循 Retry-After 輪詢,所有終態(包括失敗)都需檢查 outputs。
鑑權與副作用
使用可信環境中的 Bearer API Key。所需權限:animations:write
此操作建立付費任務,提交前取得批准。API 報價不鎖價,也不強制執行最高預算。
引數
| 引數 | 位置 | 型別 | 必填 | 約束 / 預設值 | 含義 |
|---|---|---|---|---|---|
Idempotency-Key |
header |
string |
是 | minLength: 8; maxLength: 200 |
每次邏輯操作生成並儲存一次;同一憑據和未修改請求重試時複用,更換憑據會改變去重範圍。 |
請求體 (application/json)
請求體必填:true
| 欄位 | 型別 | 必填 | 預設值 | 約束 | 含義 |
|---|---|---|---|---|---|
input |
GenerationInput | 是 | — | — | 呼叫方所屬或本次提供的生成圖片。 |
metadata |
object |
否 | {} |
— | 呼叫方後設資料,僅字串、數字、布林或 null;JSON 不超過 4 KiB,不存憑據。 |
negative_prompt |
string |
否 | "" |
maxLength: 4000 |
可選負向提示詞,僅適用於支援的模型。 |
prompt |
string |
否 | "" |
maxLength: 8000 |
動作提示詞;模型要求時不能為空,私有提示詞不得寫入日誌。 |
video |
VideoOptions | 否 | {"duration_seconds":null,"input_canvas":null,"model":null,"ratio":null,"resolution":null,"seed":null,"style_preset":null,"transparency":{"key_color":null,"key_selection":"auto","mode":"standard"},"watermark":null} |
— | 符合模型能力的生成設定。 |
完整巢狀結構:VideoGenerationCreateRequest
請求示例
{
"input": {
"first_frame": {
"file_id": "00000000-0000-4000-8000-000000000001",
"type": "file"
}
},
"prompt": "A character runs in place, side view, fixed camera."
}
響應
| HTTP | 正文 | 含義 |
|---|---|---|
202 |
TaskResponse | 已接受非同步任務,請儲存任務 ID 並輪詢。 |
400 |
APIErrorEnvelope | 輸入錯誤,修正請求後再嘗試。 |
401 |
APIErrorEnvelope | API Key 缺失、到期或被撤銷。 |
402 |
APIErrorEnvelope | 點數不足,不自動購買。 |
403 |
APIErrorEnvelope | 帳戶資格、帳戶狀態或 Key 權限不允許此操作。 |
404 |
APIErrorEnvelope | 資源不可用、不屬於當前使用者,或簽名無效/過期。 |
409 |
APIErrorEnvelope | 冪等衝突;僅 IDEMPOTENCY_IN_PROGRESS 可複用原請求重試。 |
413 |
APIErrorEnvelope | 請求或解碼後的圖片超過配置限制。 |
415 |
APIErrorEnvelope | 使用支援的圖片媒體型別。 |
422 |
APIErrorEnvelope | 圖片解碼後尺寸超過限制。 |
429 |
APIErrorEnvelope | 觸發帳戶級速率或佇列限制,遵循 Retry-After 等待。 |
500 |
APIErrorEnvelope | 內部錯誤,保留任務 ID 和冪等鍵,僅標記可重試時重試。 |
503 |
APIErrorEnvelope | 服務或供應商不可用,僅 error.retryable 為 true 時重試。 |
響應頭
| HTTP | 響應頭 | 型別 | 含義 |
|---|---|---|---|
202 |
Retry-After |
integer |
建議等待秒數,遵循服務值並設定總體截止時間。 |
429 |
Retry-After |
integer |
建議等待秒數,遵循服務值並設定總體截止時間。 |
503 |
Retry-After |
integer |
建議等待秒數,遵循服務值並設定總體截止時間。 |
響應示例
{
"created_at": "2026-08-30T00:00:00Z",
"credits": {
"charged": 0,
"held": 1,
"quoted": 1
},
"error": null,
"finished_at": null,
"id": "00000000-0000-4000-8000-000000000002",
"metadata": {},
"normalized_input": {},
"object": "video_generation",
"outputs": [],
"progress": 0,
"stage": "queued",
"started_at": null,
"status": "queued"
}
相關教程
這篇文件有幫助嗎?
不收集搜尋字詞、程式碼或自由文字。此開關僅控制文件互動事件。 隱私權政策