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 wan2.6-i2v-flash generates continuous rotation of a circular object (such as a ring, gear, or clock dial), the video may stall for about 1 second at around the 3-second mark. To avoid this issue, use the Wan 2.7 - image-to-video model instead.
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 a model: Confirm the region where the model is available.
- Select a URL: Select the endpoint URL for the corresponding region. Both HTTP and DashScope SDK URLs are supported.
- Configure an API key: Obtain an API key for the region, and then configure the API key in your environment variables.
- Install the SDK: To make calls with the SDK, install the DashScope SDK.
The sample code in this topic is for the Singapore region.
HTTP call
Image-to-video tasks use asynchronous invocation (typically 1–5 minutes): create task -> poll for results.
Step 1: Create a task
- Singapore
- Virginia
- Beijing
- Frankfurt
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis{WorkspaceId} with your actual workspace ID.
- After the task is created, use the returned
task_idto query the result. Thetask_idis 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 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)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be 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:
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:
object (Optional)Controls for resolution, duration, intelligent prompt rewriting, and watermarks.
Properties resolution string (Optional)Specifies the output video resolution tier. The model scales the output to a similar total pixel count based on the selected tier. The model maintains the output aspect ratio as close as possible to that of the input image inimg_url. For details, see FAQ.The default value and available enum values for this parameter depend on the model parameter, as follows:
integer (Optional)The output video duration, in seconds. Valid values depend 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.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. |
Save the task_id to query the task status and result. |
Step 2: Query the task result
- Singapore
- Virginia
- China (Beijing)
- Frankfurt
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}{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 asUNKNOWN.
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 parametersoutputobjectThe output details of the task.
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. 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.actual_prompt stringIf prompt_extend is true, the system rewrites the prompt, and this field contains the optimized version.
stringError code. Returned only for failed requests. See Error codes.message stringDetailed 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 base_http_api_url according to the model's region:
- Singapore
- Virginia
- Beijing
- Frankfurt
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.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.
Java SDK
Set the baseHttpApiUrl according to the model's region:
- Singapore
- Virginia
- Beijing
- Frankfurt
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.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: The
task_idand video URL are retained for 24 hours. After this period, you cannot query or download them. - Content moderation: All inputs (prompts, images) and output videos are subject to content moderation. Violations result in an
IPInfringementSuspectorDataInspectionFailederror. Error codes.
Known limitations
When wan2.6-i2v-flash generates continuous rotation of a circular object (such as a ring, gear, or clock dial), the video may stall for about 1 second at around the 3-second mark. To avoid this issue, use the Wan 2.7 - image-to-video model instead.
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 input image's aspect ratio as a baseline and combines it with the total pixel count of the selected resolution tier (
resolution) to calculate the closest valid resolution. Because a video's width and height must be multiples of 16, the model adjusts the final resolution accordingly. As a result, the output aspect ratio is not guaranteed to be exactly 3:4, but it will be very close.- For example, an input image of 750×1000 (aspect ratio 3:4 = 0.75) with
resolutionset to "720P" (a target of approximately 920,000 total pixels) produces an output of 816×1104 (aspect ratio ≈ 0.739, approximately 900,000 total pixels).
- For example, an input image of 750×1000 (aspect ratio 3:4 = 0.75) with
-
Recommendations:
- 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.