Skip to main content
Wan

Wan 2.7 - image-to-video API

The Wan 2.7 image-to-video model supports multimodal input (text, images, audio, and video) and performs three tasks: first-frame-to-video, first-and-last-frame-to-video, and video continuation .

References: User guide
The new image-to-video API (wan2.7 model) supports all three tasks. The earlier image-to-video from first frame API (wan2.6 and earlier) supports only first-frame-to-video.

Availability

The model, endpoint URL, and API key must belong to the same region. Cross-region calls fail.
The sample code in this topic applies to the Singapore region.
Alibaba Cloud Model Studio has released workspace-specific domains for the China (Beijing) and Singapore regions. The new dedicated domains deliver superior performance and higher stability for inference requests. We recommend migrating to the new domains:
  • China (Beijing): from https://dashscope.aliyuncs.com to https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com
  • Singapore: from https://dashscope-intl.aliyuncs.com to https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
{WorkspaceId} is your workspace ID, which can be found on the Workspace Details page in the Alibaba Cloud Model Studio console. The existing domain remains fully functional.

HTTP

This API uses the new image-to-video protocol and supports only the wan2.7 model.
Image-to-video tasks typically take 1 to 5 minutes, so the API uses asynchronous invocation. The workflow has two steps: create a task, then poll for the result.

Step 1: Create a task and get the task ID

  • Singapore
  • Beijing
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Replace {WorkspaceId} with your actual workspace ID.
  • After the task is created, use the returned task_id to query the result. The task_id is valid for 24 hours. Do not create duplicate tasks. Instead, use polling to retrieve the result.
  • For guidance for beginners, see Call APIs with Postman or cURL.

Request parameters

  • Video generation from the first frame
  • Video generation from the first and last frames
  • Video continuation
Generate a video based on a first frame image and audio.

# The following URL is for the Singapore region. When calling, replace {WorkspaceId} with your actual workspace ID. URLs vary by region.
curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
        -H 'X-DashScope-Async: enable' \
        -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
        -H 'Content-Type: application/json' \
        -d '{
        "model": "wan2.7-i2v-2026-04-25",
        "input": {
            "prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life on a concrete wall. He sings an English rap song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The light comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of the rap, with no other dialogue or noise.",
            "media": [
                {
                    "type": "first_frame",
                    "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
                },
                {
                    "type": "driving_audio",
                    "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"

                }
            ]
        },
        "parameters": {
            "resolution": "720P",
            "duration": 10,
            "prompt_extend": true,
            "watermark": true
        }
    }'
Content-Type string (Required)The content type of the request. Must be application/json.
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.
X-DashScope-Async string (Required)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be enable.
If this request header is missing, the error "current user api does not support synchronous calls" is returned.
Request body
model string (Required)The model name. For a list of models and their pricing, see Model pricing.Example: wan2.7-i2v-2026-04-25.
input object (Required)Basic input information, including the prompt.

Properties

prompt string (Optional)Text prompt that describes the elements and visual characteristics for the generated video.Chinese and English are supported. Up to 5,000 characters.Each Chinese character or letter counts as one character. Text that exceeds the limit is automatically truncated.Example: A kitten runs on the grass.For more information about how to use prompts, see Text-to-video/image-to-video prompt guide.negative_prompt string (Optional)Describes content to exclude from the video.Chinese and English are supported. Maximum 500 characters. Text that exceeds the limit is automatically truncated.Example: low resolution, error, worst quality, low quality, deformed, extra fingers, bad proportions.media array (Required)Reference materials (images, audio, and video) for video generation.Each element is a media object with type and url fields.

Asset combinations

Only the following asset combinations are valid. Invalid combinations return an error.
  • Video generation from the first frame:
    • First frame: first_frame
    • First frame + audio: first_frame+driving_audio
  • Video generation from the first and last frames:
    • First frame + last frame: first_frame+last_frame
    • First frame + last frame + audio: first_frame+last_frame+driving_audio
  • Video continuation:
    • First video clip continuation: first_clip
    • First video clip + last frame continuation: first_clip+last_frame

Properties

type string (Required)The media asset type. Valid values:
  • first_frame
  • last_frame
  • driving_audio
  • first_clip
Limit: Each type can appear at most once in the media array. For example, you cannot pass two first_frame assets.url string (Required)The URL of the media asset (image, audio, or video).

Pass an image (type=first_frame or last_frame)

URL or Base64-encoded data for the first or last frame image.Image limits:
  • Format: JPEG, JPG, PNG (alpha channel not supported), BMP, WEBP.
  • Resolution: The width and height must be in the range of [240, 8000] pixels.
  • Aspect ratio: 1:8 to 8:1.
  • File size: up to 20 MB.
Supported input formats:
  1. Public URL:
  2. A Base64-encoded image string:
    • Data format: data:{MIME_type};base64,{base64_data}.
    • Example: data:image/png;base64,GDU7MtCZzEbTbmRZ...... (The example is truncated for demonstration purposes).
      Format: data:{MIME_type};base64,{base64_data} .
      • {base64_data}: The Base64-encoded string of the image file.
      • {MIME_type}: The Multipurpose Internet Mail Extensions (MIME) type of the image, which must correspond to the file format.

Pass audio (type=driving_audio)

URL of the audio file.
  • With audio: The model uses it as a driving source for lip-sync and action timing.
  • Without audio: The model automatically generates matching background music or sound effects.
Audio limits:
  • Format: wav, mp3.
  • Duration: 2 s to 30 s.
  • File size: up to 15 MB.
  • Truncation: If the audio duration exceeds the duration value (for example, 5 s), the audio is automatically truncated to the first 5 seconds, and the rest is discarded. If the audio duration is shorter than the video duration, the portion of the video that exceeds the audio duration will be silent. For example, if the audio is 3 s long and the video is 5 s long, the first 3 seconds of the output video will have sound, and the last 2 seconds will be silent.
Supported input formats:
  1. Public URL:

Pass a video (type=first_clip)

URL of the video file. The model generates a continuation based on the video content. The duration parameter controls the maximum total duration of the output.
For example, if duration=15 and the input video is 3 s long, the model generates a 12-s continuation. The final output video is 15 s long and is billed for 15 s.
Video limits:
  • Format: mp4, mov.
  • Duration: 2 s to 10 s.
  • Resolution: The width and height must be in the range of [240, 4096] pixels.
  • Aspect ratio: 1:8 to 8:1.
  • File size: up to 100 MB.
Supported input formats:
  1. Public URL:
parameters object (Optional)Video processing parameters: resolution, duration, prompt rewriting, and watermarks.

Properties

resolution string (Optional)
Resolution directly affects cost. Before calling, check the Model pricing.
Resolution tier for the generated video. Controls the total pixel count.The model automatically scales the video to a total pixel count close to the selected tier. The output aspect ratio follows the input material (first frame or first video clip). For details, see FAQ.Valid values are 720P and 1080P. Default: 1080P.duration integer (Optional)
Duration directly affects cost. Billing is per second. Before calling, check the Model pricing.
Duration of the generated video in seconds. Valid range depends on the model:Valid values: an integer from 2 to 15. Default: 5.prompt_extendboolean (Optional)Whether to enable prompt rewriting. When enabled, a model rewrites the input prompt to improve results for short prompts, but increases processing time.
  • true (default)
  • false
watermark boolean (Optional)Whether to add an "AI Generated" watermark in the lower-right corner of the video.
  • false (default)
  • true
seed integer (Optional)The random number seed must be an integer in the range [0, 2147483647].If not specified, a random seed is generated. A fixed seed improves reproducibility.Because model generation is probabilistic, the same seed does not guarantee identical results.

Response parameters

  • Successful response
  • Error response
Save the task_id to query the task status and result.
{
    "output": {
        "task_status": "PENDING",
        "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
    },
    "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}
output objectTask output information.

Properties

task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.

Enumeration values

  • PENDING
  • RUNNING
  • SUCCEEDED
  • FAILED
  • CANCELED
  • UNKNOWN: The task does not exist or its status is unknown.
request_id stringUnique request identifier for tracing and troubleshooting.
code stringError code. Returned only for failed requests. See Error codes.
message stringDetailed error message. Returned only for failed requests. See Error codes.

Step 2: Query the result by task ID

  • Singapore
  • Beijing
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Replace {WorkspaceId} with your actual workspace ID.
  • Polling recommendation: Video generation takes several minutes. Use a polling mechanism with a reasonable interval, such as 15 seconds.
  • Task state transition: PENDING → RUNNING → SUCCEEDED or FAILED.
  • Result link: After a task succeeds, a video URL valid for 24 hours is returned. Download and save the video to permanent storage, such as OSS.
  • task_idvalidity: 24 hours. After this period, queries return the task status as UNKNOWN.

Request parameters

  • Query task result
Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours, Replace {WorkspaceId} with your actual workspace ID.
curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
Headers
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.
Path parameters
task_id string (Required)The ID of the task.

Response parameters

  • Task successful
  • Task failed
  • Task query expired
Video URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly.
{
    "request_id": "2ca1c497-f9e0-449d-9a3f-xxxxxx",
    "output": {
        "task_id": "af6efbc0-4bef-4194-8246-xxxxxx",
        "task_status": "SUCCEEDED",
        "submit_time": "2025-09-25 11:07:28.590",
        "scheduled_time": "2025-09-25 11:07:35.349",
        "end_time": "2025-09-25 11:17:11.650",
        "orig_prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life on a concrete wall. He sings an English rap song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The light comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise.",
        "video_url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?Expires=xxx"
    },
    "usage": {
        "duration": 15,
        "input_video_duration": 0,
        "output_video_duration": 15,
        "video_count": 1,
        "SR": 720
    }
}
outputobjectTask output information.

Properties

task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.

Enumeration values

  • PENDING
  • RUNNING
  • SUCCEEDED
  • FAILED
  • CANCELED
  • UNKNOWN: The task does not exist or its status is unknown.
State transitions during polling:
  • PENDING → RUNNING → SUCCEEDED or FAILED.
  • The initial query status is usually PENDING or RUNNING.
  • When the status changes to SUCCEEDED, the response contains the generated video URL.
  • If the status is FAILED, check the error message and retry the task.
submit_time stringThe time when the task was submitted. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.video_url stringURL of the generated video. Returned only when task_status is SUCCEEDED.Valid for 24 hours. The video is in MP4 format with H.264 encoding.orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes.
usage objectUsage statistics. Calculated only for successful tasks.

Properties

input_video_duration integerDuration of the input video, in seconds.output_video_duration integerDuration of the output video, in seconds.duration integerTotal video duration used for billing.SR integerOutput video resolution. Example: 720.video_count integerNumber of output videos. Fixed at 1.
request_id stringUnique request identifier for tracing and troubleshooting.

DashScope SDK

The SDK parameter names match those in the HTTP API. The parameter structure is encapsulated based on language conventions. Image-to-video tasks typically take 1 to 5 minutes. The SDK encapsulates the HTTP asynchronous invocation process and supports both synchronous and asynchronous calls.
Actual processing time depends on the task queue and service load. Wait for the result.

Python SDK

Make sure the DashScope Python SDK version is not lower than 1.25.16 before running the following code.If the version is too old, errors such as "url error, please check url!" may occur. For more information, see Install the SDK to update it.
Set dashscope.base_http_api_url based on the model's region:
  • Singapore
  • Beijing
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
Replace {WorkspaceId} with your actual workspace ID.
  • Synchronous call
  • Asynchronous call
Request example
# -*- coding: utf-8 -*-
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os

# The following URL is for the Singapore region. When calling, replace {WorkspaceId} with your actual workspace ID. URLs vary by region.
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'

# If you have not configured the environment variable, replace the following line with: api_key="sk-xxx"
# API keys vary by region. For more information, see https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

media = [
    {
        "type": "first_frame",
        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
    },
    {
        "type": "driving_audio",
        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
    }
]

def sample_sync_call():
    print('----Synchronous call, please wait a moment----')
    rsp = VideoSynthesis.call(
        api_key=api_key,
        model="wan2.7-i2v-2026-04-25",
        media=media,
        resolution="720P",
        duration=10,
        watermark=True,
        prompt="An urban fantasy art scene featuring a dynamic graffiti character. A boy made of spray paint comes to life on a concrete wall. He sings an English rap song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night, lit by a single street lamp. This creates a cinematic atmosphere with high energy and amazing detail. The video's audio consists entirely of the rap, with no other dialogue or noise.",
    )
    if rsp.status_code == HTTPStatus.OK:
        print(rsp.output.video_url)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (rsp.status_code, rsp.code, rsp.message))

if __name__ == '__main__':
    sample_sync_call()
Response example
The video_url is valid for 24 hours. Download the video promptly.
{
    "status_code": 200,
    "request_id": "ac5faf37-ddfa-9720-a0c5-xxxxxx",
    "code": null,
    "message": "",
    "output": {
        "task_id": "b97c6d86-ad73-4bb7-80ff-xxxxxx",
        "task_status": "SUCCEEDED",
        "video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
        "submit_time": "2026-04-13 10:45:47.597",
        "scheduled_time": "2026-04-13 10:45:56.342",
        "end_time": "2026-04-13 10:47:26.273",
        "orig_prompt": "An urban fantasy art scene. A dynamic graffiti character. A boy made of spray paint comes to life on a concrete wall. He performs a fast-paced English rap song while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The light comes from a single street lamp, creating a cinematic atmosphere with high energy and incredible detail. The audio consists solely of the rap, with no other dialogue or background noise."
    },
    "usage": {
        "video_count": 1,
        "duration": 10,
        "input_video_duration": 0,
        "output_video_duration": 10,
        "SR": 720
    }
}

Java SDK

Ensure that the DashScope Java SDK version is not lower than 2.22.14 before running the following code.If the version is too old, errors such as "url error, please check url!" may occur. For more information, see Install the SDK to update it.
Set Constants.baseHttpApiUrl based on the model's region:
  • Singapore
  • Beijing
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1"
Replace {WorkspaceId} with your actual workspace ID.
  • Synchronous call
  • Asynchronous call
A synchronous call blocks until the video generation is complete and the result is returned.
Request example
// Copyright (c) Alibaba, Inc. and its affiliates.

import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;

import java.util.ArrayList;
import java.util.List;

public class Image2Video {

    static {
        // The following URL is for the Singapore region. When calling, replace {WorkspaceId} with your actual workspace ID. URLs vary by region.
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
    }

    // If the environment variable is not configured, replace the following line with: apiKey="sk-xxx"
    // API keys are region-specific. To obtain an API key, visit: https://www.alibabacloud.com/help/en/model-studio/get-api-key
    static String apiKey = System.getenv("DASHSCOPE_API_KEY");

    public static void syncCall() {
        VideoSynthesis videoSynthesis = new VideoSynthesis();
        final String prompt = "A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life on a concrete wall. He sings an English rap song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The light comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise.";
        List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>(){{
            add(VideoSynthesisParam.Media.builder()
                    .url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png")
                    .type("first_frame")
                    .build());
            add(VideoSynthesisParam.Media.builder()
                    .url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3")
                    .type("driving_audio")
                    .build());
        }};
        VideoSynthesisParam param =
                VideoSynthesisParam.builder()
                        .apiKey(apiKey)
                        .model("wan2.7-i2v-2026-04-25")
                        .prompt(prompt)
                        .media(media)
                        .watermark(true)
                        .duration(10)
                        .resolution("720P")
                        .build();
        VideoSynthesisResult result = null;
        try {
            System.out.println("---Sync call, please wait...----");
            result = videoSynthesis.call(param);
        } catch (ApiException | NoApiKeyException e){
            throw new RuntimeException(e.getMessage());
        } catch (InputRequiredException e) {
            throw new RuntimeException(e);
        }
        System.out.println(JsonUtils.toJson(result));
    }

    public static void main(String[] args) {
        syncCall();
    }
}
Response example
The video_url is valid for 24 hours. Download the video promptly.
{
    "request_id": "78178b55-8399-9823-8173-xxxxxx",
    "output": {
        "task_id": "be457e1b-8a79-47ed-aeff-xxxxxx",
        "task_status": "SUCCEEDED",
        "video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
        "orig_prompt": "An urban fantasy art scene featuring a dynamic graffiti art character. A boy made of spray paint comes to life on a concrete wall. He rapidly sings an English rap song while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. A single street lamp provides the light, creating a high-energy cinematic atmosphere with incredible detail. The audio consists entirely of his rap, with no other dialogue or background noise.",
        "submit_time": "2026-04-13 10:57:36.795",
        "scheduled_time": "2026-04-13 10:57:46.280",
        "end_time": "2026-04-13 10:59:16.338"
    },
    "usage": {
        "video_count": 1,
        "duration": 10,
        "input_video_duration": 0,
        "output_video_duration": 10,
        "SR": 720
    },
    "status_code": 200,
    "code": "",
    "message": ""
}

Error codes

If a model call fails and returns an error message, see Error codes to resolve the issue.

FAQ

Q: How do I generate a video with a specific aspect ratio, such as 3:4?

A: The output aspect ratio is determined by the input material (first frame image or first video clip) but is not guaranteed to match exactly. A slight drift may occur. The following example explains the logic using a first frame image as input:
  • Why does drift occur?
    • Execution logic: The system uses the input image's aspect ratio as a baseline, combined with the target total pixels for the resolution tier. Because video encoding requires width and height to be multiples of 16, the system adjusts the output to the closest valid resolution.
    • Calculation example: A 750 x 1000 pixel input image (3:4 ratio = 0.75) with "720P" resolution (~920,000 total pixels) produces an 816 x 1104 pixel output (ratio ~0.739, ~900,000 total pixels).
  • Recommendations:
    • Input control: Use a first frame or video clip that matches your target aspect ratio.
    • Post-processing: For strict aspect ratio requirements, crop the video or add black bars after generation.

Q: How do I get the whitelist of domain names for video storage access?

A: Videos generated by models are stored in OSS. The API returns a temporary public URL. To configure a firewall whitelist for this download URL, note the following: The underlying storage may change dynamically. This topic does not provide a fixed OSS domain name whitelist to prevent access issues caused by outdated information. If you have security control requirements, contact your account manager to obtain the latest OSS domain name list.
Text Generation
Image Generation
  • FAQ
Audio
Realtime API
Text Embedding
Model Production
Wan 2.7 - image-to-video API - Alibaba Cloud Model Studio