The Wanx-I2V model generates a smooth video based on the first frame image and a text prompt.
Related documents: User Guide
To ensure successful calls, make sure that the model, endpoint URL, and API Key belong to the same region. Cross-region calls will fail.
I2V tasks are time-consuming (usually 1 to 5 minutes), so the API uses asynchronous calls. The entire process consists of two core steps: "Create a task -> poll for results", as follows:
When you call the API, replace
When you call the API, replace
The SDK parameter naming is basically the same as that of the HTTP API, and the parameter structure is encapsulated according to the characteristics of each language.
Since image-to-video tasks are time-consuming (usually 1-5 minutes), the SDK encapsulates the HTTP asynchronous invocation process at the underlying layer, supporting both synchronous and asynchronous invocation methods.
Set
When you call the API, replace
Set
When you call the API, replace
When using wan2.6-i2v-flash to generate animations of circular objects rotating continuously (such as rings, gears, or dials), the video may briefly stutter after about 3 seconds (the image freezes for about 1 second). To generate such continuous rotation effects, we recommend using the Wan2.7-I2V model to avoid this issue.
If a model call fails and returns an error message, see Error codes to resolve the issue.
A: The aspect ratio of the output video is determined by the first frame image (img_url) you provide, but the exact ratio cannot be guaranteed (for example, a strict 3:4), so some deviation may exist.
A: Videos generated by the model are stored in Alibaba Cloud OSS, and the API returns a temporary public URL. If you need to configure a firewall whitelist for this download URL, note that the underlying storage changes dynamically based on business conditions. To prevent outdated information from affecting access, this documentation does not provide a fixed OSS domain whitelist. If you have security control requirements, contact your account manager to obtain the latest list of OSS domains.
The newly launched Wanx2.7-I2V supports three major tasks: first-frame video generation, first-and-last-frame video generation, and video extension. We recommend that you prioritize it.The I2V First Frame (wan2.6 and earlier models) described in this document supports only first-frame video generation.
Scope
To ensure successful calls, make sure that the model, endpoint URL, and API Key belong to the same region. Cross-region calls will fail.
- Select Model: Confirm the region of the model.
- Select URL: Select the Endpoint URL of the corresponding region. HTTP URLs and DashScope SDK URLs are supported.
- Configure API Key: Obtain the API Key of the region, and then configure the API Key as an environment variable.
- Install SDK: To call the API through an SDK, install the DashScope SDK.
The sample code in this document applies to the Singapore region.
HTTP calls
I2V tasks are time-consuming (usually 1 to 5 minutes), so the API uses asynchronous calls. The entire process consists of two core steps: "Create a task -> poll for results", as follows:
Step 1: Create a task to obtain the task ID
- 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
task_idreturned by the API to query the result. The task_id is valid for 24 hours. Do not create the task repeatedly; poll for the result instead. - For a quick start guide, see Postman.
Request parametersRequest headersContent-Typestring(required)The request content type. This parameter must be set to application/json.Authorizationstring(required)Request authentication. The API uses the Alibaba Cloud Bailian API Key for authentication. Example value: Bearer sk-xxxx.X-DashScope-Asyncstring (Required)Asynchronous processing configuration parameter. HTTP requests only support asynchronous calls, and it must be set toenable.Request Bodymodelstring (Required)Model name. For the model list and prices, see Model Price.Example value: wan2.6-i2v-flash.input object (Required)Basic input information, such as the prompt.
Property prompt string (Optional)Text prompt. Used to describe the elements and visual features expected in the generated image.Supports Chinese and English. Each Chinese character or letter counts as one character, and any excess is automatically truncated. The length limit varies by model version:
string (Optional)Negative prompt, used to describe content you do not want to see in the video, which can constrain the video output.Supports Chinese and English, with a length of no more than 500 characters; any excess is automatically truncated.Example value: low resolution, error, worst quality, low quality, incomplete, extra fingers, bad proportions, etc.img_url string (Required)The URL or Base64-encoded data of the first frame image.Image limits:
string (optional)Supported models: wan2.6 and wan2.5 series models.The URL of the audio file. The model will use this audio to generate the video.Supported input formats:
object (optional)Video processing parameters, such as setting the video resolution, setting the video duration, enabling intelligent prompt rewriting, adding a watermark, and more.
Property 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 try to stay consistent with the aspect ratio of the input image img_url. 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 intelligent prompt rewriting. When enabled, a large language model is used to intelligently rewrite the input prompt. It significantly improves the generation results for short prompts, but increases the processing time.
string (optional)Supported models: wan2.6 series models.Specifies the shot type of the generated video, that is, whether the video consists of one continuous shot or multiple switching shots.Effective condition: Only effective 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 still outputs a single-shot video.Valid values:
When you want to strictly control the narrative structure of the video (for example, single-shot for product showcases, multi-shot for story short films), you can specify it through this parameter. boolean (optional)Supported models: wan2.6-i2v-flash.Whether to generate a video with audio.Parameter priority: audio > audio_url. When audio=false, even if audio_url is passed in, the output is still a silent video, and billing is based on silent videos.Valid values:
boolean (optional)Whether to add a watermark. The watermark is located in the lower-right corner of the video, with fixed text "AI-generated".
integer(optional)Random number seed, with a value range of [0, 2147483647].If not specified, the system automatically generates a random seed. To improve the reproducibility of generation results, it is recommended to fix the seed value.Note that model generation is probabilistic, so even with the same seed, the generation results are not guaranteed to be identical each time.Example value: 12345. |
Only wan2.6 series models support this feature.Can be enabled by setting "prompt_extend": true and "shot_type":"multi". |
Response parametersoutputobjectTask output information.
Property task_id stringTask ID. The query validity period is 24 hours.task_status stringTask status.
Enumerated values
stringThe unique identifier of the request. It can be used for request detail tracing and troubleshooting.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For more information, see Error codes.messagestringThe detailed error information returned when the request fails. This parameter is not returned when the request succeeds. For more information, see Error codes. |
Save the task_id for querying the task status and results. |
Step 2: Query the results by task ID
- Singapore
- Virginia
- 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. We recommend that you use the polling mechanism and set a reasonable query interval (for example, 15 seconds) to obtain the results.
- Task status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failure).
- Result link: After the task succeeds, a video link is returned, which is valid for 24 hours. We recommend that you download the video immediately after obtaining the link and transfer it to permanent storage (such as Alibaba Cloud OSS).
- task_id validity: 24 hours. After the validity period expires, the results cannot be queried, and the API returns the task status
UNKNOWN.
Request parametersRequest headersAuthorizationstring(required)Request authentication. The API uses the Alibaba Cloud Bailian API Key for authentication. Example value: Bearer sk-xxxx.URL path parameterstask_idstring (Required)Task ID. |
Replace {task_id} with the value of task_id returned by the API in the previous step. The task_id query validity period is 24 hours. Replace {WorkspaceId} with your actual Workspace ID. |
Response parametersoutputobjectTask output information.
Property task_id stringTask ID. The query validity period is 24 hours.task_status stringTask status.
Enumerated values
stringThe time when the task was submitted. The time zone is UTC+8, and the format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe task execution time. The time zone is UTC+8, and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. The time zone is UTC+8, and the format is YYYY-MM-DD HH:mm:ss.SSS.video_urlstringThe video URL. Returned only when task_status is SUCCEEDED.The link is valid for 24 hours, and you can download the video via this URL. The video format is MP4 (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.
stringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For more information, see Error codes.messagestringThe detailed error information returned when the request fails. This parameter is not returned when the request succeeds. For more information, see Error codes.objectOutput information statistics, counting only successful results.
Property
Parameters returned by wan2.6 series models input_video_duration integerThe duration of the input video, in seconds. Currently, passing in videos is not supported, so this value is fixed to 0.output_video_duration integerReturned only when wan2.6 models are used.The duration of the output video, in seconds. Its value is equal to the value of input.duration.duration integerThe total video duration, used for billing.Billing formula: duration=input_video_duration+output_video_duration.SR integerReturned only when wan2.6 models are used. The resolution tier of the generated video. Example value: 720.video_count integerThe number of generated videos. Fixed to 1.audiobooleanReturned only when the wan2.6-i2v-flash model is used. Indicates whether the output video contains audio.
Parameters returned by wan2.2 and wan2.5 series models duration integerThe duration of the generated video, in seconds. Enumerated values: 5 and 10.Billing formula: Fee = Video duration in seconds × unit price.SR integerThe resolution of the generated video. Enumerated values: 480, 720, and 1080.video_count integerThe number of generated videos. Fixed to 1.
Parameters returned by wan2.1 series models video_duration integerThe duration of the generated video, in seconds. Enumerated values: 3, 4, and 5.Billing formula: Fee = Video duration in seconds × unit price.video_ratio stringThe ratio of the generated video. Fixed to standard.video_count integerThe number of generated videos. Fixed to 1.stringThe unique identifier of the request. It can be used for request detail tracing and troubleshooting. |
The video URL is retained for only 24 hours and is automatically cleared after it expires. Save the generated video in a timely manner. |
Invoking the DashScope SDK
The SDK parameter naming is basically the same as that of the HTTP API, and the parameter structure is encapsulated according to the characteristics of each language.
Since image-to-video tasks are time-consuming (usually 1-5 minutes), the SDK encapsulates the HTTP asynchronous invocation process at the underlying layer, supporting both synchronous and asynchronous invocation methods.
The actual processing time depends on the number of queued tasks and service execution status. Please wait patiently while retrieving the result.
Python SDK calls
Set region based on the region where the model is located (pass it in when constructing the Client; the region value varies by region):
- Singapore
- Virginia
- Beijing
- Frankfurt
region="ap-southeast-1"{WorkspaceId} with your actual workspace ID.
Sample Code
- Synchronous Call
- Asynchronous Call
A synchronous call blocks and waits until video generation is completed and the result is returned. 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 promptly.
Java SDK calls
Set baseHttpApiUrl based on the region where the model is located:
- 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 and waits until video generation is completed and the result is returned. 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 promptly.
Limits
- Data validity: The task task_id and video URL are retained for only 24 hours and cannot be queried or downloaded after they expire.
- Content moderation: Input content (such as prompts and images) and output videos are subject to content safety review. Content containing violations will return the "IPInfringementSuspect" or "DataInspectionFailed" error. For more information, see Error codes.
Known Limitations
When using wan2.6-i2v-flash to generate animations of circular objects rotating continuously (such as rings, gears, or dials), the video may briefly stutter after about 3 seconds (the image freezes for about 1 second). To generate such continuous rotation effects, we recommend using the Wan2.7-I2V model to avoid this issue.
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 aspect ratio of the output video is determined by the first frame image (img_url) you provide, but the exact ratio cannot be guaranteed (for example, a strict 3:4), so some deviation may exist.
-
Why does the deviation 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 strictly equal to 3:4, but it will be very close.
- For example: with an input image of 750×1000 (aspect ratio 3:4 = 0.75) and resolution = "720P" (target total pixels of about 920,000), the actual output is 816×1104 (aspect ratio ≈ 0.739, about 900,000 total pixels).
-
Best practices:
- Input control: Use an image that matches the target ratio as the first frame input whenever possible.
- Post-processing: If you have strict ratio requirements, we recommend using an editing tool after the video is generated to perform simple cropping or black-bar padding.