Skip to main content

Wan-I2V based on first frame

The Wan-I2V model supports multimodal input (text/image/audio) and can generate videos up to 15 seconds in length at 1080P resolution.

  • Basic settings: Supports integer-level video duration (2 to 15 seconds), specified video resolution (480P/720P/1080P), intelligent prompt rewriting, and adding watermarks.
  • Audio capabilities: Supports automatic dubbing or audio upload to achieve audio-visual synchronization. (Supported by wan2.5 and wan2.6)
  • Multi-shot narrative: Can generate videos containing multiple shots, keeping the subject consistent across shot transitions. (Only supported by wan2.6)
Quick access: Online experience (Singapore|Virginia|Beijing)|API reference

QuickStart

Input promptInput first-frame imageOutput video (multi-shot, with audio)
The camera slowly moves up from beneath the sea turtle, which swims leisurely with the details of its belly clearly visible.
wan-i2v-haigui
Before making calls, first obtain and configure an API Key, and then configure the API Key in environment variables. To make calls through the SDK, please install the DashScope SDK.
  • Python SDK
  • Java SDK
  • curl
Please make sure the DashScope Python SDK version is no earlier than 2.0.1 before running the following code.If the version is too old, errors such as "url error, please check url!" may occur. Please refer to Install SDK to update.
import os
import dashscope
from dashscope import DashScopeError

# The following configuration is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. The region value varies by region. For the endpoints of each region, see https://www.alibabacloud.com/help/model-studio/image-to-video-api-reference
# API keys are region-specific. To get an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
client = dashscope.Client(
    api_key=os.getenv("DASHSCOPE_API_KEY", "YOUR_API_KEY"),
    workspace="{WorkspaceId}",
    region="ap-southeast-1",
)

print('please wait...')
# generate is a one-step call (submit the task and wait for completion) and returns a completed Job
# shot_type is not part of the named signature, and is passed through via parameters
try:
    job = client.videos.generate(model='wan2.6-i2v-flash',
                                 prompt='镜头从海龟下方缓缓上移,海龟悠然游动,腹部细节清晰可见。',
                                 image_url="https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260121/zlpocv/wan-i2v-haigui.webp",
                                 resolution="720P",
                                 duration=10,
                                 prompt_extend=True,
                                 watermark=True,
                                 parameters={'shot_type': "multi"})
    print(job)
    print("video_url:", job.video_url)
except DashScopeError as e:
    print(f"HTTP status code: {e.status_code}")
    print(f"Error code: {e.code}")
    print(f"Error message: {e.message}")
    print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")
Sample Output
video_url is valid for 24 hours. Please download the video in time.
{
    "request_id": "c1209113-8437-424f-a386-xxxxxx",
    "output": {
        "task_id": "966cebcd-dedc-4962-af88-xxxxxx",
        "task_status": "SUCCEEDED",
        "video_url": "https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
         ...
    },
    ...
}

Scope of application

  • The models supported vary by region, and resources are independent of each other. For the models supported in each region, see the Model Studio console.
  • When making calls, make sure that the model, Endpoint URL, and API Key all belong to the same region; cross-region calls will fail.
The sample code in this document applies to the Singapore region.

Core capabilities

Creating multi-shot videos

Supported models: wan2.6 series models. Overview: The model can automatically switch between shots, for example from a wide shot to a close-up, making it suitable for scenarios such as MV production. Parameter settings:
  • shot_type: must be set to "multi".
  • prompt_extend: must be set to true (enables smart rewriting to optimize shot descriptions).
Input promptInput first-frame imageOutput video (wan2.6, multi-shot video)
An urban fantasy art scene. A dynamic graffiti art character. A teenager painted with spray paint is coming to life from a concrete wall. While performing an English rap at an extremely fast pace, he strikes a classic, energetic rapper pose. The scene is set at night under an urban railway bridge. The lighting comes from a lone street lamp, creating a cinematic atmosphere full of high energy and stunning details. The audio portion of the video consists entirely of rap, with no other dialogue or noise.rap-转换自-pngInput audio:
  • Python SDK
  • Java SDK
  • curl
Please ensure that the DashScope Python SDK version is 2.0.1 or later. For updates, see Install SDK.
import os
import dashscope
from dashscope import DashScopeError

# The following configuration is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. The region value varies by region. For the endpoints of each region, see https://www.alibabacloud.com/help/model-studio/image-to-video-api-reference
client = dashscope.Client(
    # If the environment variable is not configured, set your Model Studio API key directly: api_key="sk-xxx"
    # API keys are region-specific. To get an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="ap-southeast-1",
)

def sample_async_call_i2v():
    # Asynchronous call, which returns a task_id
    try:
        # audio_url / negative_prompt are input-section fields that are not part of the named signature, and are passed through via extra_input
        # shot_type (multi-shot) is a parameters-section field, and is passed through via parameters
        job = client.videos.jobs.create(model='wan2.6-i2v-flash',
                                        prompt='一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由rap构成,没有其他对话或杂音。',
                                        image_url="https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png",
                                        extra_input={'audio_url': "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3",
                                                     'negative_prompt': ""},
                                        resolution="720P",
                                        duration=10,
                                        prompt_extend=True,
                                        watermark=True,
                                        seed=12345,
                                        parameters={'shot_type': "multi"})  # Multi-shot
        print(job)
        print("task_id: %s" % job.task_id)
    except DashScopeError as e:
        print(f"HTTP status code: {e.status_code}")
        print(f"Error code: {e.code}")
        print(f"Error message: {e.message}")
        print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")
        return

    # Wait for the asynchronous task to complete (exponential backoff polling, default total budget of 24 hours)
    try:
        done = client.videos.jobs.wait(job)
        print(done)
        print(done.video_url)
    except DashScopeError as e:
        print(f"HTTP status code: {e.status_code}")
        print(f"Error code: {e.code}")
        print(f"Error message: {e.message}")
        print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")

if __name__ == '__main__':
    sample_async_call_i2v()

Achieve audio-visual synchronization

Supported models: wan2.5 and wan2.6 series models. Overview: Make the person in a photo speak or sing, with lip movements matched to the audio. For more examples, see Video voice generation. Parameter settings:
  • Provide an audio file: Pass in audio_url. The model aligns lip movements with the audio file.
  • Automatic dubbing: No need to pass in audio_url; the output is a video with audio by default. The model automatically generates background sound effects, music, or vocals based on the visuals.
Input promptInput first-frame imageOutput video (video with audio)
An urban fantasy art scene. A dynamic graffiti art character. A teenager painted with spray paint is coming to life from a concrete wall. While performing an English rap at an extremely fast pace, he strikes a classic, energetic rapper pose. The scene is set at night under an urban railway bridge. The lighting comes from a lone street lamp, creating a cinematic atmosphere full of high energy and stunning details. The audio portion of the video consists entirely of rap, with no other dialogue or noise.rap-转换自-pngInput audio:
  • Python SDK
  • Java SDK
  • curl
Please ensure that the DashScope Python SDK version is 2.0.1 or later. For updates, see Install SDK.
import os
import dashscope
from dashscope import DashScopeError

# The following configuration is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. The region value varies by region. For the endpoints of each region, see https://www.alibabacloud.com/help/model-studio/image-to-video-api-reference
client = dashscope.Client(
    # If the environment variable is not configured, set your Model Studio API key directly: api_key="sk-xxx"
    # API keys are region-specific. To get an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="ap-southeast-1",
)

def sample_async_call_i2v():
    # Asynchronous call, which returns a task_id
    try:
        # audio_url / negative_prompt are input-section fields that are not part of the named signature, and are passed through via extra_input
        job = client.videos.jobs.create(model='wan2.6-i2v-flash',
                                        prompt='一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由rap构成,没有其他对话或杂音。',
                                        image_url="https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png",
                                        extra_input={'audio_url': "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3",
                                                     'negative_prompt': ""},
                                        resolution="720P",
                                        duration=10,
                                        prompt_extend=True,
                                        watermark=True,
                                        seed=12345)
        print(job)
        print("task_id: %s" % job.task_id)
    except DashScopeError as e:
        print(f"HTTP status code: {e.status_code}")
        print(f"Error code: {e.code}")
        print(f"Error message: {e.message}")
        print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")
        return

    # Wait for the asynchronous task to complete (exponential backoff polling, default total budget of 24 hours)
    try:
        done = client.videos.jobs.wait(job)
        print(done)
        print(done.video_url)
    except DashScopeError as e:
        print(f"HTTP status code: {e.status_code}")
        print(f"Error code: {e.code}")
        print(f"Error message: {e.message}")
        print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")

if __name__ == '__main__':
    sample_async_call_i2v()

Generate silent videos

Supported models: wan2.6-i2v-flash, wan2.2 series models, wan2.1 series models. Overview: Suitable for purely visual display scenarios that do not require audio, such as animated posters and silent short videos. Parameter settings:
  • wan2.6-i2v-flash: Generates videos with audio by default. To generate a silent video, you must explicitly set audio=false. Even if audio_url is passed in, as long as audio=false, the output is still a silent video and is billed under silent video billing.
  • wan2.2 and earlier series models: Generate silent videos by default; no additional configuration is required.
PromptInput first-frame imageOutput video (silent video)
A cat running on the grassimage
  • Python SDK
  • Java SDK
  • curl
Please ensure that the DashScope Python SDK version is 2.0.1 or later. For updates, see Install SDK.
import os
import dashscope
from dashscope import DashScopeError

# The following configuration is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. The region value varies by region. For the endpoints of each region, see https://www.alibabacloud.com/help/model-studio/image-to-video-api-reference
client = dashscope.Client(
    # If the environment variable is not configured, set your Model Studio API key directly: api_key="sk-xxx"
    # API keys are region-specific. To get an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="ap-southeast-1",
)

def sample_async_call_i2v():
    # Asynchronous call, which returns a task_id
    try:
        # negative_prompt is an input-section field, and is passed through via extra_input
        # audio (must be explicitly set to False to generate a silent video) is a parameters-section field, and is passed through via parameters
        job = client.videos.jobs.create(model='wan2.6-i2v-flash',
                                        prompt='一只猫在草地上奔跑',
                                        image_url="https://cdn.translate.alibaba.com/r/wanx-demo-1.png",
                                        extra_input={'negative_prompt': ""},
                                        resolution="720P",
                                        duration=5,
                                        prompt_extend=True,
                                        watermark=True,
                                        seed=12345,
                                        parameters={'audio': False})   # Set to False to generate a silent video
        print(job)
        print("task_id: %s" % job.task_id)
    except DashScopeError as e:
        print(f"HTTP status code: {e.status_code}")
        print(f"Error code: {e.code}")
        print(f"Error message: {e.message}")
        print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")
        return

    # Wait for the asynchronous task to complete (exponential backoff polling, default total budget of 24 hours)
    try:
        done = client.videos.jobs.wait(job)
        print(done)
        print(done.video_url)
    except DashScopeError as e:
        print(f"HTTP status code: {e.status_code}")
        print(f"Error code: {e.code}")
        print(f"Error message: {e.message}")
        print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")

if __name__ == '__main__':
    sample_async_call_i2v()

How to provide images and audio

Provide an image

  • Number of images: 1.
  • Input methods: Image URL, local file path, or Base64-encoded string.

Method 1: Image URL (HTTP API, SDK) (Recommended)

Different programming languages (Python/Java) have slightly different requirements for file paths. Strictly follow the rules below when writing them.Python SDK: Supports both absolute and relative paths. File path rules are as follows:

Operating system

File path to pass in

Example (absolute path)

Example (relative path)

Linux / macOS

file://{absolute or relative path of the file}

file:///home/images/test.png

file://./images/test.png

Windows

file://D:/images/test.png

file://./images/test.png

Java SDK: Supports only absolute paths. File path rules are as follows:

Operating system

File path to pass in

Example (absolute path)

Linux / macOS

file://{absolute path of the file}

file:///home/images/test.png

Windows

file:///{absolute path of the file}

file:///D:/images/test.png

  • Sample value: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABDg...... (truncated for demonstration only).
  • Format requirements: Follow the data:{MIME_type};base64,{base64_data} format, where:
    • {base64_data}: The string obtained by Base64-encoding the image file.
    • {MIME_type}: The media type of the image, which must match the file format.

      Image format

      MIME Type

      JPEG

      image/jpeg

      JPG

      image/jpeg

      PNG

      image/png

      BMP

      image/bmp

      WEBP

      image/webp

Sample code: three input methods
Python SDK
import base64
import os
import mimetypes
import dashscope
from dashscope import DashScopeError

# The following configuration is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. The region value varies by region.
# For the endpoints of each region, see https://www.alibabacloud.com/help/model-studio/image-to-video-api-reference
client = dashscope.Client(
    # If the environment variable is not configured, set your Model Studio API key directly: api_key="sk-xxx"
    # To get an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="ap-southeast-1",
)

# --- Helper function: for Base64 encoding ---
# The format is data:{MIME_type};base64,{base64_data}
def encode_file(file_path):
    mime_type, _ = mimetypes.guess_type(file_path)
    if not mime_type or not mime_type.startswith("image/"):
        raise ValueError("不支持或无法识别的图像格式")
    with open(file_path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
    return f"data:{mime_type};base64,{encoded_string}"

"""
图像输入方式说明:
以下提供了三种图片输入方式,

1. 使用公网URL - 适合已有公开可访问的图片
2. 使用本地文件 - 适合本地开发测试
3. 使用Base64编码 - 适合私有图片或需要加密传输的场景
"""

# [Method 1] Use a publicly accessible image URL
# Example: Use a public image URL
img_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"

# [Method 2] Use a local file (supports absolute and relative paths)
# Format: file:// + file path
# Example (absolute path):
# img_url = "file://" + "/path/to/your/img.png"    # Linux/macOS
# img_url = "file://" + "/C:/path/to/your/img.png"  # Windows
# Example (relative path):
# img_url = "file://" + "./img.png"                # Relative to the current script's directory

# [Method 3] Use a Base64-encoded image
# img_url = encode_file("./img.png")

# Set the audio url
audio_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"

def sample_call_i2v():
    # Synchronous call, which returns the result directly
    print('please wait...')
    # generate is a one-step call (submit the task and wait for completion) and returns a completed Job
    # audio_url / negative_prompt are input-section fields that are not part of the named signature, and are passed through via extra_input
    try:
        job = client.videos.generate(model='wan2.6-i2v-flash',
                                     prompt='一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由他的rap构成,没有其他对话或杂音。',
                                     image_url=img_url,
                                     extra_input={'audio_url': audio_url,
                                                  'negative_prompt': ""},
                                     resolution="720P",
                                     duration=10,
                                     prompt_extend=True,
                                     watermark=False,
                                     seed=12345)
        print(job)
        print("video_url:", job.video_url)
    except DashScopeError as e:
        print(f"HTTP status code: {e.status_code}")
        print(f"Error code: {e.code}")
        print(f"Error message: {e.message}")
        print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")

if __name__ == '__main__':
    sample_call_i2v()

Input audio

  • Number of audio files: 1.
  • Input method:
    • Public URL: HTTP or HTTPS protocols are supported.

Output video

  • Number of videos: 1.
  • Output video specifications: Supported output specifications vary by model. See Applicable scope.
  • Output video URL validity: 24 hours.
  • Output video dimensions: Determined by the input image and the set resolution resolution.
    • The model tries to keep the aspect ratio of the input image unchanged while scaling to a total pixel count close to the target. Due to encoding specifications, width and height must be divisible by 16, and the model automatically fine-tunes the dimensions.
    • For example: with an input image of 750×1000 (aspect ratio 3:4 = 0.75) and resolution set to "720P" (target total pixels of about 920,000), the final output may be 816 × 1104 (aspect ratio ≈ 0.739, total pixels ≈ 900,000), with both width and height being multiples of 16.

Billing and rate limits

  • For model free quotas and billing unit prices, see Model Price.
  • For model rate limits, see Wan series.
  • Billing details:
    • Input is not billed; output is billed. Billing is based on the video seconds of successfully generated videos.
    • Failed model calls or processing errors incur no fees and do not consume the new-user free quota.
    • I2V also supports the savings plan.

API docs

I2V - first-frame-based API reference

FAQ

Q: Why can't I directly set the video aspect ratio (such as 16:9)?

A: The current API does not support directly specifying the video aspect ratio. You can only set the video resolution through the resolution parameter. resolution controls the total number of pixels in the video, not a fixed ratio. The model prioritizes preserving the original aspect ratio of the input first-frame image (approximately) and makes minor adjustments on this basis to meet the video encoding requirements (that is, both the width and height must be multiples of 16).

Q: Why does the "url error, please check url!" error occur when I run SDK code?

A: Please ensure:
  • The DashScope Python SDK version is 2.0.1 or later.
  • The DashScope Java SDK version is 2.22.6 or later.
If the version is too old, the "url error, please check url!" error may be triggered. Refer to Upgrade SDK to update.