Aliyun wan i2v

From cinience/alicloud-skills · View interactive version

Aliyun wan i2v is an AI agent skill from the GitHub repository cinience/alicloud-skills. Use 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.

How to use this skill

Skill file

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.txt

Pass criteria: command exits 0 and output/aliyun-wan-i2v/validate.txt is generated.

Output And Evidence

Prerequisites

python3 -m venv .venv
. .venv/bin/activate
python -m pip install dashscope

Critical model names

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-synthesis

Required headers:

Singapore endpoint: replace dashscope.aliyuncs.com with dashscope-intl.aliyuncs.com.

Normalized interface

Request

Media input limits

Images (first_frame, last_frame):

Audio (driving_audio):

Video (first_clip):

Response (task creation)

Response (task result)

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

Anti-patterns

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.