创建 Wan 视频
通过 CometAPI 使用文本、参考媒体或首尾帧创建 Wan 视频,然后轮询任务并下载 MP4 文件。
{
"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}.
{
"id": "task_example",
"task_id": "task_example",
"object": "video",
"model": "wan3.0",
"status": "queued",
"progress": 0,
"created_at": 1779938152
}