Wan2.2-Animate Image-to-Video
Transfer motion and expression from a reference video to a static character image, generating a dynamic video. Uses Alibaba Cloud Bailian API with the fixed model name wan2.2-animate-move.
Pre-checks (Always Do First)
This skill requires an Alibaba Cloud Bailian API Key. First, switch the working directory to where this SKILL.md is located, then run:
python scripts/wan_animate.py check
If the path reports "file not found", retry using the absolute path of the skill directory (replace scripts/wan_animate.py with <skill_directory>/scripts/wan_animate.py). Do not give up or write requests yourself just because the script is missing.
- Output
"api_key_set": true→ proceed directly. - Output
false→ Stop and ask the user for the API Key, do not guess or hardcode it. Inform the user to create one in the Alibaba Cloud Bailian console and set the environment variable:
# Windows PowerShell
$env:DASHSCOPE_API_KEY="sk-xxxx"
# macOS / Linux
export DASHSCOPE_API_KEY=sk-xxxx
Do not write the user's API Key into any files, notes, or conversation summaries. Only pass it via environment variables in the current session.
If the user wants to use a business space-specific domain (faster and more stable), have them provide it and set DASHSCOPE_API_HOST:
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com or for Singapore region
https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com. Note that API Keys for Beijing and Singapore are not interchangeable.
Execution
python scripts/wan_animate.py run \
--image <character image path or URL> \
--video <reference video path or URL> \
--mode wan-std \
--out ./output
Parameter Descriptions:
| Parameter | Description |
|---|---|
--image | Required. Character image, can be a local path or public URL. Local files are automatically uploaded to Bailian temporary storage by the script. |
--video | Required. Reference video, same as above. Duration 2~30 seconds. |
--mode | wan-std standard mode, fast and cheap, default; wan-pro professional mode, smoother but slower and more expensive. |
--watermark | Adds an "AI-generated" watermark, not added by default. |
--out | Output directory, default ./wan_animate_output. |
--no-download | Only return the result link, no local download. Result links are valid for 24 hours; downloading locally is usually better. |
The script automatically: uploads local assets → creates an async task → polls every 15 seconds → downloads the final output locally.
A single video typically takes a few minutes—this is normal, do not abort midway, let the polling complete.
Finally, it outputs the result JSON between RESULT_JSON_BEGIN / RESULT_JSON_END, and informs the user of the video path.
Asset Constraints (Check Before Submitting to Save a Round of Failure)
- Image: JPG/JPEG/PNG/BMP/WEBP, width and height both 200~4096 px, aspect ratio 1:3 ~ 3:1, ≤ 5MB
- Video: MP4/AVI/MOV, duration 2~30 seconds, width and height both 200~2048 px, aspect ratio 1:3 ~ 3:1, ≤ 200MB
- Both assets must be publicly accessible URLs or local files. Regular URLs requiring login or anti-leeching will fail; in such cases, have the user download the file locally first and use the local path.
If constraints are exceeded, inform the user before calling and explain what needs to be done (crop, compress, transcode). Do not submit blindly.
Quality Optimization (Check These First When Output Looks Poor)
- The character's framing ratio in the image and reference video should be similar — a full-body and a half-body shot will almost certainly fail.
- The body proportions of the characters should match.
- The reference video should have as high resolution and frame rate as possible; blurry videos will directly degrade output quality.
- For the first attempt, use
wan-stdto verify motion alignment. Once satisfied, usewan-profor the final version — pro mode is expensive, don't waste money upfront.
Common Error Handling
The script translates Bailian error codes into plain language; you only need to relay them to the user:
UrlOrFileNotReachable/downloadFail→ link unreachable or requires authentication, switch to local file upload.DataInspectionFailed/IPInfringementSuspect→ asset failed content review or suspected infringement, replace the asset.Arrearage/FreeQuotaExhausted→ account overdue or free quota exhausted, requires recharge/purchasing the paid plan.InvalidApiKey→ Key invalid, have the user regenerate it.Throttling→ rate-limited, wait and retry.InvalidParameter→ asset dimensions/duration do not meet requirements, check against the constraints above.
Billing: Input is free; charged by the number of seconds of successfully generated video; failed calls are not charged. For specific unit prices, refer to the Bailian console. If the user asks, direct them to the "Model Pricing" page—do not quote from memory.
If the user has not yet provided assets, first ask where the image and video are. Do not fabricate file paths.