Category: provider
Model Studio Wan Video
Validation
CODEBLOCK0
Pass criteria: command exits 0 and output/alicloud-ai-video-wan-video/validate.txt is generated.
Output And Evidence
- - Save task IDs, polling responses, and final video URLs to
output/alicloud-ai-video-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:
- - INLINECODE3
- INLINECODE4
- INLINECODE5
- INLINECODE6
- INLINECODE7
- INLINECODE8
- INLINECODE9
Prerequisites
- - Install SDK (recommended in a venv to avoid PEP 668 limits):
CODEBLOCK1
- - 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) - INLINECODE14 (string, optional)
- INLINECODE15 (number, required) seconds
- INLINECODE16 (number, required)
- INLINECODE17 (string, required) e.g. INLINECODE18
- INLINECODE19 (int, optional)
- INLINECODE20 (string | bytes, optional for t2v, required for i2v family models)
- INLINECODE21 (number, optional)
Response
- -
video_url (string) - INLINECODE23 (number)
- INLINECODE24 (number)
- INLINECODE25 (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 can omit reference_image.
CODEBLOCK2
Async handling (polling)
CODEBLOCK3
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.
- INLINECODE28 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.
Size notes
- - Use
WxH format (e.g. 1280*720). - Prefer common sizes; unsupported sizes can return 400.
Output location
- - Default output: INLINECODE32
- 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
1) Confirm user intent, region, identifiers, and whether the operation is read-only or mutating.
2) Run one minimal read-only query first to verify connectivity and permissions.
3) Execute the target operation with explicit parameters and bounded scope.
4) Verify results and save output/evidence files.
References
- - See
references/api_reference.md for DashScope SDK mapping and async handling notes.
- - Source list: INLINECODE35
技能名称: alicloud-ai-video-wan-video
详细描述:
类别: 提供者
Model Studio Wan Video
验证
bash
mkdir -p output/alicloud-ai-video-wan-video
python -m pycompile skills/ai/video/alicloud-ai-video-wan-video/scripts/generatevideo.py && echo pycompileok > output/alicloud-ai-video-wan-video/validate.txt
通过标准:命令退出码为0,且生成 output/alicloud-ai-video-wan-video/validate.txt 文件。
输出与证据
- - 将任务ID、轮询响应以及最终视频URL保存到 output/alicloud-ai-video-wan-video/ 目录下。
- 保留一次完整的端到端运行日志,以便进行故障排查。
通过标准化 video.generate 的输入/输出,并使用 DashScope SDK(Python)及精确的模型名称,为视频代理管道提供一致的视频生成行为。
关键模型名称
使用以下精确的模型字符串之一:
- - wan2.2-t2v-plus
- wan2.2-t2v-flash
- wan2.6-i2v-flash
- wan2.6-i2v
- wan2.6-i2v-us
- wan2.6-t2v-us
- wanx2.1-t2v-turbo
前提条件
- - 安装SDK(建议在虚拟环境中安装,以避免PEP 668的限制):
bash
python3 -m venv .venv
. .venv/bin/activate
python -m pip install dashscope
- - 在环境中设置 DASHSCOPEAPIKEY,或者将 dashscopeapikey 添加到 ~/.alibabacloud/credentials 文件中(环境变量优先级更高)。
标准化接口 (video.generate)
请求
- - prompt (字符串, 必填)
- negativeprompt (字符串, 可选)
- duration (数字, 必填) 秒
- fps (数字, 必填)
- size (字符串, 必填) 例如 1280*720
- seed (整数, 可选)
- referenceimage (字符串 | 字节, 文本生成视频模型可选,图像生成视频系列模型必填)
- motion_strength (数字, 可选)
响应
- - video_url (字符串)
- duration (数字)
- fps (数字)
- seed (整数)
快速开始 (Python + DashScope SDK)
视频生成通常是异步的。会返回一个任务ID,需要轮询直到完成。
注意:Wan 图像生成视频模型需要输入图像;纯文本生成视频模型可以省略 reference_image。
python
import os
from dashscope import VideoSynthesis
优先使用环境变量进行认证:export DASHSCOPEAPIKEY=...
或者使用 ~/.alibabacloud/credentials 文件,在 [default] 下配置 dashscopeapikey。
def generate_video(req: dict) -> dict:
payload = {
model: req.get(model, wan2.6-i2v-flash),
prompt: req[prompt],
negativeprompt: req.get(negativeprompt),
duration: req.get(duration, 4),
fps: req.get(fps, 24),
size: req.get(size, 1280*720),
seed: req.get(seed),
motionstrength: req.get(motionstrength),
apikey: os.getenv(DASHSCOPEAPI_KEY),
}
if req.get(reference_image):
# DashScope 期望图像生成视频模型使用 img_url;本地文件会自动上传。
payload[imgurl] = req[referenceimage]
response = VideoSynthesis.call(payload)
# 某些SDK版本需要轮询以获取最终结果。
# 如果返回了 task_id,则轮询直到状态变为 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),
}
异步处理 (轮询)
python
import os
from dashscope import VideoSynthesis
task = VideoSynthesis.async_call(
model=req.get(model, wan2.6-i2v-flash),
prompt=req[prompt],
imgurl=req[referenceimage],
duration=req.get(duration, 4),
fps=req.get(fps, 24),
size=req.get(size, 1280*720),
apikey=os.getenv(DASHSCOPEAPI_KEY),
)
final = VideoSynthesis.wait(task)
videourl = final.output.get(videourl)
操作指南
- - 视频生成可能需要几分钟;应展示进度,并允许取消/重试。
- 根据 (prompt, negativeprompt, duration, fps, size, seed, referenceimage hash, motionstrength) 进行缓存。
- 将视频资源存储在对象存储中,元数据中仅持久化URL。
- referenceimage 可以是URL或本地路径;SDK会自动上传本地文件。
- 如果遇到 Field required: input.img_url 错误,说明参考图像缺失或未正确映射。
尺寸说明
- - 使用 WxH 格式(例如 1280*720)。
- 优先使用常见尺寸;不支持的尺寸可能会返回400错误。
输出位置
- - 默认输出:output/alicloud-ai-video-wan-video/videos/
- 可通过 OUTPUT_DIR 覆盖基础目录。
反模式
- - 不要发明模型名称或别名;仅使用官方的 Wan 图像生成视频模型ID。
- 不要在没有进度更新的情况下阻塞UI。
- 不要在4xx错误上盲目重试;应显式处理验证失败的情况。
工作流程
1) 确认用户意图、区域、标识符,以及操作是只读还是修改。
2) 首先执行一个最小的只读查询,以验证连接和权限。
3) 使用明确的参数和有限的范围执行目标操作。
4) 验证结果并保存输出/证据文件。
参考
- - 有关 DashScope SDK 映射和异步处理说明,请参见 references/api_reference.md。
- - 来源列表:references/sources.md