$npx -y skills add cinience/alicloud-skills --skill aliyun-wan-i2vUse when generating videos from images with DashScope Wan 2.7 image-to-video model (wan2.7-i2v). Use when implementing first-frame video generation, first+last frame interpolation, video continuation, or audio-driven video synthesis via the video-synthesis async API.
| 1 | # Wan 2.7 Image-to-Video |
| 2 | |
| 3 | ## Validation |
| 4 | |
| 5 | ```bash |
| 6 | mkdir -p output/aliyun-wan-i2v |
| 7 | python -m py_compile skills/ai/video/aliyun-wan-i2v/scripts/generate_i2v.py && echo "py_compile_ok" > output/aliyun-wan-i2v/validate.txt |
| 8 | ``` |
| 9 | |
| 10 | Pass criteria: command exits 0 and `output/aliyun-wan-i2v/validate.txt` is generated. |
| 11 | |
| 12 | ## Output And Evidence |
| 13 | |
| 14 | - Save task IDs, polling responses, and final video URLs to `output/aliyun-wan-i2v/`. |
| 15 | - Keep at least one end-to-end run log for troubleshooting. |
| 16 | |
| 17 | ## Prerequisites |
| 18 | |
| 19 | - Install SDK (recommended in a venv): |
| 20 | |
| 21 | ```bash |
| 22 | python3 -m venv .venv |
| 23 | . .venv/bin/activate |
| 24 | python -m pip install dashscope |
| 25 | ``` |
| 26 | - Set `DASHSCOPE_API_KEY` in your environment, or add `dashscope_api_key` to `~/.alibabacloud/credentials`. |
| 27 | |
| 28 | ## Critical model names |
| 29 | |
| 30 | - `wan2.7-i2v` — supports first-frame, first+last frame, video continuation, and audio-driven generation |
| 31 | |
| 32 | ## Capabilities |
| 33 | |
| 34 | | Capability | Description | Required media types | |
| 35 | |---|---|---| |
| 36 | | First-frame video | Generate video from a single image | `first_frame` | |
| 37 | | First+last frame | Interpolate video between two images | `first_frame` + `last_frame` | |
| 38 | | Video continuation | Extend an existing video clip | `first_clip` | |
| 39 | | Audio-driven | Drive video with audio (lip-sync, rhythm) | `first_frame` + `driving_audio` | |
| 40 | |
| 41 | ## API endpoint (async only) |
| 42 | |
| 43 | ``` |
| 44 | POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis |
| 45 | ``` |
| 46 | |
| 47 | Required headers: |
| 48 | - `Authorization: Bearer $DASHSCOPE_API_KEY` |
| 49 | - `Content-Type: application/json` |
| 50 | - `X-DashScope-Async: enable` |
| 51 | |
| 52 | Singapore endpoint: replace `dashscope.aliyuncs.com` with `dashscope-intl.aliyuncs.com`. |
| 53 | |
| 54 | ## Normalized interface |
| 55 | |
| 56 | ### Request |
| 57 | - `prompt` (string, optional) — up to 5000 characters, describes desired video content |
| 58 | - `negative_prompt` (string, optional) — up to 500 characters |
| 59 | - `media` (array, required) — media objects with `type` and `url` fields: |
| 60 | - `type`: `first_frame` | `last_frame` | `driving_audio` | `first_clip` |
| 61 | - `url`: public URL (HTTP/HTTPS) or OSS temporary URL |
| 62 | - `resolution` (string, optional) — `720P` or `1080P` (default: `1080P`) |
| 63 | - `duration` (integer, optional) — video length in seconds, range [2, 15] (default: 5) |
| 64 | - `prompt_extend` (boolean, optional) — AI prompt rewriting (default: true) |
| 65 | - `watermark` (boolean, optional) — add "AI generated" watermark (default: false) |
| 66 | - `seed` (integer, optional) — range [0, 2147483647] |
| 67 | |
| 68 | ### Media input limits |
| 69 | |
| 70 | **Images** (first_frame, last_frame): |
| 71 | - Formats: JPEG, JPG, PNG (no transparency), BMP, WEBP |
| 72 | - Resolution: [240, 8000] pixels per side |
| 73 | - Aspect ratio: 1:8 to 8:1 |
| 74 | - Max size: 20MB |
| 75 | |
| 76 | **Audio** (driving_audio): |
| 77 | - Formats: wav, mp3 |
| 78 | - Duration: 2-30s |
| 79 | - Max size: 15MB |
| 80 | - Auto-truncated to `duration` value if longer |
| 81 | |
| 82 | **Video** (first_clip): |
| 83 | - Formats: mp4, mov |
| 84 | - Duration: 2-10s |
| 85 | - Resolution: [240, 4096] pixels per side |
| 86 | - Aspect ratio: 1:8 to 8:1 |
| 87 | - Max size: 100MB |
| 88 | |
| 89 | ### Response (task creation) |
| 90 | - `output.task_id` (string) — use for polling, valid 24 hours |
| 91 | - `output.task_status` (string) — PENDING | RUNNING | SUCCEEDED | FAILED | CANCELED |
| 92 | - `request_id` (string) |
| 93 | |
| 94 | ### Response (task result) |
| 95 | - `output.video_url` (string) — generated video URL |
| 96 | - `output.orig_prompt` (string) — original prompt |
| 97 | - `output.actual_prompt` (string) — rewritten prompt (if prompt_extend enabled) |
| 98 | - `usage.video_count` (integer) |
| 99 | - `usage.video_duration` (integer) — duration in seconds |
| 100 | |
| 101 | ## Quick start (Python + HTTP) |
| 102 | |
| 103 | ```python |
| 104 | import os |
| 105 | import json |
| 106 | import time |
| 107 | import requests |
| 108 | |
| 109 | API_KEY = os.getenv("DASHSCOPE_API_KEY") |
| 110 | BASE_URL = "https://dashscope.aliyuncs.com/api/v1" |
| 111 | |
| 112 | def create_i2v_task(req: dict) -> str: |
| 113 | """Create an image-to-video task and return task_id.""" |
| 114 | payload = { |
| 115 | "model": "wan2.7-i2v", |
| 116 | "input": { |
| 117 | "prompt": req.get("prompt", ""), |
| 118 | "media": req["media"], |
| 119 | }, |
| 120 | "parameters": { |
| 121 | "resolution": req.get("resolution", "1080P"), |
| 122 | "duration": req.get("duration", 5), |
| 123 | "prompt_extend": req.get("prompt_extend", True), |
| 124 | "watermark": req.get("watermark", False), |
| 125 | }, |
| 126 | } |
| 127 | if req.get("negative_prompt"): |
| 128 | payload["input"]["negative_prompt"] = req["negative_prompt"] |
| 129 | if req.get("seed") is not None: |
| 130 | payload["parameters"]["seed"] = req["seed"] |
| 131 | |
| 132 | resp = requests.post( |
| 133 | f"{BASE_URL}/services/aigc/video-generation/video-synthesis", |
| 134 | headers={ |
| 135 | "Authorization": f"Bearer {API_KEY}", |
| 136 | "Content-Type": "application/json", |
| 137 | "X-DashScope-Async": "enable", |
| 138 | }, |
| 139 | json=payload, |
| 140 | ) |
| 141 | resp.raise_for_status() |
| 142 | data = resp.json() |
| 143 | return data["output"]["task_id"] |
| 144 | |
| 145 | |
| 146 | def poll_task(task_id: str, interva |