The Wan image-to-video model generates a smooth video from a first-frame image and a text prompt .
Related documents: User guide
Your model, endpoint URL, and API key must be in the same region. Cross-region calls fail.
Image-to-video tasks use asynchronous invocation (typically 1–5 minutes): create task -> poll for results.
Replace
Replace
SDK parameter names are largely consistent with the HTTP API, following each language's conventions.
Image-to-video tasks typically take 1–5 minutes. The SDK wraps the asynchronous HTTP call process and supports both synchronous and asynchronous calls.
Set the
Replace
Set the
Replace
When using wan2.6-i2v-flash to generate animations of continuously rotating circular objects (such as rings, gears, and dials), the video may briefly freeze (the frame stays still for about 1 second) after about 3 seconds. To generate such continuous rotation effects, we recommend switching to the Wan2.7-I2V model to avoid this issue.
If a model call returns an error message, see Error codes.
A: The input first-frame image (img_url) determines the aspect ratio of the output video. However, an exact ratio like 3:4 is not guaranteed, as minor deviations may occur.
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.
Wan 2.7 - image-to-video supports first-frame-to-video, first-and-last-frame-to-video, and video continuation. We recommend this version.The image-to-video (based on first frame) feature for Wan 2.6 and earlier models supports only first-frame-to-video.
Availability
Your model, endpoint URL, and API key must be in the same region. Cross-region calls fail.
- Select Model: Confirm the region of the model.
- Select URL: Select the Endpoint URL of the corresponding region. HTTP URL or DashScope SDK URL is supported.
- Configure API Key: Obtain the API Key of the region, and then configure the API Key in environment variables.
- Install SDK: To call through the SDK, please install the DashScope SDK.
The sample code in this topic is for the China (Beijing) region.
HTTP call
Image-to-video tasks use asynchronous invocation (typically 1–5 minutes): create task -> poll for results.
Step 1: Create a task
- Beijing
- Singapore
- Virginia
- Frankfurt
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis{WorkspaceId} with your actual workspace ID.
- After the task is created, use the
task_idreturned by the API to query the result. task_id is valid for 24 hours. Do not create tasks repeatedly; polling is sufficient to obtain the result. - For beginner guidance, see Postman.
Request parametersHeadersContent-Typestring (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)Asynchronous processing configuration parameter. HTTP requests support asynchronous mode only, and it must be set to enable.Request bodymodelstring (Required)The model name. Available models and pricing: model pricing.Example: wan2.6-i2v-flash.input object (Required)Input fields including the prompt.
Properties prompt string (Optional)Describes the desired visual elements and characteristics of the generated video.Supports Chinese and English. Each character counts as one. Text exceeding the limit is truncated. Length limits by model:
template is not empty), the model ignores the prompt parameter and you do not need to set it.Example: A kitten running on the grass.Prompt writing tips: Text-to-Video/Image-to-Video Prompt Guide.negative_prompt string (Optional)Describes what to exclude from the video, constraining the output.Supports Chinese and English. Maximum 500 characters; longer text is truncated.Example: low resolution, errors, worst quality, low quality, disfigured, extra fingers, poor proportions, etc.img_url string (Required)The URL or Base64-encoded data of the initial image.Image constraints:
string (Optional)Supported models: Wan2.6 and Wan2.5 series models.The URL of the audio file. The model generates the video using this audio.Supported input formats:
string (Optional)The name of the video effect template. If you leave this empty, no video effect is applied.Supported templates vary by model. Check the Wan - Image-to-Video - Video Effects List before calling.Example: flying, which enables the "Magic Levitation" video effect.object (Optional)Controls for resolution, duration, intelligent prompt rewriting, and watermarks.
Properties resolution string (Optional)Specifies the video resolution tier for generation, which adjusts the video clarity (total pixels). Based on the selected resolution tier, the model automatically scales to a similar total pixel count. The video aspect ratio will keep consistent with the aspect ratio of the input image img_url as much as possible. For more information, see FAQ.The default value and available enumeration values of this parameter depend on the model parameter, as follows:
integer (Optional)The duration of the generated video, in seconds. The value of this parameter depends on the model parameter:
boolean (Optional)Whether to enable prompt rewriting. When enabled, an LLM rewrites the input prompt. This improves generation quality for shorter prompts but increases processing time.
string (Optional)Supported models: Wan2.6 series models.Specifies the shot type of the generated video: a single continuous shot or a sequence of multiple shots.This parameter takes effect only when "prompt_extend": true.Parameter priority: shot_type > prompt. For example, if shot_type is set to "single", even if the prompt contains "generate a multi-shot video", the model will still output a single-shot video.Valid values:
Use this parameter when you need strict control over the narrative structure, such as a single shot for product demos or multiple shots for short films. boolean (Optional)Supported model: wan2.6-i2v-flash.Specifies whether to generate a video with sound.Parameter priority: audio > audio_url. When audio=false, the output is still a silent video even if an audio_url is provided, and billing is based on a silent video.Valid values:
boolean (Optional)Specifies whether to add an "AI Generated" watermark in the lower-right corner of the video.
integer(Optional)The random number seed. Value range: [0, 2147483647].If not specified, the system generates one. For better reproducibility, use a fixed seed.Generation is probabilistic. Even with the same seed, results may differ.Example: 12345. |
This feature is supported only by the Wan2.6 series models.You can enable it by setting "prompt_extend": true and "shot_type":"multi". |
Response parametersoutputobjectInformation about the task output.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringUnique request identifier for tracing and troubleshooting.codestringError code. Returned only for failed requests. See Error codes.messagestringDetailed error message. Returned only for failed requests. See Error codes. |
Please save the task_id, which is used to query the task status and results. |
Step 2: Query the task result
- Beijing
- Singapore
- Virginia
- Frankfurt
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}{WorkspaceId} with your actual workspace ID.
- Polling recommendation: Video generation takes several minutes. We recommend using a polling mechanism and setting a reasonable query interval (such as 15 seconds) to obtain the result.
- Task status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- Result link: The video link is returned after the task succeeds, with a validity of 24 hours. We recommend downloading the video immediately after obtaining the link and transferring it to permanent storage (such as Alibaba Cloud OSS).
- task_id validity: 24 hours. After it expires, the result can no longer be queried, and the API returns a task status of
UNKNOWN. - RPS limit: The default RPS of the query API is 20. For higher-frequency queries or event notifications, we recommend configuring asynchronous task callbacks.
- More operations: For batch queries, task cancellation, and other operations, see Manage asynchronous tasks.
Request parametersHeadersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.Path parameterstask_idstring (Required)The ID of the task. |
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. |
Response parametersoutputobjectInformation about the task output.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. format is YYYY-MM-DD HH:mm:ss.SSS.video_urlstringVideo URL. 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.actual_prompt stringWhen prompt_extend=true, the system intelligently rewrites the input prompt, and this field returns the optimized prompt actually used for generation.
stringError code. Returned only for failed requests. See Error codes.messagestringDetailed error message. Returned only for failed requests. See Error codes.objectUsage statistics for the task, which are counted only for successful tasks.
Properties
Parameters returned by wan2.6 series models input_video_duration integerThe duration of the input video in seconds. This is always 0, as video input is not currently supported.output_video_duration integerReturned only when using wan2.6 models.The duration of the output video in seconds. This value matches the input.duration.duration integerThe total video duration, used for billing.Billing formula: duration=input_video_duration+output_video_duration.SR integerReturned only when using wan2.6 models. The resolution tier of the generated video. Example: 720.video_count integerThe number of generated videos. This is fixed at 1.audiobooleanReturned only when using the wan2.6-i2v-flash model. Indicates whether the output is a video with audio.
Parameters returned by wan2.2 and wan2.5 series models duration integerThe duration of the generated video in seconds. Possible values: 5, 10.Billing formula: Cost = Video duration in seconds × Unit price.SR integerThe resolution of the generated video. Possible values: 480, 720, 1080.video_count integerThe number of generated videos. This is fixed at 1.
Parameters returned by wan2.1 series models video_duration integerThe duration of the generated video in seconds. Possible values: 3, 4, 5.Billing formula: Cost = Video duration in seconds × Unit price.video_ratio stringThe aspect ratio of the generated video. This value is always "standard".video_count integerThe number of generated videos. This is fixed at 1.stringUnique request identifier for tracing and troubleshooting. |
Video URLs are valid for only 24 hours and then automatically purged. Save generated videos promptly. |
DashScope SDK calls
SDK parameter names are largely consistent with the HTTP API, following each language's conventions.
Image-to-video tasks typically take 1–5 minutes. The SDK wraps the asynchronous HTTP call process and supports both synchronous and asynchronous calls.
Processing time depends on the task queue and service status.
Python SDK
Set the region according to the model's region (passed in when constructing the Client; the region value varies by region):
- Beijing
- Singapore
- Virginia
- Frankfurt
region="cn-beijing"{WorkspaceId} with your actual workspace ID.
Sample code
- Synchronous call
- Asynchronous call
A synchronous call blocks until video generation completes. This example demonstrates three image input methods: public URL, Base64 encoding, and local file path.
Request example
Response example
The video_url is valid for 24 hours. Download the video before it expires.
Java SDK
Set the baseHttpApiUrl according to the model's region:
- Beijing
- Singapore
- Virginia
- Frankfurt
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";{WorkspaceId} with your actual workspace ID.
Sample code
- Synchronous call
- Asynchronous call
A synchronous call blocks until video generation completes. This example demonstrates three image input methods: public URL, Base64 encoding, and local file path.
Request example
Response example
The video_url is valid for 24 hours. Download the video before it expires.
Limitations
- Data retention: Both the task task_id and the video url are retained for only 24 hours; after expiration, they can no longer be queried or downloaded.
- Content moderation: The input content (such as prompts and images) and the output video are subject to content security review. If prohibited content is detected, the “IPInfringementSuspect” or “DataInspectionFailed” error is returned. For more information, see Error code.
Known limitations
When using wan2.6-i2v-flash to generate animations of continuously rotating circular objects (such as rings, gears, and dials), the video may briefly freeze (the frame stays still for about 1 second) after about 3 seconds. To generate such continuous rotation effects, we recommend switching to the Wan2.7-I2V model to avoid this issue.
Error codes
If a model call returns an error message, see Error codes.
FAQ
Q: How to generate a video with a specific aspect ratio?
A: The input first-frame image (img_url) determines the aspect ratio of the output video. However, an exact ratio like 3:4 is not guaranteed, as minor deviations may occur.
-
Why do deviations occur?
The model uses the aspect ratio of the input image as the baseline and, combined with the total pixels of the configured resolution tier (resolution), automatically calculates the closest valid resolution. Because the width and height of the video must be multiples of 16, the model fine-tunes the final resolution. Therefore, the output ratio cannot be guaranteed to be exactly 3:4, but it will be very close.
- Example: The input image is 750×1000 (aspect ratio 3:4 = 0.75), and resolution = "720P" is set (target total pixels approximately 920,000). The actual output is 816×1104 (aspect ratio ≈ 0.739, total pixels approximately 900,000).
-
Best practice:
- Control the input: For best results, use a first-frame image that already has your target aspect ratio.
- Post-processing: If you need a strict aspect ratio, crop the video or add black bars using an editing tool after generation.