Aliyun Wan video generation

Generate video asynchronously with Aliyun Wan 2.5+ (t2v/i2v/r2v).

POST /v1/videos/generations

Auth: {'type': 'bearer', 'prefix': 'sk-', 'description': 'API Key, `Authorization: Bearer sk-xxx`'}

## official documentation reference | capability | Model | Official documentation | |---|---|---| | text-to-video (t2v) | `wan2.7-t2v` | [Wan2.7-text-to-video](https://modelstudio.console.alibabacloud.com/ap-southeast-1?tab=api#/api/?type=model&url=2865250) | | image-to-video (i2v) | `wan2.7-i2v` | [Wan2.7-image-to-video](https://modelstudio.console.alibabacloud.com/ap-southeast-1?tab=api#/api/?type=model&url=3025059) | | reference-to-video (r2v) | `wan2.7-r2v` | [Wan2.7-reference-to-video](https://modelstudio.console.alibabacloud.com/ap-southeast-1?tab=api#/api/?type=model&url=3001146) | Aliyun Wan series video generation. Upon task submission, immediately returns task_id; poll via GET /v1/videos/generations/{id. ## ⚠️ Wan protocol has version differences (important) Wan 2.6 and Wan 2.7 upstream field names are **incompatible**; must construct the body according to the corresponding version: | version | input field | parameters field | |---|---|---| | **Wan 2.7+** | `media: [{type, url}]` array (type values: reference_video / reference_image / first_frame / driving_audio) | `resolution: "720P"` (uppercase P) + duration + prompt_extend + watermark | | **Wan 2.6** | r2v uses `reference_urls` (URL string array), i2v uses `img_url` + `audio_url`, t2v only uses `prompt` | `size: "1280*720"` + duration + audio + shot_type + prompt_extend | ## field responsibility division - top-level `model` / `duration` / `resolution` / `aspect_ratio`: gateway used for billing (USD/second × duration) - `input` / `parameters`: **fully transparently passed to upstream**; client constructs according to upstream documentation, field names and nesting structure are client's responsibility Clear error information will be returned to customers by upstream when field errors occur (e.g. `Field required: input.media`), and customers will adjust the input accordingly.

Request body

modelstringrequiredVideo generation model. The suffix t2v/i2v/r2v determines the input field; the main version number 2.6/2.7 determines the protocol format (see introduction)
durationintegerrequiredVideo duration (in seconds). Billing is calculated by gateway, required field
resolutionstringrequiredResolution tier (gateway billing applies). 480p is only supported in wan2.5-*-preview; Wan 2.7 supports most of 720p; clients must also pass this in parameters (Wan 2.7 uses resolution="720P" in uppercase; Wan 2.6 uses size="1280*720")
aspect_ratiostringAspect ratio (gateway billing applies)
inputobjectrequiredUpstream input field, fully transparent. Field names vary by model version: - Wan 2.7+: `prompt` + `media: [{type, url}]` (type values: reference_video / reference_image / first_frame / driving_audio) - Wan 2.6 r2v: `prompt` + `reference_urls: ["url1","url2"]` (string array) - Wan 2.6 i2v: `prompt` + `img_url` (single URL) + `audio_url` (single URL, optional) - Wan 2.6/2.7 t2v: only `prompt`
parametersobjectUpstream parameters field, fully transparent: - Wan 2.7+: `resolution: "720P"` (uppercase P) + `duration` + `prompt_extend` (boolean) + `watermark` (boolean) - Wan 2.6: `size: "1280*720"` + `duration` + `audio` (bool) + `shot_type: "multi"` + `prompt_extend`
webhook_urlstringFinal push callback URL (optional). If not provided, the system will actively perform a GET request to /v1/videos/generations/{id for polling

Responses

Example

## ─── 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 reference