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
NoteThe 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.
NoteThe sample code in this topic applies to the Singapore region.
ImportantAlibaba Cloud Model Studio provides workspace-specific domains for the China (Beijing) and Singapore regions. These domains deliver superior performance and higher stability for inference requests. We recommend that you migrate to the new domains:
- China (Beijing) region: migrate from
https://dashscope.aliyuncs.comtohttps://{WorkspaceId}.cn-beijing.maas.aliyuncs.com - Singapore region: migrate from
https://dashscope-intl.aliyuncs.comtohttps://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
{WorkspaceId} specifies your workspace ID, which you can view on the Workspace Details page in the Alibaba Cloud Model Studio console. The existing domains remain available.
HTTP calls
ImportantThis API uses the new I2V protocol and supports only the wan2.7 model.
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
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Beijing
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
When you call the API, replace {WorkspaceId} with your actual workspace ID.
Note
- 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-Type The request content type. You must set this parameter to Authorization Request authentication. This API uses the Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx. X-DashScope-Async Asynchronous processing configuration parameter. HTTP requests only support asynchronous calls, and this parameter must be set to ImportantIf this request header is missing, the following error is returned: "current user api does not support synchronous calls". Request Bodymodel Model name. For the model list and prices, see Model pricing. Example value: wan2.7-i2v-2026-04-25. input The basic input information, such as the prompt. parameters Video processing parameters, such as setting the video resolution, setting the video duration, enabling intelligent prompt rewriting, and adding a watermark. | First frame to videoGenerate a video based on a first frame image and audio. First and last frame to videoGenerate a video by providing the first frame and last frame. Video continuationBased on the first video segment, the model generates the subsequent content. |
Response parametersoutput Task output information. request_id The unique request identifier. It can be used for tracing request details and troubleshooting. code The error code returned when the request fails. This parameter is not returned when the request succeeds. For more information, see Error codes. message The detailed error information returned when the request fails. This parameter is not returned when the request succeeds. For more information, see Error codes. | Success responseSave the task_id for querying the task status and result. Error responseTask creation failed. For troubleshooting, see Error codes. |
Step 2: Query the result by task ID
Singapore
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Beijing
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
When you call the API, replace {WorkspaceId} with your actual workspace ID.
Note
- 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 headersAuthorization Request authentication. This API uses the Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx. URL path parameterstask_id The task ID. | Query the task resultReplace |
Response parametersoutput Task output information. usage Output information statistics, counted only for successful results. request_id The unique request identifier. It can be used for tracing request details and troubleshooting. | Task executed successfullyThe video URL is retained for only 24 hours and will be automatically deleted after it expires. Save the generated video in a timely manner. Task execution failedIf the task fails, task_status will be set to FAILED, and an error code and message will be provided. See error codes for troubleshooting. Task query expiredtask_id can be queried within 24 hours. After that, queries are no longer available and the following error message is returned. |
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
ImportantMake sure the DashScope Python SDK version is no earlier than 2.0.1 before running the following code.
If the version is too old, errors such as "url error, please check url!" may occur. Refer to Install SDK to update it.
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
region="ap-southeast-1"
Beijing
region="cn-beijing"
When you call the API, replace {WorkspaceId} with your actual workspace ID.
Synchronous Call
Request example
# -*- coding: utf-8 -*-
import dashscope
import os
from dashscope import DashScopeError
# The following configuration is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. The region value varies by region.
client = dashscope.Client(
# If the environment variable is not configured, set your Model Studio API key directly: api_key="sk-xxx"
# API keys are region-specific. To get an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="ap-southeast-1",
)
media = [
{
"type": "first_frame",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
},
{
"type": "driving_audio",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
}
]
def sample_sync_call():
print('----sync call, please wait a moment----')
# generate is a one-step call (submit the task and wait for completion) and returns a completed Job
# prompt_extend: in 1.x, prompt smart rewriting is enabled by default; in 2.0 it is decided by the server by default. It is explicitly enabled here to keep the behavior consistent
try:
job = client.videos.generate(
model="wan2.7-i2v-2026-04-25",
media=media,
resolution="720P",
duration=10,
watermark=True,
prompt="一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由rap构成,没有其他对话或杂音。",
prompt_extend=True,
)
print(job)
print(job.video_url)
except DashScopeError as e:
print(f"HTTP status code: {e.status_code}")
print(f"Error code: {e.code}")
print(f"Error message: {e.message}")
print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")
if __name__ == '__main__':
sample_sync_call()
Response example
The video_url is valid for 24 hours. Download the video in a timely manner.
{
"request_id": "ac5faf37-ddfa-9720-a0c5-xxxxxx",
"task_id": "b97c6d86-ad73-4bb7-80ff-xxxxxx",
"status": "SUCCEEDED",
"video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
"task_metrics": {
"TOTAL": 1,
"SUCCEEDED": 1,
"FAILED": 0
},
"usage": {
"video_count": 1,
"duration": 10,
"input_video_duration": 0,
"output_video_duration": 10,
"SR": 720
}
}
Asynchronous Call
Request example
# -*- coding: utf-8 -*-
import dashscope
import os
from dashscope import DashScopeError
# The following configuration is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. The region value varies by region.
client = dashscope.Client(
# If the environment variable is not configured, set your Model Studio API key directly: api_key="sk-xxx"
# API keys are region-specific. To get an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="ap-southeast-1",
)
media = [
{
"type": "first_frame",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
},
{
"type": "driving_audio",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
}
]
def sample_async_call():
# Submit the asynchronous task and return the task information immediately
# prompt_extend: in 1.x, prompt smart rewriting is enabled by default; in 2.0 it is decided by the server by default. It is explicitly enabled here to keep the behavior consistent
try:
job = client.videos.jobs.create(
model="wan2.7-i2v-2026-04-25",
media=media,
resolution="720P",
duration=10,
watermark=True,
prompt="一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由rap构成,没有其他对话或杂音。",
prompt_extend=True,
)
print(job)
print("task_id: %s" % job.task_id)
except DashScopeError as e:
print(f"HTTP status code: {e.status_code}")
print(f"Error code: {e.code}")
print(f"Error message: {e.message}")
print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")
return
# Query the task status
try:
snapshot = client.videos.jobs.fetch(job.task_id)
print(snapshot.status)
except DashScopeError as e:
print(f"HTTP status code: {e.status_code}")
print(f"Error code: {e.code}")
print(f"Error message: {e.message}")
print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")
# Wait for the task to complete (exponential backoff polling, default total budget of 24 hours)
try:
done = client.videos.jobs.wait(job)
print(done)
print(done.video_url)
except DashScopeError as e:
print(f"HTTP status code: {e.status_code}")
print(f"Error code: {e.code}")
print(f"Error message: {e.message}")
print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")
if __name__ == '__main__':
sample_async_call()
Response example
- Response example of creating a task
{
"request_id": "6dc3bf6c-be18-9268-9c27-xxxxxx",
"task_id": "686391d9-7ecf-4290-a8e9-xxxxxx",
"status": "PENDING"
}
- Response example of querying the task result
The video_url is valid for 24 hours. Download the video in a timely manner.
{
"request_id": "ac5faf37-ddfa-9720-a0c5-xxxxxx",
"task_id": "b97c6d86-ad73-4bb7-80ff-xxxxxx",
"status": "SUCCEEDED",
"video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
"task_metrics": {
"TOTAL": 1,
"SUCCEEDED": 1,
"FAILED": 0
},
"usage": {
"video_count": 1,
"duration": 10,
"input_video_duration": 0,
"output_video_duration": 10,
"SR": 720
}
}
Java SDK calls
ImportantMake sure the DashScope Java SDK version is no earlier than 2.22.14 before running the following code.
If the version is too old, errors such as "url error, please check url!" may occur. Refer to Install SDK to update it.
Set Constants.baseHttpApiUrl based on the region where the model is located:
Singapore
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1"
Beijing
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"
When you call the API, replace {WorkspaceId} with your actual workspace ID.
Synchronous Call
A synchronous call blocks and waits until video generation is complete and the result is returned.
Request example
Asynchronous Call
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.
Q: How do I obtain the access domain whitelist for video storage?
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.