
Aliyun Wan I2v
- 52 installs
- 396 repo stars
- Updated July 18, 2026
- cinience/alicloud-skills
Generates video from images with DashScope Wan 2.7 i2v, supporting first-frame, first+last frame, video continuation, and audio-driven synthesis.
About
This skill submits async video-synthesis tasks to the Wan 2.7 image-to-video model across first-frame, keyframe, continuation, and audio-driven modes. A developer uses it to animate images or extend clips at 720P or 1080P.
- Single model wan2.7-i2v covers four media-input capabilities
- Async API with Beijing and Singapore endpoints, 2-15s duration
Aliyun Wan I2v by the numbers
- 52 all-time installs (skills.sh)
- Ranked #884 of 1,335 Generative Media skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/cinience/alicloud-skills --skill aliyun-wan-i2vAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 52 |
|---|---|
| repo stars | ★ 396 |
| Last updated | July 18, 2026 |
| Repository | cinience/alicloud-skills ↗ |
What it does
Generates video from images with DashScope Wan 2.7 i2v, supporting first-frame, first+last frame, video continuation, and audio-driven synthesis.
Files
Wan 2.7 Image-to-Video
Validation
mkdir -p output/aliyun-wan-i2v
python -m py_compile skills/ai/video/aliyun-wan-i2v/scripts/generate_i2v.py && echo "py_compile_ok" > output/aliyun-wan-i2v/validate.txtPass criteria: command exits 0 and output/aliyun-wan-i2v/validate.txt is generated.
Output And Evidence
- Save task IDs, polling responses, and final video URLs to
output/aliyun-wan-i2v/. - Keep at least one end-to-end run log for troubleshooting.
Prerequisites
- Install SDK (recommended in a venv):
python3 -m venv .venv
. .venv/bin/activate
python -m pip install dashscope- Set
DASHSCOPE_API_KEYin your environment, or adddashscope_api_keyto~/.alibabacloud/credentials.
Critical model names
wan2.7-i2v— supports first-frame, first+last frame, video continuation, and audio-driven generation
Capabilities
| Capability | Description | Required media types |
|---|---|---|
| First-frame video | Generate video from a single image | first_frame |
| First+last frame | Interpolate video between two images | first_frame + last_frame |
| Video continuation | Extend an existing video clip | first_clip |
| Audio-driven | Drive video with audio (lip-sync, rhythm) | first_frame + driving_audio |
API endpoint (async only)
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesisRequired headers:
Authorization: Bearer $DASHSCOPE_API_KEYContent-Type: application/jsonX-DashScope-Async: enable
Singapore endpoint: replace dashscope.aliyuncs.com with dashscope-intl.aliyuncs.com.
Normalized interface
Request
prompt(string, optional) — up to 5000 characters, describes desired video contentnegative_prompt(string, optional) — up to 500 charactersmedia(array, required) — media objects withtypeandurlfields:type:first_frame|last_frame|driving_audio|first_clipurl: public URL (HTTP/HTTPS) or OSS temporary URLresolution(string, optional) —720Por1080P(default:1080P)duration(integer, optional) — video length in seconds, range [2, 15] (default: 5)prompt_extend(boolean, optional) — AI prompt rewriting (default: true)watermark(boolean, optional) — add "AI generated" watermark (default: false)seed(integer, optional) — range [0, 2147483647]
Media input limits
Images (first_frame, last_frame):
- Formats: JPEG, JPG, PNG (no transparency), BMP, WEBP
- Resolution: [240, 8000] pixels per side
- Aspect ratio: 1:8 to 8:1
- Max size: 20MB
Audio (driving_audio):
- Formats: wav, mp3
- Duration: 2-30s
- Max size: 15MB
- Auto-truncated to
durationvalue if longer
Video (first_clip):
- Formats: mp4, mov
- Duration: 2-10s
- Resolution: [240, 4096] pixels per side
- Aspect ratio: 1:8 to 8:1
- Max size: 100MB
Response (task creation)
output.task_id(string) — use for polling, valid 24 hoursoutput.task_status(string) — PENDING | RUNNING | SUCCEEDED | FAILED | CANCELEDrequest_id(string)
Response (task result)
output.video_url(string) — generated video URLoutput.orig_prompt(string) — original promptoutput.actual_prompt(string) — rewritten prompt (if prompt_extend enabled)usage.video_count(integer)usage.video_duration(integer) — duration in seconds
Quick start (Python + HTTP)
import os
import json
import time
import requests
API_KEY = os.getenv("DASHSCOPE_API_KEY")
BASE_URL = "https://dashscope.aliyuncs.com/api/v1"
def create_i2v_task(req: dict) -> str:
"""Create an image-to-video task and return task_id."""
payload = {
"model": "wan2.7-i2v",
"input": {
"prompt": req.get("prompt", ""),
"media": req["media"],
},
"parameters": {
"resolution": req.get("resolution", "1080P"),
"duration": req.get("duration", 5),
"prompt_extend": req.get("prompt_extend", True),
"watermark": req.get("watermark", False),
},
}
if req.get("negative_prompt"):
payload["input"]["negative_prompt"] = req["negative_prompt"]
if req.get("seed") is not None:
payload["parameters"]["seed"] = req["seed"]
resp = requests.post(
f"{BASE_URL}/services/aigc/video-generation/video-synthesis",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"X-DashScope-Async": "enable",
},
json=payload,
)
resp.raise_for_status()
data = resp.json()
return data["output"]["task_id"]
def poll_task(task_id: str, interval: int = 15) -> dict:
"""Poll until task completes. Returns final response."""
while True:
resp = requests.get(
f"{BASE_URL}/tasks/{task_id}",
headers={"Authorization": f"Bearer {API_KEY}"},
)
resp.raise_for_status()
data = resp.json()
status = data["output"]["task_status"]
if status in ("SUCCEEDED", "FAILED", "CANCELED"):
return data
time.sleep(interval)Media combination examples
# First-frame only
media = [{"type": "first_frame", "url": "https://example.com/image.jpg"}]
# First + last frame interpolation
media = [
{"type": "first_frame", "url": "https://example.com/start.jpg"},
{"type": "last_frame", "url": "https://example.com/end.jpg"},
]
# Audio-driven from first frame
media = [
{"type": "first_frame", "url": "https://example.com/face.jpg"},
{"type": "driving_audio", "url": "https://example.com/speech.mp3"},
]
# Video continuation
media = [{"type": "first_clip", "url": "https://example.com/clip.mp4"}]Error handling
| Error | Likely cause | Action |
|---|---|---|
| 401/403 | Missing or invalid DASHSCOPE_API_KEY | Check env var or credentials file |
400 InvalidParameter | Unsupported resolution, bad duration, missing media | Validate parameters |
| "does not support synchronous calls" | Missing X-DashScope-Async: enable header | Add required header |
| 429 | Rate limit or quota | Retry with backoff |
Output location
- Default output:
output/aliyun-wan-i2v/videos/ - Override base dir with
OUTPUT_DIR.
Anti-patterns
- Do not use model names other than
wan2.7-i2v. - Do not call this API synchronously — async header is required.
- Do not pass duplicate media types (e.g., two
first_frameentries). - Video URLs expire after 24 hours; download and persist immediately.
- Do not use this API for video editing — use
aliyun-wan-videoeditinstead.
Workflow
1) Confirm user intent: first-frame, first+last frame, video continuation, or audio-driven. 2) Prepare media array with correct types and valid URLs. 3) Create async task and poll for results. 4) Download and save generated video before URL expiration.
References
- See
references/api_reference.mdfor full HTTP API details. - See
references/sources.mdfor source links.
DashScope API Reference (Wan 2.7 Image-to-Video)
Model
| Model | Capabilities | Resolution | Duration |
|---|---|---|---|
| wan2.7-i2v | First-frame, first+last frame, video continuation, audio-driven | 720P, 1080P | 2-15s |
Endpoint
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesisSingapore: https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Required headers
| Header | Value |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer $DASHSCOPE_API_KEY |
| X-DashScope-Async | enable |
Request body
{
"model": "wan2.7-i2v",
"input": {
"prompt": "描述文本",
"negative_prompt": "不希望出现的内容",
"media": [
{"type": "first_frame", "url": "https://..."},
{"type": "driving_audio", "url": "https://..."}
]
},
"parameters": {
"resolution": "1080P",
"duration": 5,
"prompt_extend": true,
"watermark": false,
"seed": 42
}
}input fields
| Field | Type | Required | Description |
|---|---|---|---|
| prompt | string | No | Text prompt, up to 5000 chars |
| negative_prompt | string | No | Negative prompt, up to 500 chars |
| media | array | Yes | Media objects with type and url |
media types
| type | Description | Formats | Limits |
|---|---|---|---|
| first_frame | First frame image | JPEG/JPG/PNG/BMP/WEBP | [240,8000]px, ≤20MB |
| last_frame | Last frame image | JPEG/JPG/PNG/BMP/WEBP | [240,8000]px, ≤20MB |
| driving_audio | Driving audio | wav/mp3 | 2-30s, ≤15MB |
| first_clip | Video for continuation | mp4/mov | 2-10s, [240,4096]px, ≤100MB |
Media combinations
| Task | Required media |
|---|---|
| First-frame video | first_frame |
| First+last frame | first_frame + last_frame |
| Audio-driven | first_frame + driving_audio |
| Video continuation | first_clip |
parameters fields
| Field | Type | Default | Description |
|---|---|---|---|
| resolution | string | 1080P | 720P or 1080P |
| duration | integer | 5 | Video length 2-15 seconds |
| prompt_extend | boolean | true | AI prompt rewriting |
| watermark | boolean | false | "AI generated" watermark |
| seed | integer | auto | Range [0, 2147483647] |
Task creation response
{
"output": {
"task_status": "PENDING",
"task_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
},
"request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}Task polling
GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
Header: Authorization: Bearer $DASHSCOPE_API_KEYSuccess response
{
"request_id": "...",
"output": {
"task_id": "...",
"task_status": "SUCCEEDED",
"video_url": "https://...",
"orig_prompt": "original prompt text",
"actual_prompt": "rewritten prompt text"
},
"usage": {
"video_count": 1,
"video_duration": 5
}
}Task statuses
| Status | Description |
|---|---|
| PENDING | Queued |
| RUNNING | Processing |
| SUCCEEDED | Complete |
| FAILED | Failed |
| CANCELED | Canceled |
| UNKNOWN | Not found or unknown |
Sources
- 万相-图生视频2.7 API参考 — Official API documentation
- 视频生成模型概览 — Model overview and selection guide
- 模型价格 — Pricing details
- 上传文件获取临时URL — File upload for OSS temporary URLs
- 文生视频/图生视频 Prompt 指南 — Prompt writing guide
"""Wan 2.7 Image-to-Video generation via DashScope HTTP API.
Supports: first-frame, first+last frame, video continuation, audio-driven.
Usage:
python generate_i2v.py --first-frame https://example.com/img.jpg --prompt "a cat running"
python generate_i2v.py --first-frame img.jpg --last-frame img2.jpg --duration 10
python generate_i2v.py --first-clip clip.mp4 --duration 15
python generate_i2v.py --first-frame face.jpg --driving-audio speech.mp3
"""
import argparse
import json
import os
import sys
import time
import requests
API_KEY = os.getenv("DASHSCOPE_API_KEY", "")
BASE_URL = os.getenv(
"DASHSCOPE_BASE_URL",
"https://dashscope.aliyuncs.com/api/v1",
)
MODEL = "wan2.7-i2v"
OUTPUT_DIR = os.getenv("OUTPUT_DIR", "output/aliyun-wan-i2v/videos")
def _headers(async_mode: bool = True) -> dict:
h = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
if async_mode:
h["X-DashScope-Async"] = "enable"
return h
def create_task(
media: list[dict],
prompt: str = "",
negative_prompt: str | None = None,
resolution: str = "1080P",
duration: int = 5,
prompt_extend: bool = True,
watermark: bool = False,
seed: int | None = None,
) -> str:
"""Submit an async i2v task. Returns task_id."""
payload: dict = {
"model": MODEL,
"input": {"prompt": prompt, "media": media},
"parameters": {
"resolution": resolution,
"duration": duration,
"prompt_extend": prompt_extend,
"watermark": watermark,
},
}
if negative_prompt:
payload["input"]["negative_prompt"] = negative_prompt
if seed is not None:
payload["parameters"]["seed"] = seed
resp = requests.post(
f"{BASE_URL}/services/aigc/video-generation/video-synthesis",
headers=_headers(async_mode=True),
json=payload,
)
resp.raise_for_status()
data = resp.json()
if "output" not in data or "task_id" not in data["output"]:
raise RuntimeError(f"Unexpected response: {json.dumps(data, ensure_ascii=False)}")
return data["output"]["task_id"]
def poll_task(task_id: str, interval: int = 15) -> dict:
"""Poll until terminal status. Returns full response."""
while True:
resp = requests.get(
f"{BASE_URL}/tasks/{task_id}",
headers={"Authorization": f"Bearer {API_KEY}"},
)
resp.raise_for_status()
data = resp.json()
status = data["output"]["task_status"]
print(f" status: {status}")
if status in ("SUCCEEDED", "FAILED", "CANCELED"):
return data
time.sleep(interval)
def _build_media(args: argparse.Namespace) -> list[dict]:
media = []
if args.first_frame:
media.append({"type": "first_frame", "url": args.first_frame})
if args.last_frame:
media.append({"type": "last_frame", "url": args.last_frame})
if args.driving_audio:
media.append({"type": "driving_audio", "url": args.driving_audio})
if args.first_clip:
media.append({"type": "first_clip", "url": args.first_clip})
if not media:
raise ValueError("At least one media input is required (--first-frame, --first-clip, etc.)")
return media
def main() -> None:
parser = argparse.ArgumentParser(description="Wan 2.7 Image-to-Video")
parser.add_argument("--first-frame", help="First frame image URL")
parser.add_argument("--last-frame", help="Last frame image URL")
parser.add_argument("--driving-audio", help="Driving audio URL")
parser.add_argument("--first-clip", help="First clip video URL for continuation")
parser.add_argument("--prompt", default="", help="Text prompt")
parser.add_argument("--negative-prompt", default=None)
parser.add_argument("--resolution", default="1080P", choices=["720P", "1080P"])
parser.add_argument("--duration", type=int, default=5, help="Video duration 2-15s")
parser.add_argument("--seed", type=int, default=None)
parser.add_argument("--no-prompt-extend", action="store_true")
parser.add_argument("--watermark", action="store_true")
parser.add_argument("--output", default=OUTPUT_DIR, help="Output directory")
args = parser.parse_args()
if not API_KEY:
print("Error: DASHSCOPE_API_KEY not set", file=sys.stderr)
sys.exit(1)
media = _build_media(args)
print(f"Creating i2v task with {len(media)} media input(s)...")
task_id = create_task(
media=media,
prompt=args.prompt,
negative_prompt=args.negative_prompt,
resolution=args.resolution,
duration=args.duration,
prompt_extend=not args.no_prompt_extend,
watermark=args.watermark,
seed=args.seed,
)
print(f"Task created: {task_id}")
print("Polling for result...")
result = poll_task(task_id)
os.makedirs(args.output, exist_ok=True)
out_path = os.path.join(args.output, f"{task_id}.json")
with open(out_path, "w") as f:
json.dump(result, f, indent=2, ensure_ascii=False)
status = result["output"]["task_status"]
if status == "SUCCEEDED":
video_url = result["output"].get("video_url", "")
print(f"Video URL: {video_url}")
else:
print(f"Task {status}: {json.dumps(result, ensure_ascii=False)}", file=sys.stderr)
sys.exit(1)
print(f"Result saved to {out_path}")
if __name__ == "__main__":
main()