建立 Wan 影片
透過 CometAPI,根據文字、參考媒體或首尾影格建立 Wan 影片,然後輪詢任務並下載 MP4 檔案。
curl https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F model=wan3.0 \
-F 'prompt=A small robot walks through a bright greenhouse with smooth camera movement.' \
-F seconds=5 \
-F size=1920x1080{
"id": "task_example",
"task_id": "task_example",
"object": "video",
"model": "wan3.0",
"status": "queued",
"progress": 0,
"created_at": 1779938152
}id,以輪詢任務並下載完成的影片。
POST /v1/videos 使用 multipart/form-data。傳送明確的整數 seconds 值,以及採用 size 格式的 WxH。
wan3.0-prime 使用與 wan3.0 相同的公開請求欄位、媒體限制和任務流程。以 Prime 為目標時,請將 model 設為確切值 wan3.0-prime。Prime 支援文字轉影片、圖片轉影片、首尾影格輸入,以及合併的圖片、影片和音訊參考資料。參考媒體和影格輸入必須透過不同的請求傳送。
選擇輸入模式
每種模式都需要model 和 prompt。可用的媒體輸入取決於模型:
| 目標 | 模型 ID | 媒體欄位 |
|---|---|---|
| 文字轉影片 | wan2.6, wan2.7, wan3.0, wan3.0-prime | 省略媒體欄位 |
| 圖片轉影片 | wan2.7, wan3.0, wan3.0-prime | input_reference URL 或上傳的圖片檔案 |
| 參考影片 | wan2.6 | reference_videos 僅限 |
| 圖片和影片參考資料 | wan2.7, wan3.0, wan3.0-prime | input_reference 搭配 reference_videos |
| 圖片、影片和音訊參考資料 | wan3.0, wan3.0-prime | 圖片/影片參考資料搭配 reference_audios |
| 首尾影格 | wan2.7, wan3.0, wan3.0-prime | first_frame,可選擇搭配 last_frame |
建立 Wan 3.0 Prime 影片
此最簡請求會建立一個使用 Prime 的五秒文字轉影片任務:prompt='A small robot walks through a bright greenhouse '
prompt+='with smooth camera movement.'
curl \
https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan3.0-prime' \
--form-string "prompt=$prompt" \
-F 'seconds=5' \
-F 'size=1920x1080'
使用參考圖片
對於wan2.7、wan3.0 和 wan3.0-prime,請透過 input_reference 傳送公開可存取的 HTTPS URL 或上傳檔案作為參考圖片。
若要使用多張圖片,請依圖片順序重複此欄位,每個欄位放入一個 URL 或檔案。
在 input_reference 中請全部使用 URL 或全部使用檔案。請分別傳送每個 URL,而非將多個 URL 合併為以逗號分隔的值。
請使用每張最大 20 MB 的 PNG 或 JPEG 圖片。
單一 input_reference URL 或檔案會使用圖片轉影片工作流程。圖片會引導構圖和外觀;請使用 Prompt 描述動作和鏡頭行為。
對於 wan3.0 和 wan3.0-prime,無論使用 URL 或上傳檔案,最多只能透過 input_reference 傳送 10 張參考圖片。
使用參考影片和音訊
透過reference_videos 傳送影片,並透過 reference_audios 傳送音訊片段;每個輸入欄位各重複一次。
每個輸入可以是可公開存取的 HTTPS URL 或上傳的檔案。
影片參考請使用含有 H.264 編碼視訊的 MP4 檔案。音訊參考請使用個別的 MP3 檔案。
不同欄位可以使用不同的輸入類型,例如搭配上傳影片的圖片 URL。在 reference_videos 或 reference_audios 中,請全部使用 URL 或全部使用檔案。
最多可上傳五個影片檔案,每個檔案最大為 50 MiB(50 × 1024 × 1024 位元組).
最多可上傳五個音訊檔案,每個檔案最大為 15 MiB(15 × 1024 × 1024 位元組).
Wan 2.6 影片參考
傳送一至三個reference_videos,每個長度為 2–30 秒、最大 30 MB,且至少為 16 fps。
這些限制同時適用於 URL 和上傳的影片。在 Prompt 中,依輸入順序將主體稱為 @Video1、@Video2 和 @Video3。
在此模式下,省略 input_reference、reference_audios、first_frame 和 last_frame。將 seconds 設為 5 或 10。
這些範例會根據兩個影片參考建立一段五秒的影片。請將媒體 URL 或檔案名稱替換為您的輸入:
curl https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan2.6' \
--form-string 'prompt=Keep @Video1 and @Video2 recognizable as they walk.' \
-F 'seconds=5' \
-F 'size=1280x720' \
-F 'reference_videos=https://your-media-host/reference-1.mp4' \
-F 'reference_videos=https://your-media-host/reference-2.mp4'
curl https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan2.6' \
--form-string 'prompt=Keep @Video1 and @Video2 recognizable as they walk.' \
-F 'seconds=5' \
-F 'size=1280x720' \
-F 'reference_videos=@reference-1.mp4;type=video/mp4' \
-F 'reference_videos=@reference-2.mp4;type=video/mp4'
Wan 2.7 圖片和影片參考
結合圖片和影片參考,以引導主體外觀和動作。將seconds 設為從 2 到 10 的整數。省略 reference_audios。
搭配一個影片參考使用兩個圖片 URL 或兩張上傳的圖片:
curl \
https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan2.7' \
-F 'prompt=Preserve the image subjects and follow the video motion.' \
-F 'seconds=5' \
-F 'size=1280x720' \
-F 'input_reference=https://your-image-host/reference-1.png' \
-F 'input_reference=https://your-image-host/reference-2.jpg' \
-F 'reference_videos=https://your-media-host/reference.mp4'
curl https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan2.7' \
-F 'prompt=Preserve the image subjects and follow the video motion.' \
-F 'seconds=5' \
-F 'size=1280x720' \
-F 'input_reference=@reference-1.png;type=image/png' \
-F 'input_reference=@reference-2.jpg;type=image/jpeg' \
-F 'reference_videos=@reference.mp4;type=video/mp4'
Wan 3.0 圖片、影片和音訊參考
對於wan3.0 和 wan3.0-prime,請將圖片和影片參考與音訊參考結合,以引導外觀、動作和節奏。
最多可傳送五個影片參考,合計長度最多為 15 秒。每個影片至少必須為 16 fps。
最多可傳送五個音訊參考,合計長度最多為 15 秒。影片和音訊時長分開計算。
將輸出 seconds 設為從 2 到 30 的整數。
搭配一個影片和兩個音訊片段使用兩個圖片 URL 或兩張上傳的圖片:
curl \
https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan3.0' \
-F 'prompt=Preserve image subjects, video motion, and audio rhythm.' \
-F 'seconds=5' \
-F 'size=1280x720' \
-F 'input_reference=https://your-image-host/reference-1.png' \
-F 'input_reference=https://your-image-host/reference-2.jpg' \
-F 'reference_videos=https://your-media-host/reference.mp4' \
-F 'reference_audios=https://your-media-host/reference-1.mp3' \
-F 'reference_audios=https://your-media-host/reference-2.mp3'
curl \
https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan3.0-prime' \
-F 'prompt=Preserve image subjects, video motion, and audio rhythm.' \
-F 'seconds=5' \
-F 'size=1280x720' \
-F 'input_reference=https://your-image-host/reference-1.png' \
-F 'input_reference=https://your-image-host/reference-2.jpg' \
-F 'reference_videos=https://your-media-host/reference.mp4' \
-F 'reference_audios=https://your-media-host/reference-1.mp3' \
-F 'reference_audios=https://your-media-host/reference-2.mp3'
curl https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan3.0' \
-F 'prompt=Preserve image subjects, video motion, and audio rhythm.' \
-F 'seconds=5' \
-F 'size=1280x720' \
-F 'input_reference=@reference-1.png;type=image/png' \
-F 'input_reference=@reference-2.jpg;type=image/jpeg' \
-F 'reference_videos=@reference.mp4;type=video/mp4' \
-F 'reference_audios=@reference-1.mp3;type=audio/mpeg' \
-F 'reference_audios=@reference-2.mp3;type=audio/mpeg'
使用首尾影格
對於wan2.7、wan3.0 和 wan3.0-prime,請傳送 first_frame 作為起始圖片,並可選擇傳送 last_frame 作為結束圖片。
每個欄位接受一個可公開存取的 HTTPS PNG 或 JPEG URL,或一個已上傳的 PNG 或 JPEG 檔案。
對於 Wan 2.7 影格輸入,起始圖片會決定長寬比,而 size 會選擇輸出解析度層級。
請將影格輸入與 input_reference、reference_videos 和 reference_audios 分開提交於不同的請求中。
以下 Wan 2.7 範例會在起始與結束影格之間建立轉場:
curl https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan2.7' \
-F 'prompt=Move smoothly from the opening frame to the ending frame.' \
-F 'seconds=5' \
-F 'size=1280x720' \
-F 'first_frame=https://your-image-host/first-frame.png' \
-F 'last_frame=https://your-image-host/last-frame.jpg'
curl https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan2.7' \
-F 'prompt=Move smoothly from the opening frame to the ending frame.' \
-F 'seconds=5' \
-F 'size=1280x720' \
-F 'first_frame=@first-frame.png;type=image/png' \
-F 'last_frame=@last-frame.jpg;type=image/jpeg'
curl https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan3.0' \
-F 'prompt=Move smoothly from the opening frame to the ending frame.' \
-F 'seconds=5' \
-F 'size=1280x720' \
-F 'first_frame=https://your-image-host/first-frame.png' \
-F 'last_frame=https://your-image-host/last-frame.jpg'
curl \
https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan3.0-prime' \
-F 'prompt=Move smoothly from the opening frame to the ending frame.' \
-F 'seconds=5' \
-F 'size=1280x720' \
-F 'first_frame=https://your-image-host/first-frame.png' \
-F 'last_frame=https://your-image-host/last-frame.jpg'
curl https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
-F 'model=wan3.0' \
-F 'prompt=Move smoothly from the opening frame to the ending frame.' \
-F 'seconds=5' \
-F 'size=1280x720' \
-F 'first_frame=@first-frame.png;type=image/png' \
-F 'last_frame=@last-frame.jpg;type=image/jpeg'
設定時長與尺寸
將seconds 以整數形式傳送,其值須在您的模型和輸入模式適用的範圍內。
| 模型 ID | 輸入模式 | seconds | 預設值 |
|---|---|---|---|
wan3.0, wan3.0-prime | 文字、參考資料或影格 | 整數 2–30 | 5 秒, 1920x1080 |
wan2.7 | 文字 | 整數 2–15 | 5 秒, 1920x1080 |
wan2.7 | 影格 | 整數 2–15 | 5 秒,1080p 級別;長寬比依照起始影像 |
wan2.7 | 影像/影片參考資料 | 整數 2–10 | 5 秒, 1920x1080 |
wan2.6 | 文字 | 5, 10, 15 | 5 秒, 1920x1080 |
wan2.6 | 影片參考資料 | 5, 10 | 5 秒, 1920x1080 |
size 設為目標模型適用的以下其中一個 WxH 值。
Wan 3.0 的尺寸值也適用於 wan3.0-prime。
Wan 3.0 尺寸值
| 解析度級別 | 長寬比 | size (WxH) |
|---|---|---|
480p | 16:9 | 832x480 |
9:16 | 480x832 | |
1:1 | 624x624 | |
4:3 | 704x528 | |
3:4 | 528x704 | |
720p | 16:9 | 1280x720 |
9:16 | 720x1280 | |
1:1 | 960x960 | |
4:3 | 1088x832 | |
3:4 | 832x1088 | |
1080p | 16:9 | 1920x1080 |
9:16 | 1080x1920 | |
1:1 | 1440x1440 | |
4:3 | 1632x1248 | |
3:4 | 1248x1632 |
Wan 2.7 尺寸值
| 解析度級別 | 長寬比 | size (WxH) |
|---|---|---|
720p | 16:9 | 1280x720 |
9:16 | 720x1280 | |
1080p | 16:9 | 1920x1080 |
9:16 | 1080x1920 | |
1:1 | 1440x1440 |
Wan 2.6 尺寸值
| 解析度級別 | 長寬比 | size (WxH) |
|---|---|---|
720p | 16:9 | 1280x720 |
9:16 | 720x1280 | |
4:3 | 1088x832 | |
3:4 | 832x1088 | |
1080p | 16:9 | 1920x1080 |
9:16 | 1080x1920 | |
1:1 | 1440x1440 | |
4:3 | 1632x1248 | |
3:4 | 1248x1632 |
工作流程
建立任務
id。輪詢任務
status 為 completed、failed 或 error 為止。下載結果
completed 時,呼叫 擷取 Wan 影片內容 以下載 MP4 檔案。主體
Wan model ID: wan2.6, wan2.7, wan3.0, or wan3.0-prime. Wan 3.0 and Wan 3.0 Prime use the same public request fields, task flow, and media limits; use the exact model ID wan3.0-prime when targeting Prime. Use wan2.6 for text or reference-video input. Use wan2.7 for text, image/video references, or frame inputs. Wan 3.0 and Wan 3.0 Prime also support reference audio.
"wan3.0-prime"
Text prompt that describes the video to generate. Describe the appearance and motion to preserve from references, or the transition between first_frame and last_frame. For wan2.6 video references, use @Video1, @Video2, and @Video3 in input order.
"A small robot walks through a bright greenhouse with smooth camera movement."
Requested output duration in whole seconds. Send an explicit integer. For wan2.6 reference-to-video, use 5 or 10; text-to-video also accepts 15. For wan2.7 reference-to-video, use 2 through 10; text and frame inputs accept 2 through 15. For wan3.0 and wan3.0-prime, use 2 through 30. Default is 5.
2 <= x <= 305
Supported WxH size values. For wan3.0 and wan3.0-prime, 480p: 832x480, 480x832, 624x624, 704x528, 528x704; 720p: 1280x720, 720x1280, 960x960, 1088x832, 832x1088; 1080p: 1920x1080, 1080x1920, 1440x1440, 1632x1248, 1248x1632. For wan2.6: 1280x720, 720x1280, 1088x832, 832x1088, 1920x1080, 1080x1920, 1440x1440, 1632x1248, 1248x1632. For wan2.7: 1280x720, 720x1280, 1920x1080, 1080x1920, 1440x1440. Default is 1920x1080. For Wan 2.7 frame inputs, the opening image determines the aspect ratio; size selects the output resolution tier.
"1920x1080"
PNG or JPEG reference images for wan2.7, wan3.0, and wan3.0-prime. Repeat input_reference with one publicly accessible HTTPS image URL or uploaded image file per field. Use all URLs or all files within this field. Do not combine URLs into a comma-separated value. A single URL or file uses the image-to-video workflow. Each image can be up to 20 MB. For wan3.0 and wan3.0-prime, send at most 10 reference images, whether you use URLs or uploaded files. Image and video references can share a request; reference audio requires wan3.0 or wan3.0-prime. Submit frame inputs separately. Omit for text-to-video and wan2.6 reference-to-video. Submit images in the order you want to reference them in the prompt.
^https://Reference videos for wan2.6, wan2.7, wan3.0, and wan3.0-prime. Repeat reference_videos with publicly accessible HTTPS URLs or uploaded MP4 files with H.264 video. Use one input type within this field: all URLs or all files. For wan2.6, send 1 to 3 clips, each 2 to 30 seconds and up to 30 MB, with at least 16 fps; omit image, audio, and frame fields. For wan2.7, combine video references with image references. For wan3.0 and wan3.0-prime, send at most 5 clips totaling at most 15 seconds, with at least 16 fps. Video uploads are limited to 5 files, each at most 50 MiB (50 x 1024 x 1024 bytes); the lower wan2.6 limits still apply. Submit frame inputs separately.
1^https://Reference audio for wan3.0 and wan3.0-prime, combined with image or video references. Repeat reference_audios with publicly accessible HTTPS MP3 URLs or uploaded MP3 files. Use one input type within this field: all URLs or all files. Send at most 5 audio references totaling at most 15 seconds, counted separately from reference video duration. Audio uploads are limited to 5 files, each at most 15 MiB (15 x 1024 x 1024 bytes). Submit frame inputs separately. Omit for wan2.6 and wan2.7.
1^https://Opening frame for wan2.7, wan3.0, and wan3.0-prime, as one publicly accessible HTTPS PNG or JPEG URL or one uploaded PNG or JPEG file. Use first_frame alone or add last_frame to guide the ending. Submit frame inputs in a separate request from input_reference, reference_videos, and reference_audios. Omit for wan2.6. For Wan 2.7 frame inputs, the opening image determines the aspect ratio; size selects the output resolution tier.
^https://Ending frame for wan2.7, wan3.0, and wan3.0-prime, as one publicly accessible HTTPS PNG or JPEG URL or one uploaded PNG or JPEG file. Use with first_frame to guide the ending. Submit frame inputs in a separate request from input_reference, reference_videos, and reference_audios. Omit for wan2.6. For Wan 2.7 frame inputs, the opening image determines the aspect ratio; size selects the output resolution tier.
^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=wan3.0 \
-F 'prompt=A small robot walks through a bright greenhouse with smooth camera movement.' \
-F seconds=5 \
-F size=1920x1080{
"id": "task_example",
"task_id": "task_example",
"object": "video",
"model": "wan3.0",
"status": "queued",
"progress": 0,
"created_at": 1779938152
}