Aliyun Wan 影片生成

Aliyun Wan 2.5+ 非同步 t2v/i2v/r2v 影片生成

POST /v1/videos/generations

鉴权: {'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`), 客戶按錯誤自行調整.

请求体

modelstringrequired影片生成模型. 字尾 t2v/i2v/r2v 決定 input 欄位; 主版本號 2.6/2.7 決定協議格式 (見介紹)
durationintegerrequired影片時長 (秒). 閘道器計費用, 必填
resolutionstringrequired解析度檔位 (閘道器計費用). 480p 僅 wan2.5-*-preview 支援; Wan 2.7 大部分僅 720p; 客戶端額外在 parameters 裡也要傳 (Wan 2.7 用 resolution="720P" 大寫, Wan 2.6 用 size="1280*720")
aspect_ratiostring寬高比 (閘道器計費用)
inputobjectrequired上游 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`
parametersobject上游 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_urlstring終態推送回調 URL (可選). 不傳則主動 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'

API 文件