YUYU_N1 圖生影片

YUYU_N1 可以自訂影片長度(2–15 秒)、解析度(720p / 1080p)和是否有聲音,適合需要依素材調整規格的情境。

POST /api/tasks/video-generation
X-Api-Key: sk-live-xxxx
Content-Type: application/json
Idempotency-Key: 選填,見下方說明

完整範例

images 要放 base64 格式的 data URI,支援 PNG、JPEG、WebP。範例中省略了實際的 base64 內容:

curl -X POST https://yuyuvideo.com/api/tasks/video-generation \
  -H "X-Api-Key: sk-live-xxxx" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-20260716-00042" \
  -d '{
    "model": "YUYU_N1",
    "prompt": "a woman waving at the camera, cinematic lighting",
    "images": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."],
    "duration": 5,
    "resolution": "720p",
    "audio": true,
    "seed": 1234567,
    "payload": { "external_order_id": "order-20260716-00042" },
    "callback_url": "https://example.com/webhooks/yuyu-video"
  }'

建立成功會回傳 201 Created 和任務資料。這時任務還在排隊,files 是空的。credits 是這次扣除的積分,範例中的數字僅供參考:

{
  "public_id": "01K1M2N3P4Q5R6S7T8V9W0XY12",
  "type": 1,
  "status": 0,
  "credits": 20,
  "params": {
    "model": "YUYU_N1",
    "prompt": "a woman waving at the camera, cinematic lighting",
    "images": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."],
    "duration": 5,
    "resolution": "720p",
    "audio": true,
    "seed": 1234567,
    "payload": { "external_order_id": "order-20260716-00042" },
    "callback_url": "https://example.com/webhooks/yuyu-video"
  },
  "error_code": null,
  "error_message": null,
  "created_at": "2026-07-16T08:00:00.000000Z",
  "finished_at": null,
  "files_expire_at": null,
  "files_expired": false,
  "files": []
}

接下來如何查詢進度、下載影片,請見〈任務查詢與取件〉。

參數表

欄位 型別 必填 說明
model string 是 填 YUYU_N1
prompt string 是 影片描述,最多 1500 字
images string[] 是 只能放 1 張圖片,格式為 base64 data URI(data:image/{png|jpeg|webp};base64,...)
duration integer 否 影片長度 2–15 秒,預設 5。每 5 秒為一個計費單位,不足 5 秒以 5 秒計,詳見〈積分與計費〉
audio boolean 否 是否有聲音,預設 true
resolution string 否 720p 或 1080p,預設 720p
seed integer 否 隨機種子,需為 0 以上的整數
payload object 否 自訂資料,例如你的訂單編號。系統不會讀取或修改,查詢任務和 Webhook 通知時會原樣帶回
callback_url string 否 任務結束時要通知的網址,需以 https:// 開頭,最多 2000 字。詳見〈回呼(Webhook)〉

model 填了不存在的模型會回傳 422:Unknown model alias: {model}。

表格沒有列出的參數(age_declared 除外,詳見〈生成前年齡檢查〉)帶了會回傳 422,不會被忽略。

Idempotency-Key

用來避免重複建立任務。在 header 帶上一組自訂字串,建議用你系統裡的訂單編號這類不會重複的值:

Idempotency-Key: order-20260711-00042

用同一把 API 金鑰、同一個 Idempotency-Key,在短時間內重複送出請求,只會建立一筆任務,也只扣一次積分。之後的重複請求會回傳 200 OK 和原本那筆任務。

不帶這個 header 的話,每次請求都會建立新任務。

錯誤情境

狀態碼 原因 回應內容
422 參數有誤,例如缺少必填欄位、型別錯誤、images 不是 1 張、prompt 超過 1500 字、duration / resolution / audio 超出允許範圍 errors 欄位會列出每個欄位的錯誤原因
422 model 填了不存在的模型 { "message": "Unknown model alias: {model}" }
402 積分不足 { "message": "Insufficient credits to complete this charge." }
429 排隊中的影片任務太多 { "message": "Too many pending tasks of this type; please retry later." }。可以依回應的 Retry-After header 決定多久後再試

扣款規則請見〈積分與計費〉。