The Wan2.7-I2V model has been fully upgraded to support multimodal input (text/image/audio/video) and can perform three major tasks: first-frame-to-video, first-and-last-frame-to-video, and video continuation.
Related documents: User Guide
To ensure successful calls, make sure that the model, endpoint URL, and API Key all belong to the same region. Cross-region calls will fail.
I2V tasks take a long time to complete (usually 1 to 5 minutes), so the API uses asynchronous calls. The entire process consists of two core steps: "Create a task -> poll for the result", as follows:
When calling the API, replace
When calling the API, replace
The SDK parameter naming is basically consistent with the HTTP API, and the parameter structure is encapsulated according to language characteristics.
Since I2V tasks take a long time (usually 1-5 minutes), the SDK encapsulates the HTTP asynchronous call process at the underlying layer, supporting both synchronous and asynchronous calls.
Because image-to-video tasks take a long time (typically 1 to 5 minutes), the SDK encapsulates the HTTP asynchronous invocation process at the underlying layer and supports both synchronous and asynchronous invocation methods.
Set
When calling the API, replace
Set
When calling the API, replace
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 input material (first frame image or first video clip), but it cannot be guaranteed to strictly equal the input ratio (for example, an exact 3:4). The actual output may have a slight deviation.
The following uses "inputting a first frame image" as an example to explain the specific logic:
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 expired information from affecting access, this document 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 I2V API (wan2.7 model) supports the three tasks above and is recommended as the preferred option.The legacy I2V based on the first frame (wan2.6 and earlier models) only supports first-frame video generation.
Scope
To ensure successful calls, make sure that the model, endpoint URL, and API Key all 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 that region, and then configure the API Key in environment variables.
- Install SDK: To make calls through an SDK, please install the DashScope SDK.
The sample code in this topic applies to the Beijing region.
HTTP calls
I2V tasks take a long time to complete (usually 1 to 5 minutes), so the API uses asynchronous calls. The entire process consists of two core steps: "Create a task -> poll for the result", as follows:
Step 1: Create a task and obtain the task ID
- Beijing
- Singapore
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. The task_id is valid for 24 hours. Do not create duplicate tasks; just poll for the result. - For a beginner's guide, see Postman.
Request parametersContent-Typestring(Required)The request content type. This parameter must be set to application/json.Authorizationstring(Required)Request authentication. The API uses an Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.X-DashScope-Asyncstring (Required)Asynchronous processing configuration parameter. HTTP requests only support asynchronous mode, and it must be set to enable.Request Bodymodelstring (Required)The model name. For the model list and prices, see Model Price.Example value: wan2.7-i2v-2026-04-25.input object (Required)Basic input information, such as the prompt.
Property prompt string (Optional)The text prompt, used to describe the elements and visual features you expect in the generated video.Supports both Chinese and English, with a maximum length of 5,000 characters. Each Chinese character or letter counts as one character, and any excess is automatically truncated.Example value: A little cat running on the grass.For tips on writing prompts, see T2V/I2V Prompt Guide.negative_prompt string (Optional)The negative prompt, used to describe content you do not want to see in the video. It can be used to constrain the video output.Supports both Chinese and English, with a maximum length of 500 characters, and any excess is automatically truncated.Example value: low resolution, error, worst quality, low quality, incomplete, extra fingers, bad proportions, etc.media array (Required)A list of media assets, used to specify the reference materials (images, audio, and videos) required for video generation.Each element of the array is a media object that contains the type and url fields.
Media asset combinations Only the following specific media asset combinations are supported. Invalid combinations will cause an error.
Property type string (Required)The media asset type. Valid values:
type can appear at most once in the media array (for example: you cannot pass in two first_frame values at the same time).url string (Required)URL of the media assets. Assets include images, audio, and videos.
The URL of the media asset. Assets include images, audio, and video. Pass an image (type=first_frame or last_frame)The URL of the first or last frame, or Base64-encoded data. Video generation from the first frame and from the first and last frames are currently supported.
image/webp Pass audio (type=driving_audio)The URL of the audio file.
Input video (type=first_clip) The URL of the video file. The model generates a continuation based on the video content, and the upper limit of the continuation duration is controlled by the duration parameter.For example: when duration=15, with a 3-second input video, the model generates a 12-second continuation, and the final output video has a total duration of 15 seconds, billed at 15 seconds. For example, when duration=15, if the input video is 3 seconds, the model generates a 12-second continuation, and the final output video is 15 seconds in total and billed as 15 seconds.
object (Optional)Video processing parameters, such as setting the video resolution, setting the video duration, enabling prompt intelligent rewriting, adding a watermark, and more.
Property resolution string (Optional)Specifies the resolution tier of the generated video, which controls 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 should be kept consistent with the input asset (first frame or first video segment) whenever possible. For more information, see FAQ.Optional values:Valid values:duration integer (Optional)The duration of the generated video, in seconds.The value is an integer between [2, 15]. The default value is 5.prompt_extendboolean (optional)Whether to enable intelligent prompt rewriting. When enabled, a large model is used to intelligently rewrite the input prompt. This significantly improves generation results for short prompts, but increases processing time.
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)The random seed, in the range [0, 2147483647].If not specified, the system automatically generates a random seed. To improve the reproducibility of generation results, it is recommended to use a fixed seed value.If not specified, the system automatically generates a random seed. To improve the reproducibility of the results, we recommend that you fix the seed value. |
Video generation from the first frame |
Response parametersoutputobjectTask output information.
Property task_id stringTask ID. The query is valid for 24 hours.task_status stringTask status.
The task status. Enumeration values stringThe unique request identifier. It can be used for request tracing and troubleshooting.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error message returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes. |
Successful response |
Step 2: Query the result by task ID
- Beijing
- Singapore
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. It is recommended to use a polling mechanism with a reasonable query interval (such as 15 seconds) to obtain results.
- Task status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- Result link: The video URL is returned after the task succeeds, valid for 24 hours. It is recommended to download it immediately and store it in permanent storage (such as Alibaba Cloud OSS).
- task_id validity: 24 hours. After expiration, results can no longer be queried, and the API returns a task status of
UNKNOWN. - RPS limits: The query API has a default RPS of 20. For higher-frequency queries or event notifications, see Configure asynchronous task callbacks.
- More operations: For batch queries, task cancellation, and other operations, see Manage asynchronous tasks.
Request parametersHeadersAuthorizationstring(Required)Request authentication. The API uses an Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.Path parameterstask_idstring(required)Task ID. |
Replace {task_id} entirely with the value of task_id returned by the API in the previous step. The task_id query is valid for 24 hours. Replace {WorkspaceId} with the actual workspace ID. |
Response parametersoutputobjectTask output information.
Property task_id stringTask ID. The query is valid for 24 hours.task_status stringTask status.
The task status. Enumeration values
stringTask submission time. The format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringTask execution time. The format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringTask completion time. The format is YYYY-MM-DD HH:mm:ss.SSS.video_urlstringVideo URL. Returned only when task_status is SUCCEEDED.The video URL. Returned only when task_status is SUCCEEDED.orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error message returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.objectOutput information statistics, counted only for successful results.
Property input_video_duration integerThe duration of the input video, in seconds.output_video_duration integerThe duration of the output video, in seconds.duration integerThe total video duration, used for billing.SR integerThe resolution tier of the output video. Example value: 720.video_count integerThe number of output videos. Fixed at 1.stringThe unique request identifier. It can be used for request tracing and troubleshooting. |
Task succeeded |
DashScope SDK calls
The SDK parameter naming is basically consistent with the HTTP API, and the parameter structure is encapsulated according to language characteristics.
Since I2V tasks take a long time (usually 1-5 minutes), the SDK encapsulates the HTTP asynchronous call process at the underlying layer, supporting both synchronous and asynchronous calls.
Because image-to-video tasks take a long time (typically 1 to 5 minutes), the SDK encapsulates the HTTP asynchronous invocation process at the underlying layer and supports both synchronous and asynchronous invocation methods.
Python SDK calls
Set region according to the region where the model is located (passed in when constructing the Client; the region value varies by region):
- Beijing
- Singapore
region="cn-beijing"{WorkspaceId} with your actual workspace ID.
- Synchronous call
- > The video_url is valid for 24 hours. Download the video in a timely manner.
Request example
Response example
video_url is valid for 24 hours. Download the video in a timely manner.
Java SDK calls
Set Constants.baseHttpApiUrl based on the region where the model is located:
- Beijing
- Singapore
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"{WorkspaceId} with your actual workspace ID.
- Synchronous call
- > The video_url is valid for 24 hours. Download the video in a timely manner.
Synchronous call
Request example
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 input material (first frame image or first video clip), but it cannot be guaranteed to strictly equal the input ratio (for example, an exact 3:4). The actual output may have a slight deviation.
The following uses "inputting a first frame image" as an example to explain the specific logic:
-
Why is there a deviation?
- Execution logic: The input image's ratio is used as the baseline ratio reference. Combined with the target total pixels of the
resolutiontier and the requirement that video width and height must be multiples of 16 (video encoding specification), the system automatically fine-tunes the output to the nearest valid resolution. - Calculation example: Input a first frame image of 750×1000 (aspect ratio 3:4 = 0.75) and set resolution = "720P" (target total pixels of approximately 920,000). The actual output video resolution is 816×1104 (aspect ratio ≈ 0.739, total pixels of approximately 900,000).
- Execution logic: The input image's ratio is used as the baseline ratio reference. Combined with the target total pixels of the
-
Best practices:
- Input control: Use a first frame image or first video clip that matches the target ratio as the input whenever possible.
- Post-processing: If you have strict requirements on the ratio, after the video is generated, use an editing tool to perform simple cropping or black-bar padding.