The Wan2.7-I2V model is fully upgraded. It supports multimodal input (text/image/audio/video) and can complete 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 belong to the same region. Cross-region calls will fail.
I2V tasks take a long time to complete (typically 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 you call the API, replace
When you call the API, replace
The SDK parameter naming is basically consistent with the HTTP API, and the parameter structure is encapsulated based on language characteristics.
I2V tasks take a long time (usually 1 to 5 minutes), so the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous calls.
Set
When you call the API, replace
Set
When you call the API, replace
If the 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 be strictly equal to the input ratio (for example, exactly 3:4). The actual output may have slight deviations.
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 firewall whitelist rules for this download URL, note that because the underlying storage changes dynamically based on business conditions, this document does not provide a fixed OSS domain whitelist to prevent expired information from affecting access. If you have security control requirements, contact your account manager to obtain the latest OSS domain list.
The newly launched I2V API (wan2.7 model) supports the preceding three tasks and is recommended as the first choice.The original I2V based on first frame (wan2.6 and earlier models) only supports first-frame-to-video.
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 to which the model belongs.
- Select URL: Select the endpoint URL of the corresponding region. Both 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 make calls by using an SDK, install the DashScope SDK.
The sample code in this topic applies to the Singapore region.
HTTP calls
I2V tasks take a long time to complete (typically 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 to obtain the task ID
- Singapore
- Beijing
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 duplicate tasks. Poll for the result instead. - For getting started, see Postman.
Request parametersContent-Typestring(required)The request content type. You must set this parameter to application/json.Authorizationstring(required)Request authentication. This API uses the 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 calls, and this parameter must be set to enable.Request Bodymodelstring (Required)Model name. For the model list and prices, see Model pricing.Example value: wan2.7-i2v-2026-04-25.input object (Required)The basic input information, such as the prompt.
Properties prompt string (Optional)The text prompt. It describes the elements and visual features that you want to include in the generated video.Both Chinese and English are supported, 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 kitten running on the grass.For tips on how to use prompts, see T2V/I2V prompt guide.negative_prompt string (Optional)The negative prompt, which describes the content that you do not want to see in the video frames and can be used to constrain the video output.Both Chinese and English are supported, with a maximum length of 500 characters; any excess is automatically truncated.Example value: low resolution, fault, worst quality, low quality, mutilated, extra fingers, bad proportions, etc.media array (Required)The 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 return an error.
Properties 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 at the same time).url string (Required)The URL of the media asset. Assets include images, audio, and videos.
Input image (type=first_frame or last_frame) The URL of the first frame or last frame, or Base64-encoded data. Currently, first-frame-to-video and first-and-last-frame-to-video are supported.Image limits:
Input audio (type=driving_audio) The URL of the audio file.
Input video (type=first_clip) The URL of the video file. The model continues generating video content based on the input video, and the upper limit of the continuation duration is controlled by the duration parameter.For example, when duration=15, if the input video is 3 seconds, the model generates a 12-second continuation, and the final output video has a total duration of 15 seconds, billed at 15 seconds.Video limits:
object (Optional)Video processing parameters, such as setting the video resolution, setting the video duration, enabling intelligent prompt rewriting, and adding a watermark.
Properties resolution string (Optional)The resolution tier of the generated video, used to control 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.Valid values:
integer (Optional)The duration of the generated video, in seconds.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 the generation results for short prompts but increases the 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 of [0, 2147483647].If not specified, the system automatically generates a random seed. To improve the reproducibility of generation results, we recommend fixing the seed value.Note that model generation is probabilistic. Even with the same seed, identical generation results cannot be guaranteed. |
Generate a video based on a first frame image and audio. |
Response parametersoutputobjectTask output information.
Properties task_id stringTask ID. The validity period for queries is 24 hours.task_status stringTask status.
Enumerated value
stringThe unique request identifier. It can be used for tracing request details 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 result. |
Step 2: Query the result by task ID
- Singapore
- Beijing
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}{WorkspaceId} with your actual workspace ID.
- Polling recommendations: Video generation takes several minutes. We recommend using a polling mechanism with a reasonable query interval (such as 15 seconds) to obtain the result.
- Task status transition: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- Result link: After the task succeeds, a video link is returned, valid for 24 hours. We recommend downloading the video immediately after obtaining the link and storing it in 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 the task status as
UNKNOWN.
Request parametersRequest headersAuthorizationstring(required)Request authentication. This API uses the Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.URL path parameterstask_idstring (Required)The task ID. |
Replace {task_id} entirely with the task_id value returned by the API in the previous step. The task_id is valid for queries for 24 hours. Also replace {WorkspaceId} with your actual Workspace ID. |
Response parametersoutputobjectTask output information.
Properties task_id stringTask ID. The validity period for queries is 24 hours.task_status stringTask status.
Enumerated value
stringThe task submission time. The time zone is UTC+8, in the format YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe task execution time. The time zone is UTC+8, in the format YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe task completion time. The time zone is UTC+8, in the format 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.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.objectOutput information statistics, counted only for successful results.
Properties input_video_duration integerThe duration of the input video, in seconds.output_video_duration integerThe duration of the output video, in seconds.duration integerTotal video duration, used for billing.SR integerThe resolution tier of the output video. Example value: 720.video_count integerThe number of output videos. Fixed to 1.stringThe unique request identifier. It can be used for tracing request details and troubleshooting. |
The video URL is retained for only 24 hours and will be automatically deleted after it expires. Save the generated video in a timely manner. |
DashScope SDK calls
The SDK parameter naming is basically consistent with the HTTP API, and the parameter structure is encapsulated based on language characteristics.
I2V tasks take a long time (usually 1 to 5 minutes), so the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous calls.
The actual time required depends on the number of queued tasks and service execution status. Please be patient when retrieving results.
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
- Beijing
region="ap-southeast-1"{WorkspaceId} with your actual workspace ID.
- Synchronous Call
- Asynchronous Call
Request example
Response example
The 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:
- Singapore
- Beijing
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1"{WorkspaceId} with your actual workspace ID.
- Synchronous Call
- Asynchronous Call
A synchronous call blocks and waits until video generation is complete and the result is returned.
Request example
Error codes
If the 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 be strictly equal to the input ratio (for example, exactly 3:4). The actual output may have slight deviations.
The following uses "inputting a first frame image" as an example to explain the specific logic:
-
Why is there a deviation?
- Execution logic: The system uses the input image ratio as the baseline ratio reference, combines it with the target total pixels of the
resolutiontier, and the video width and height must be multiples of 16 (video encoding specification), so the system automatically fine-tunes 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 system uses the input image ratio as the baseline ratio reference, combines it with the target total pixels of the
-
Best practices:
- Input control: Use a first frame or first video clip that matches the target ratio as the input whenever possible.
- Post-processing: If you have strict ratio requirements, after the video is generated, use an editing tool to perform simple cropping or black-bar padding.