Category: provider
Model Studio Wan Video
Validation
mkdir -p output/aliyun-wan-video
python -m py_compile skills/ai/video/aliyun-wan-video/scripts/generate_video.py && echo "py_compile_ok" > output/aliyun-wan-video/validate.txt
Pass criteria: command exits 0 and output/aliyun-wan-video/validate.txt is generated.
Output And Evidence
- Save task IDs, polling responses, and final video URLs to
output/aliyun-wan-video/.
- Keep one end-to-end run log for troubleshooting.
Provide consistent video generation behavior for the video-agent pipeline by standardizing video.generate inputs/outputs and using DashScope SDK (Python) with the exact model name.
Critical model names
Use one of these exact model strings:
wan2.6-t2v
wan2.6-t2v-us
wan2.2-t2v-plus
wan2.2-t2v-flash
wan2.6-i2v-flash
wan2.6-i2v
wan2.6-i2v-us
wanx2.1-t2v-turbo
Prerequisites
- Install SDK (recommended in a venv to avoid PEP 668 limits):
python3 -m venv .venv
. .venv/bin/activate
python -m pip install dashscope
- Set
DASHSCOPE_API_KEY in your environment, or add dashscope_api_key to ~/.alibabacloud/credentials (env takes precedence).
Normalized interface (video.generate)
Request
prompt (string, required)
negative_prompt (string, optional)
duration (number, required) seconds
fps (number, required)
size (string, required) e.g. 1280*720
seed (int, optional)
reference_image (string | bytes, optional for t2v, required for i2v family models)
motion_strength (number, optional)
Response
video_url (string)
duration (number)
fps (number)
seed (int)
Quick start (Python + DashScope SDK)
Video generation is usually asynchronous. Expect a task ID and poll until completion.
Note: Wan i2v models require an input image; pure t2v models such as wan2.6-t2v can omit reference_image.
import os
from dashscope import VideoSynthesis
# Prefer env var for auth: export DASHSCOPE_API_KEY=...
# Or use ~/.alibabacloud/credentials with dashscope_api_key under [default].
def generate_video(req: dict) -> dict:
payload = {
"model": req.get("model", "wan2.6-i2v-flash"),
"prompt": req["prompt"],
"negative_prompt": req.get("negative_prompt"),
"duration": req.get("duration", 4),
"fps": req.get("fps", 24),
"size": req.get("size", "1280*720"),
"seed": req.get("seed"),
"motion_strength": req.get("motion_strength"),
"api_key": os.getenv("DASHSCOPE_API_KEY"),
}
if req.get("reference_image"):
# DashScope expects img_url for i2v models; local files are auto-uploaded.
payload["img_url"] = req["reference_image"]
response = VideoSynthesis.call(**payload)
# Some SDK versions require polling for the final result.
# If a task_id is returned, poll until status is SUCCEEDED.
result = response.output.get("results", [None])[0]
return {
"video_url": None if not result else result.get("url"),
"duration": response.output.get("duration"),
"fps": response.output.get("fps"),
"seed": response.output.get("seed"),
}
Async handling (polling)
import os
from dashscope import VideoSynthesis
task = VideoSynthesis.async_call(
model=req.get("model", "wan2.6-i2v-flash"),
prompt=req["prompt"],
img_url=req["reference_image"],
duration=req.get("duration", 4),
fps=req.get("fps", 24),
size=req.get("size", "1280*720"),
api_key=os.getenv("DASHSCOPE_API_KEY"),
)
final = VideoSynthesis.wait(task)
video_url = final.output.get("video_url")
Operational guidance
- Video generation can take minutes; expose progress and allow cancel/retry.
- Cache by
(prompt, negative_prompt, duration, fps, size, seed, reference_image hash, motion_strength).
- Store video assets in object storage and persist only URLs in metadata.
reference_image can be a URL or local path; the SDK auto-uploads local files.
- If you get
Field required: input.img_url, the reference image is missing or not mapped.
wan2.6-t2v and wan2.6-t2v-us add multi-shot narrative support and optional audio input according to the official docs.
Size notes
- Use
WxH format (e.g. 1280*720).
- Prefer common sizes; unsupported sizes can return 400.
Output location
- Default output:
output/aliyun-wan-video/videos/
- Override base dir with
OUTPUT_DIR.
Anti-patterns
- Do not invent model names or aliases; use official Wan i2v model IDs only.
- Do not block the UI without progress updates.
- Do not retry blindly on 4xx; handle validation failures explicitly.
Workflow
- Confirm user intent, region, identifiers, and whether the operation is read-only or mutating.
- Run one minimal read-only query first to verify connectivity and permissions.
- Execute the target operation with explicit parameters and bounded scope.
- Verify results and save output/evidence files.
References
1---
2name: aliyun-wan-video
3description: Use when generating videos with Model Studio DashScope SDK using Wan video generation models (wan2.6-t2v, wan2.6-i2v-flash, wan2.6-i2v and regional variants). Use when implementing or documenting video.generate requests/responses, mapping prompt/negative_prompt/duration/fps/size/seed/reference_image/motion_strength, or integrating video generation into the video-agent pipeline.
4version: 1.0.0
5---
6
7Category: provider
8
9# Model Studio Wan Video
10
11## Validation
12
13```bash
14mkdir -p output/aliyun-wan-video
15python -m py_compile skills/ai/video/aliyun-wan-video/scripts/generate_video.py && echo "py_compile_ok" > output/aliyun-wan-video/validate.txt
16```
17
18Pass criteria: command exits 0 and `output/aliyun-wan-video/validate.txt` is generated.
19
20## Output And Evidence
21
22- Save task IDs, polling responses, and final video URLs to `output/aliyun-wan-video/`.
23- Keep one end-to-end run log for troubleshooting.
24
25Provide consistent video generation behavior for the video-agent pipeline by standardizing `video.generate` inputs/outputs and using DashScope SDK (Python) with the exact model name.
26
27## Critical model names
28
29Use one of these exact model strings:
30- `wan2.6-t2v`
31- `wan2.6-t2v-us`
32- `wan2.2-t2v-plus`
33- `wan2.2-t2v-flash`
34- `wan2.6-i2v-flash`
35- `wan2.6-i2v`
36- `wan2.6-i2v-us`
37- `wanx2.1-t2v-turbo`
38
39## Prerequisites
40
41- Install SDK (recommended in a venv to avoid PEP 668 limits):
42
43```bash
44python3 -m venv .venv
45. .venv/bin/activate
46python -m pip install dashscope
47```
48- Set `DASHSCOPE_API_KEY` in your environment, or add `dashscope_api_key` to `~/.alibabacloud/credentials` (env takes precedence).
49
50## Normalized interface (video.generate)
51
52### Request
53- `prompt` (string, required)
54- `negative_prompt` (string, optional)
55- `duration` (number, required) seconds
56- `fps` (number, required)
57- `size` (string, required) e.g. `1280*720`
58- `seed` (int, optional)
59- `reference_image` (string | bytes, optional for t2v, required for i2v family models)
60- `motion_strength` (number, optional)
61
62### Response
63- `video_url` (string)
64- `duration` (number)
65- `fps` (number)
66- `seed` (int)
67
68## Quick start (Python + DashScope SDK)
69
70Video generation is usually asynchronous. Expect a task ID and poll until completion.
71Note: Wan i2v models require an input image; pure t2v models such as `wan2.6-t2v` can omit `reference_image`.
72
73```python
74import os
75from dashscope import VideoSynthesis
76
77# Prefer env var for auth: export DASHSCOPE_API_KEY=...
78# Or use ~/.alibabacloud/credentials with dashscope_api_key under [default].
79
80def generate_video(req: dict) -> dict:
81 payload = {
82 "model": req.get("model", "wan2.6-i2v-flash"),
83 "prompt": req["prompt"],
84 "negative_prompt": req.get("negative_prompt"),
85 "duration": req.get("duration", 4),
86 "fps": req.get("fps", 24),
87 "size": req.get("size", "1280*720"),
88 "seed": req.get("seed"),
89 "motion_strength": req.get("motion_strength"),
90 "api_key": os.getenv("DASHSCOPE_API_KEY"),
91 }
92
93 if req.get("reference_image"):
94 # DashScope expects img_url for i2v models; local files are auto-uploaded.
95 payload["img_url"] = req["reference_image"]
96
97 response = VideoSynthesis.call(**payload)
98
99 # Some SDK versions require polling for the final result.
100 # If a task_id is returned, poll until status is SUCCEEDED.
101 result = response.output.get("results", [None])[0]
102
103 return {
104 "video_url": None if not result else result.get("url"),
105 "duration": response.output.get("duration"),
106 "fps": response.output.get("fps"),
107 "seed": response.output.get("seed"),
108 }
109```
110
111## Async handling (polling)
112
113```python
114import os
115from dashscope import VideoSynthesis
116
117task = VideoSynthesis.async_call(
118 model=req.get("model", "wan2.6-i2v-flash"),
119 prompt=req["prompt"],
120 img_url=req["reference_image"],
121 duration=req.get("duration", 4),
122 fps=req.get("fps", 24),
123 size=req.get("size", "1280*720"),
124 api_key=os.getenv("DASHSCOPE_API_KEY"),
125)
126
127final = VideoSynthesis.wait(task)
128video_url = final.output.get("video_url")
129```
130
131## Operational guidance
132
133- Video generation can take minutes; expose progress and allow cancel/retry.
134- Cache by `(prompt, negative_prompt, duration, fps, size, seed, reference_image hash, motion_strength)`.
135- Store video assets in object storage and persist only URLs in metadata.
136- `reference_image` can be a URL or local path; the SDK auto-uploads local files.
137- If you get `Field required: input.img_url`, the reference image is missing or not mapped.
138- `wan2.6-t2v` and `wan2.6-t2v-us` add multi-shot narrative support and optional audio input according to the official docs.
139
140## Size notes
141
142- Use `WxH` format (e.g. `1280*720`).
143- Prefer common sizes; unsupported sizes can return 400.
144
145## Output location
146
147- Default output: `output/aliyun-wan-video/videos/`
148- Override base dir with `OUTPUT_DIR`.
149
150## Anti-patterns
151
152- Do not invent model names or aliases; use official Wan i2v model IDs only.
153- Do not block the UI without progress updates.
154- Do not retry blindly on 4xx; handle validation failures explicitly.
155
156## Workflow
157
1581) Confirm user intent, region, identifiers, and whether the operation is read-only or mutating.
1592) Run one minimal read-only query first to verify connectivity and permissions.
1603) Execute the target operation with explicit parameters and bounded scope.
1614) Verify results and save output/evidence files.
162
163## References
164
165- See `references/api_reference.md` for DashScope SDK mapping and async handling notes.
166
167- Source list: `references/sources.md`