创建 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 的参考图像,会创建参考图生视频任务。
要确认 viduq3 或 viduq3-turbo 是否可供您的 API 密钥使用,请使用 列出可用模型.
使用参考图像
对于 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 个可公开访问的 MP3 片段 HTTPS URL,每个片段时长为 3–12 秒,并为每个片段重复一次 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
}