Wan 视频生成
Wan 通过同一套异步视频 API 提供文生视频、图生视频、首末帧生成和参考视频生成能力。
支持的模型
| 模型 | 模式 | 说明 |
|---|---|---|
| wan2.5-t2v-preview | 文生视频 | Wan 2.5 预览模型 |
| wan2.6-t2v | 文生视频 | Wan 2.6 模型 |
| wan2.7-t2v | 文生视频 | Wan 2.7 模型 |
| wan2.5-i2v-preview | 图生视频 | Wan 2.5 预览模型 |
| wan2.6-i2v | 图生视频 | Wan 2.6 模型 |
| wan2.1-kf2v-plus | 首末帧 | Wan 2.1 关键帧模型 |
| wan2.6-r2v | 参考生视频 | Wan 2.6 角色参考模型 |
概述
所有模式都使用 POST /v1/video/generations。模型和输入字段决定生成模式:文生视频仅使用提示词;图生视频增加 input_reference;首末帧生成在 metadata.input 中传入两个 URL;参考生视频则使用 metadata.input.reference_video_urls。
视频生成采用异步流程:提交任务、使用任务 ID 轮询状态,并在成功后获取结果 URL。
任务状态流转
queued → in_progress → completed
↓
failed接口列表
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /v1/video/generations | 提交视频生成任务 |
| GET | /v1/video/generations/{task_id} | 查询任务状态并获取结果 |
模型与模式差异
| 能力 | 文生视频 | 图生视频 | 首末帧 | 参考生视频 |
|---|---|---|---|---|
| 输入 | 提示词 | 首帧 URL 或数据 URI | 首帧和末帧 URL | 1~3 个参考视频 URL |
| 分辨率字段 | parameters.size | parameters.resolution | 固定 720P | parameters.size |
| 时长 | 5、10;2.6 支持 15 | 5、10;2.6 支持 15 | 固定 5 | 5 或 10 |
| 音频 | Wan 2.5/2.6 | Wan 2.5/2.6 | 不支持 | 从参考视频提取角色声音 |
| 多镜头 | Wan 2.6,需开启提示词扩写 | Wan 2.6,需开启提示词扩写 | 不支持 | 支持 |
1. 提交视频生成任务 (/v1/video/generations)
选择与输入素材和模型系列匹配的示例。
调用示例
{
"prompt": "A marble hand statue stands in a shallow pool as vines move in the breeze.",
"model": "wan2.6-t2v",
"metadata": {
"input": {
"negative_prompt": "trees, animals"
},
"parameters": {
"size": "1920*1080",
"duration": 10,
"audio": true,
"prompt_extend": true
}
}
}在 input_reference 中提供 HTTP(S) URL 或图像数据 URI 作为首帧。不接受未包含 MIME 前缀的纯 base64 数据。
{
"prompt": "The light turns red and water begins overflowing around the statue.",
"model": "wan2.5-i2v-preview",
"input_reference": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"metadata": {
"input": {
"negative_prompt": "blurry, low quality, distorted"
},
"parameters": {
"resolution": "1080P",
"duration": 5,
"audio": true,
"watermark": false
}
}
}wan2.1-kf2v-plus 仅接受 URL。分辨率固定为 720P,时长固定为五秒,且不支持音频和镜头控制。
{
"prompt": "The hand-shaped statue cracks and collapses into the water.",
"model": "wan2.1-kf2v-plus",
"metadata": {
"input": {
"first_frame_url": "https://example.com/first-frame.png",
"last_frame_url": "https://example.com/last-frame.png",
"negative_prompt": "blurry, low quality"
},
"parameters": {
"watermark": false,
"prompt_extend": false,
"seed": 12345
}
}
}使用一段视频参考角色的外观和声音,并在提示词中用 character1 指代该角色。
{
"prompt": "character1 drinks bubble tea while dancing to the music.",
"model": "wan2.6-r2v",
"metadata": {
"input": {
"reference_video_urls": [
"https://example.com/reference-video.mp4"
]
},
"parameters": {
"size": "1280*720",
"duration": 5,
"shot_type": "multi"
}
}
}参考视频按数组顺序映射到提示词中的 character1、character2 和 character3。
{
"prompt": "character1 and character2 talk to each other in an office.",
"model": "wan2.6-r2v",
"metadata": {
"input": {
"reference_video_urls": [
"https://example.com/character1.mp4",
"https://example.com/character2.mp4"
],
"negative_prompt": "white walls"
},
"parameters": {
"size": "1280*720",
"duration": 10,
"shot_type": "multi",
"watermark": true
}
}
}完整请求
curl -X POST "https://www.unodetech.xyz/v1/video/generations" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer API_KEY" \
-d @request-body.json请求头
| 请求头 | 必填 | 值 |
|---|---|---|
Content-Type | 是 | application/json |
Authorization | 是 | Bearer API_KEY |
请求体字段
音频参数优先级为
metadata.input.audio_url高于metadata.parameters.audio。省略两者(或将audio设为false)会生成无声视频;audio: true会自动生成音频;传入audio_url则使用自定义同步音频。
响应示例
{
"id": "TASK_ID",
"object": "video",
"model": "wan2.6-t2v",
"status": "queued",
"progress": 0,
"created_at": 1765328779
}响应体字段
2. 查询任务状态 (/v1/video/generations/{task_id})
完整请求
curl -X GET "https://www.unodetech.xyz/v1/video/generations/TASK_ID" \
-H "Authorization: Bearer API_KEY"请求头
| 请求头 | 必填 | 值 |
|---|---|---|
Authorization | 是 | Bearer API_KEY |
路径参数
响应示例
{
"code": "success",
"message": "",
"data": {
"task_id": "TASK_ID",
"action": "textGenerate",
"status": "IN_PROGRESS",
"fail_reason": "",
"submit_time": 1765328779,
"start_time": 1765328794,
"finish_time": 0,
"progress": "30%",
"data": {
"output": {
"task_id": "TASK_ID",
"task_status": "RUNNING"
},
"request_id": "REQUEST_ID"
}
}
}{
"code": "success",
"message": "",
"data": {
"task_id": "TASK_ID",
"action": "textGenerate",
"status": "SUCCESS",
"fail_reason": "<OUTPUT_URL>",
"submit_time": 1765328779,
"start_time": 1765328794,
"finish_time": 1765328947,
"progress": "100%",
"data": {
"output": {
"actual_prompt": "<EDITED_PROMPT>",
"orig_prompt": "<ORIGINAL_PROMPT>",
"task_id": "TASK_ID",
"task_status": "SUCCEEDED",
"video_url": "<OUTPUT_URL>"
},
"request_id": "REQUEST_ID",
"usage": {
"video_count": 1,
"video_duration": 10,
"video_ratio": "1920*1080"
}
}
}
}获取结果时应优先使用 data.data.output.video_url。上游 API 在成功时也会将 URL 放入 data.fail_reason。
{
"code": "success",
"message": "",
"data": {
"task_id": "TASK_ID",
"action": "textGenerate",
"status": "FAILURE",
"fail_reason": "task failed, code: InvalidParameter",
"progress": "100%",
"data": {
"output": {
"code": "InvalidParameter",
"message": "The request parameters are invalid.",
"task_id": "TASK_ID",
"task_status": "FAILED"
},
"request_id": "REQUEST_ID"
}
}
}响应体字段
重要提示
input_reference中的图像必须是 HTTP(S) URL 或完整数据 URI,不接受纯 base64。wan2.1-kf2v-plus的首末帧输入仅接受 URL。- 任务 ID 和输出 URL 保留 24 小时。
- 参考生视频支持 1~3 段参考视频。每段视频应只包含一个角色;数组顺序决定
character1、character2和character3。 - 参考生视频按输入与输出总时长计费。截断后的输入视频最多计入五秒,生成失败不计费。
- 提示词、输入素材和输出视频都会经过内容审核。
相关链接
最后更新于
