建立 Vidu 影片
透過 CometAPI 使用 POST /v1/videos 建立 Vidu Q3 或 Q4 影片任務。Q3 適用於文字轉影片或圖片轉影片,Q4 適用於圖片轉影片或參考圖轉影片。接著輪詢任務並下載已完成的 MP4 檔案。
curl https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F model=viduq3-turbo \
-F 'prompt=An astronaut walks through soft blue fog with a slow cinematic camera move.' \
-F seconds=1{
"id": "task_example",
"task_id": "task_example",
"object": "video",
"model": "viduq3-turbo",
"status": "queued",
"progress": 0,
"created_at": 1779938152
}viduq4-preview 可建立圖片轉影片及參考圖轉影片任務。API 會立即傳回任務 ID,因此請儲存傳回的 id,並輪詢任務直到其進入終止狀態。
POST /v1/videos 使用 multipart/form-data。將純量控制項作為表單欄位傳送,並將參考圖片作為 input_reference 欄位傳送。
選擇輸入模式
| 目標 | 模型 ID | 必填欄位 | 選填欄位 |
|---|---|---|---|
| 文字轉影片 | viduq3, viduq3-turbo | model, prompt | seconds, size |
| 圖片轉影片 | viduq3, viduq3-turbo | model, prompt、一個 input_reference 檔案 | seconds, size |
| 圖片轉影片 | viduq4-preview | model, prompt、一個 input_reference 檔案或 HTTPS 圖片 URL | seconds, size |
| 參考圖轉影片 | viduq4-preview | model, prompt, 2–12 input_reference HTTPS 圖片 URL | seconds, size, reference_audios |
viduq4-preview 會根據請求選擇模式。一張未附參考音訊的參考圖片會建立圖片轉影片任務。兩張以上的參考圖片,或一張附帶 reference_audios 的參考圖片,會建立參考圖轉影片任務。
若要確認您的 API 金鑰是否可使用 viduq3 或 viduq3-turbo,請使用 列出可用模型.
使用參考圖片
針對 Q3 圖片轉影片,請透過input_reference multipart 欄位上傳一張參考圖片。檔案大小上限為 20 MB。
圖片會引導所產生影片的構圖與外觀。請使用 Prompt 描述動作、攝影機行為,以及影片應保留的細節。
針對 viduq4-preview 圖片轉影片,請將一張圖片作為上傳檔案傳送,或在 input_reference 中提供可公開存取的 HTTPS URL。影片會從此圖片開始,並保留其長寬比。
針對 viduq4-preview 參考圖轉影片,請傳送 2–12 個可公開存取的 HTTPS 圖片 URL。每張圖片重複一次 input_reference,並在各自的欄位中傳送每個 URL。請使用 PNG、JPEG 或 WEBP 圖片。
在 Prompt 中,請依照請求中的順序參照參考圖片:@1 是第一張 input_reference 圖片,@2 是第二張,依此類推。例如:The pink car from @1 drives across the snowy hill from @2.
新增參考音訊
針對viduq4-preview 參考圖轉影片,reference_audios 可新增語音參考。請傳送最多 3 個可公開存取、每個長度為 3–12 秒的 MP3 片段 HTTPS URL,並為每個片段重複一次 reference_audios。在同一請求中至少傳送一張 input_reference 圖片。
設定時長和尺寸
| 模型 ID | seconds | 預設值 |
|---|---|---|
viduq3-turbo | 整數 1-16 | 5 秒, 1280x720 |
viduq3 | 整數 1-16 | 5 秒, 1280x720 |
viduq4-preview | 整數 3-16 | 5 秒, 1280x720 |
size 設為下列其中一個 WxH 值。
| 解析度層級 | 長寬比 | size (WxH) |
|---|---|---|
540p | 16:9 | 960x528 |
720p | 16:9 | 1280x720 |
1080p | 16:9 | 1920x1080 |
viduq4-preview,請將 size 設為下列其中一個 WxH 值。對於參考轉影片,size 會設定影格形狀。對於圖像轉影片,輸出會保留輸入圖像的長寬比。
| 解析度層級 | 長寬比 | size (WxH) |
|---|---|---|
720p | 16:9 (預設) | 1280x720 |
720p | 9:16 | 720x1280 |
720p | 1:1 | 960x960 |
720p | 4:3 | 1104x816 |
720p | 3:4 | 816x1104 |
viduq4-preview 影片包含生成的音訊軌。
任務流程
建立任務
id。輪詢任務
status 為 completed、failed 或 error。下載結果
completed 時,呼叫 擷取 Vidu 影片內容 以下載 MP4 檔案。主體
Text prompt that describes the video to generate. For image-to-video, describe the motion and camera behavior that should animate the reference image. For viduq4-preview reference-to-video, refer to reference images as @1, @2, and so on, in the order of the input_reference fields. Up to 5000 characters for viduq4-preview.
"An astronaut walks through soft blue fog with a slow cinematic camera move."
Output size as WxH. Supported WxH size values for viduq3 and viduq3-turbo: 960x528, 1280x720, 1920x1080. Supported WxH size values for viduq4-preview: 1280x720, 720x1280, 960x960, 1104x816, 816x1104. Default is 1280x720. For viduq4-preview reference-to-video, size sets the frame shape. For viduq4-preview image-to-video, the output keeps the aspect ratio of the input image.
Reference images. For Q3 image-to-video, upload one image file up to 20 MB. For viduq4-preview image-to-video, send one image file or one publicly accessible HTTPS image URL. For viduq4-preview reference-to-video, send 2-12 publicly accessible HTTPS image URLs by repeating input_reference once per image. Use PNG, JPEG, or WEBP images. Omit this field for text-to-video.
Voice references for viduq4-preview reference-to-video. Send up to 3 publicly accessible HTTPS URLs of MP3 clips, each 3-12 seconds long, by repeating reference_audios once per clip. Send at least one input_reference image in the same request.
^https://回應
Task created. Store the returned id and poll GET /v1/videos/{task_id}.
curl https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F model=viduq3-turbo \
-F 'prompt=An astronaut walks through soft blue fog with a slow cinematic camera move.' \
-F seconds=1{
"id": "task_example",
"task_id": "task_example",
"object": "video",
"model": "viduq3-turbo",
"status": "queued",
"progress": 0,
"created_at": 1779938152
}