Aliyun Wan 2.5+ 异步 t2v/i2v/r2v 视频生成
POST /v1/videos/generations
Auth: {'type': 'bearer', 'prefix': 'sk-', 'description': 'API Key, `Authorization: Bearer sk-xxx`'}
## 官方文档参考 | 能力 | 模型 | 官方文档 | |---|---|---| | 文生视频 (t2v) | `wan2.7-t2v` | [万相2.7-文生视频](https://modelstudio.console.alibabacloud.com/ap-southeast-1?tab=api#/api/?type=model&url=2865250) | | 图生视频 (i2v) | `wan2.7-i2v` | [万相2.7-图生视频](https://modelstudio.console.alibabacloud.com/ap-southeast-1?tab=api#/api/?type=model&url=3025059) | | 参考生视频 (r2v) | `wan2.7-r2v` | [万相2.7-参考生视频](https://modelstudio.console.alibabacloud.com/ap-southeast-1?tab=api#/api/?type=model&url=3001146) | Aliyun Wan 系列视频生成. 提交任务后立即返 task_id, 通过 GET /v1/videos/generations/{id} 轮询. ## ⚠️ Wan 协议有版本差异 (重要) Wan 2.6 与 Wan 2.7 上游字段名**不兼容**, 必须按对应版本构造 body: | 版本 | input 字段 | parameters 字段 | |---|---|---| | **Wan 2.7+** | `media: [{type, url}]` 数组 (type 取值: reference_video / reference_image / first_frame / driving_audio) | `resolution: "720P"` (大写 P) + duration + prompt_extend + watermark | | **Wan 2.6** | r2v 用 `reference_urls` (URL 字符串数组), i2v 用 `img_url` + `audio_url`, t2v 仅 `prompt` | `size: "1280*720"` + duration + audio + shot_type + prompt_extend | ## 字段责任划分 - 顶层 `model` / `duration` / `resolution` / `aspect_ratio`: 网关用于计费 (USD/秒 × 时长) - `input` / `parameters`: **完全透传给上游**, 客户端按上游文档构造, 字段名/嵌套结构客户自己负责 字段写错时上游会返清晰错误给客户 (如 `Field required: input.media`), 客户按错误自行调整.
model | string | required | 视频生成模型. 后缀 t2v/i2v/r2v 决定 input 字段; 主版本号 2.6/2.7 决定协议格式 (见介绍) |
duration | integer | required | 视频时长 (秒). 网关计费用, 必填 |
resolution | string | required | 分辨率档位 (网关计费用). 480p 仅 wan2.5-*-preview 支持; Wan 2.7 大部分仅 720p; 客户端额外在 parameters 里也要传 (Wan 2.7 用 resolution="720P" 大写, Wan 2.6 用 size="1280*720") |
aspect_ratio | string | 宽高比 (网关计费用) | |
input | object | required | 上游 input 字段, 完全透传. 字段名按 model 版本不同: - Wan 2.7+: `prompt` + `media: [{type, url}]` (type 取值: reference_video / reference_image / first_frame / driving_audio) - Wan 2.6 r2v: `prompt` + `reference_urls: ["url1","url2"]` (字符串数组) - Wan 2.6 i2v: `prompt` + `img_url` (单 URL) + `audio_url` (单 URL, 可选) - Wan 2.6/2.7 t2v: 仅 `prompt` |
parameters | object | 上游 parameters 字段, 完全透传: - Wan 2.7+: `resolution: "720P"` (大写P) + `duration` + `prompt_extend` (bool) + `watermark` (bool) - Wan 2.6: `size: "1280*720"` + `duration` + `audio` (bool) + `shot_type: "multi"` + `prompt_extend` | |
webhook_url | string | 终态推送回调 URL (可选). 不传则主动 GET /v1/videos/generations/{id} 轮询 |
202 — 任务已提交, 异步生成中200 — GET /v1/videos/generations/{id} 查询终态## ─── Wan 2.7-t2v (新协议) ───
curl -X POST https://api.router.ai/v1/videos/generations \
-H 'Authorization: Bearer sk-xxx' \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.7-t2v",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9",
"input": {
"prompt": "雨夜的纽约街头, 霓虹灯闪烁, 一位身穿黑色风衣的侦探快步行走"
},
"parameters": {
"resolution": "720P",
"ratio": "16:9",
"duration": 5,
"prompt_extend": true,
"watermark": true
}
}'
## ─── Wan 2.7-i2v (新协议, media.first_frame) ───
curl -X POST https://api.router.ai/v1/videos/generations \
-H 'Authorization: Bearer sk-xxx' \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.7-i2v",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9",
"input": {
"prompt": "一个由喷漆所画成的少年, 正从一面混凝土墙上活过来",
"media": [
{"type": "first_frame", "url": "https://example.com/rap.png"}
]
},
"parameters": {
"resolution": "720P",
"duration": 5,
"prompt_extend": true,
"watermark": true
}
}'
## ─── Wan 2.7-r2v (新协议, media 多模态参考) ───
curl -X POST https://api.router.ai/v1/videos/generations \
-H 'Authorization: Bearer sk-xxx' \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.7-r2v",
"duration": 10,
"resolution": "720p",
"aspect_ratio": "16:9",
"input": {
"prompt": "视频2抱着图片3在咖啡厅里弹奏, 视频1笑着看着视频2",
"media": [
{"type": "reference_video", "url": "https://example.com/role1.mp4"},
{"type": "reference_video", "url": "https://example.com/role2.mp4"},
{"type": "reference_image", "url": "https://example.com/object.png"}
]
},
"parameters": {
"resolution": "720P",
"duration": 10,
"prompt_extend": false,
"watermark": true
}
}'
## ─── Wan 2.6-t2v (老协议, parameters.size + audio + shot_type) ───
curl -X POST https://api.router.ai/v1/videos/generations \
-H 'Authorization: Bearer sk-xxx' \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.6-t2v",
"duration": 10,
"resolution": "720p",
"aspect_ratio": "16:9",
"input": {
"prompt": "一只小巧可爱的卡通小猫将军, 身穿细节精致的金色盔甲"
},
"parameters": {
"size": "1280*720",
"duration": 10,
"audio": true,
"shot_type": "multi",
"prompt_extend": true
}
}'
## ─── Wan 2.6-i2v (老协议, input.img_url + input.audio_url) ───
curl -X POST https://api.router.ai/v1/videos/generations \
-H 'Authorization: Bearer sk-xxx' \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.6-i2v",
"duration": 10,
"resolution": "720p",
"aspect_ratio": "16:9",
"input": {
"prompt": "一个由喷漆所画成的少年, 正从一面混凝土墙上活过来",
"img_url": "https://example.com/rap.png",
"audio_url": "https://example.com/rap.mp3"
},
"parameters": {
"size": "1280*720",
"duration": 10,
"audio": true,
"shot_type": "multi",
"prompt_extend": true
}
}'
## ─── Wan 2.6-r2v (老协议, input.reference_urls 字符串数组) ───
curl -X POST https://api.router.ai/v1/videos/generations \
-H 'Authorization: Bearer sk-xxx' \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.6-r2v",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9",
"input": {
"prompt": "character1 在沙发上开心地看电影",
"reference_urls": ["https://cdn.wanx.aliyuncs.com/static/demo-wan26/vace.mp4"]
},
"parameters": {
"size": "1280*720",
"duration": 5,
"shot_type": "multi"
}
}'
## ─── 查询任务 ───
curl 'https://api.router.ai/v1/videos/generations/{task_id}' \
-H 'Authorization: Bearer sk-xxx'