The Wanx-I2V model generates a smooth video based on the first frame image and a text prompt.
Related documents: User Guide
NoteThe 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.
NoteThe sample code in this document applies to the Singapore region.
ImportantAlibaba Cloud Model Studio provides workspace-dedicated domains for the North China 2 (Beijing) and Singapore regions, which deliver superior performance and higher stability for inference requests. We recommend that you migrate to the new domains:
- North China 2 (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} is 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
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
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Virginia
POST https://{WorkspaceId}.us-east-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
Frankfurt
POST https://{WorkspaceId}.eu-central-1.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 the task repeatedly; poll for the result instead. - For a quick start guide, see Postman.
Request parametersRequest headersContent-Type The request content type. This parameter must be set to Authorization Request authentication. The API uses the Alibaba Cloud Bailian API Key for authentication. Example value: Bearer sk-xxxx. X-DashScope-Async Asynchronous processing configuration parameter. HTTP requests only support asynchronous calls, and it must be set to ImportantIf this request header is missing, an error will be reported: "current user api does not support synchronous calls". Request Bodymodel Model name. For the model list and prices, see Model Price. Example value: wan2.6-i2v-flash. input 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, adding a watermark, and more. | Multi-shot narrativeOnly wan2.6 series models support this feature. Can be enabled by setting Automatic dubbingOnly wan2.6 and wan2.5 series models support this feature. If Pass in an audio fileOnly wan2.6 and wan2.5 series models support this feature. To specify background music or dubbing for a video, you can pass in the URL of a custom audio file through the Generate a silent videoOnly the following models support generating silent videos:
Use negative promptsUse negative_prompt to specify that the generated video should avoid the "flower" element. |
Response parametersoutput Task output information. request_id The unique identifier of the request. It can be used for request detail tracing 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. | Successful responseSave the task_id for querying the task status and results. Error responseFailed to create the task. See Error codes for troubleshooting. |
Step 2: Query the results by task ID
Singapore
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Virginia
GET https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
Beijing
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
Frankfurt
GET https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
When you call the API, replace {WorkspaceId} with your actual workspace ID.
Note
- 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 headersAuthorization Request authentication. The API uses the Alibaba Cloud Bailian API Key for authentication. Example value: Bearer sk-xxxx. URL path parameterstask_id Task ID. | Query task resultsReplace |
Response parametersoutput Task output information. usage Output information statistics, counting only successful results. request_id The unique identifier of the request. It can be used for request detail tracing and troubleshooting. | Task executed successfullyThe video URL is retained for only 24 hours and is automatically cleared after it expires. Save the generated video in a timely manner. Task execution failedIf the task execution fails, task_status is set to FAILED, and an error code and message are 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. |
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
ImportantEnsure that your 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. Please 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"
Virginia
region="us-east-1"
Beijing
region="cn-beijing"
Frankfurt
region="eu-central-1"
When you call the API, replace {WorkspaceId} with your actual workspace ID.
Sample Code
Synchronous 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
import base64
import os
import mimetypes
import dashscope
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.
# For the endpoints of each region, see https://www.alibabacloud.com/help/model-studio/image-to-video-api-reference
client = dashscope.Client(
# If the environment variable is not configured, set your Model Studio API key directly: api_key="sk-xxx"
# 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",
)
# --- Helper function for Base64 encoding ---
# The format is data:{MIME_type};base64,{base64_data}
def encode_file(file_path):
mime_type, _ = mimetypes.guess_type(file_path)
if not mime_type or not mime_type.startswith("image/"):
raise ValueError("不支持或无法识别的图像格式")
with open(file_path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
return f"data:{mime_type};base64,{encoded_string}"
"""
图像输入方式说明:
以下提供了三种图片输入方式,
1. 使用公网URL - 适合已有公开可访问的图片
2. 使用本地文件 - 适合本地开发测试
3. 使用Base64编码 - 适合私有图片或需要加密传输的场景
"""
# [Method 1] Use a publicly accessible image URL
# Example: Use a public image URL
img_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
# [Method 2] Use a local file (supports absolute and relative paths)
# Format: file:// + file path
# Example (absolute path):
# img_url = "file://" + "/path/to/your/img.png" # Linux/macOS
# img_url = "file://" + "/C:/path/to/your/img.png" # Windows
# Example (relative path):
# img_url = "file://" + "./img.png" # Relative to the current script's directory
# [Method 3] Use a Base64-encoded image
# img_url = encode_file("./img.png")
# Set the audio url
audio_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
def sample_call_i2v():
print('please wait...')
# generate is a one-step call (submit the task and wait for completion) and returns a completed Job
# audio_url / negative_prompt are input-section fields that are not part of the named signature, and are passed through via extra_input
try:
job = client.videos.generate(model='wan2.6-i2v-flash',
prompt='一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由他的rap构成,没有其他对话或杂音。',
image_url=img_url,
extra_input={'audio_url': audio_url,
'negative_prompt': ""},
resolution="720P",
duration=10,
prompt_extend=True,
watermark=False,
seed=12345)
print(job)
print("video_url:", 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_call_i2v()
Response example
The video_url is valid for 24 hours. Download the video promptly.
{
"request_id": "2794c7a3-fe8c-4dd4-a1b7-xxxxxx",
"task_id": "c15d5b14-07c4-4af5-b862-xxxxxx",
"status": "SUCCEEDED",
"video_url": "https://dashscope-result-bj.oss-cn-beijing.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,
"audio": true,
"SR": 720
}
}
Asynchronous Call
This example demonstrates the asynchronous calling method. This method immediately returns a task ID, and you need to poll on your own or wait for the task to complete.
Request example
import os
import dashscope
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.
# For the endpoints of each region, see https://www.alibabacloud.com/help/model-studio/image-to-video-api-reference
client = dashscope.Client(
# If the environment variable is not configured, set your Model Studio API key directly: api_key="sk-xxx"
# 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",
)
# Use a publicly accessible image URL
img_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
# Set the audio url
audio_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
def sample_async_call_i2v():
# Asynchronous call, which returns a task_id
# audio_url / negative_prompt are input-section fields that are not part of the named signature, and are passed through via extra_input
try:
job = client.videos.jobs.create(model='wan2.6-i2v-flash',
prompt='一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由他的rap构成,没有其他对话或杂音。',
image_url=img_url,
extra_input={'audio_url': audio_url,
'negative_prompt': ""},
resolution="720P",
duration=10,
prompt_extend=True,
watermark=False,
seed=12345)
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
# Obtain information about the asynchronous task.
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 asynchronous task to complete (polling with exponential backoff, default total budget 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_i2v()
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 promptly.
{
"request_id": "2794c7a3-fe8c-4dd4-a1b7-xxxxxx",
"task_id": "c15d5b14-07c4-4af5-b862-xxxxxx",
"status": "SUCCEEDED",
"video_url": "https://dashscope-result-bj.oss-cn-beijing.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,
"audio": true,
"SR": 720
}
}
Java SDK calls
ImportantEnsure that your DashScope Java SDK version is no earlier than 2.22.6 before running the following code.
If the version is too old, errors such as "url error, please check url!" may occur. Please refer to Install SDK to update it.
Set baseHttpApiUrl based on the region where the model is located:
Singapore
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
Virginia
Constants.baseHttpApiUrl = "https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1";
Beijing
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
Frankfurt
Constants.baseHttpApiUrl = "https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1";
When you call the API, replace {WorkspaceId} with your actual workspace ID.
Sample Code
Synchronous 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
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
public class Image2Video {
static {
// The following URL is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. URLs differ by region.
// Get the URL: https://www.alibabacloud.com/help/model-studio/image-to-video-api-reference
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
// If you have not configured the environment variable, replace the following line with your Model Studio API key: apiKey="sk-xxx"
// Get an API key: https://www.alibabacloud.com/help/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
/**
* Image input methods: Choose one of the following three.
*
* 1. Use a public URL - suitable for publicly accessible images.
* 2. Local file: Suitable for local development and testing.
* 3. Base64 encoding: Best for private images or when data must be securely transmitted.
*/
//[Method 1] Public URL
static String imgUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png";
//[Method 2] Local file path (file:// + absolute path)
// static String imgUrl = "file://" + "/your/path/to/img.png"; // Linux/macOS
// static String imgUrl = "file://" + "/C:/your/path/to/img.png"; // Windows
//[Method 3] Base64 encoding
// static String imgUrl = Image2Video.encodeFile("/your/path/to/img.png");
// Set the audio URL
static String audioUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3";
public static void image2video() throws ApiException, NoApiKeyException, InputRequiredException {
// Set the parameters
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("watermark", false);
parameters.put("seed", 12345);
VideoSynthesis vs = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.6-i2v-flash")
.prompt("一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由他的rap构成,没有其他对话或杂音。")
.imgUrl(imgUrl)
.audioUrl(audioUrl)
.duration(10)
.parameters(parameters)
.resolution("720P")
.negativePrompt("")
.build();
System.out.println("please wait...");
VideoSynthesisResult result = vs.call(param);
System.out.println(JsonUtils.toJson(result));
}
/**
* Encodes a file into a Base64 string.
* @param filePath The file path.
* @return A Base64 string in the format data:{MIME_type};base64,{base64_data}.
*/
public static String encodeFile(String filePath) {
Path path = Paths.get(filePath);
if (!Files.exists(path)) {
throw new IllegalArgumentException("文件不存在: " + filePath);
}
// Detect MIME type
String mimeType = null;
try {
mimeType = Files.probeContentType(path);
} catch (IOException e) {
throw new IllegalArgumentException("无法检测文件类型: " + filePath);
}
if (mimeType == null || !mimeType.startsWith("image/")) {
throw new IllegalArgumentException("不支持或无法识别的图像格式");
}
// Read file content and encode
byte[] fileBytes = null;
try{
fileBytes = Files.readAllBytes(path);
} catch (IOException e) {
throw new IllegalArgumentException("无法读取文件内容: " + filePath);
}
String encodedString = Base64.getEncoder().encodeToString(fileBytes);
return "data:" + mimeType + ";base64," + encodedString;
}
public static void main(String[] args) {
try {
image2video();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
Response example
The video_url is valid for 24 hours. Download the video promptly.
{
"request_id": "87c091bb-7a3c-4904-8501-xxxxxx",
"output": {
"task_id": "413ed6e4-5f3a-4f57-8d58-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx.mp4?Expires=xxx",
"orig_prompt": "一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由他的rap构成,没有其他对话或杂音。",
"submit_time": "2026-01-22 23:25:45.729",
"scheduled_time": "2026-01-22 23:25:45.771",
"end_time": "2026-01-22 23:26:44.942"
},
"usage": {
"video_count": 1,
"duration": 10.0,
"input_video_duration": 0.0,
"output_video_duration": 10.0,
"SR": "720"
},
"status_code": 200,
"code": "",
"message": ""
}
Asynchronous Call
This example demonstrates the asynchronous calling method. This method immediately returns a task ID, and you need to poll on your own or wait for the task to complete.
Request example
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisListResult;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.task.AsyncTaskListParam;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.util.HashMap;
import java.util.Map;
public class Image2Video {
static {
// The following URL is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. URLs differ by region.
// Get the URL: https://www.alibabacloud.com/help/model-studio/image-to-video-api-reference
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
// If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
// Get an API key: https://www.alibabacloud.com/help/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
//Set input image URL
static String imgUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png";
// Set the audio URL
static String audioUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3";
public static void image2video() throws ApiException, NoApiKeyException, InputRequiredException {
// Set the parameters
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("watermark", false);
parameters.put("seed", 12345);
VideoSynthesis vs = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.6-i2v-flash")
.prompt("一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由他的rap构成,没有其他对话或杂音。")
.imgUrl(imgUrl)
.audioUrl(audioUrl)
.duration(10)
.parameters(parameters)
.resolution("720P")
.negativePrompt("")
.build();
// Asynchronous call
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("please wait...");
//Retrieve the result.
VideoSynthesisResult result = vs.wait(task, apiKey);
System.out.println(JsonUtils.toJson(result));
}
// Retrieve the task list.
public static void listTask() throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
AsyncTaskListParam param = AsyncTaskListParam.builder().build();
param.setApiKey(apiKey);
VideoSynthesisListResult result = is.list(param);
System.out.println(result);
}
// Retrieve the result of a single task.
public static void fetchTask(String taskId) throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
// If DASHSCOPE_API_KEY is set as an environment variable, apiKey may be empty
VideoSynthesisResult result = is.fetch(taskId, apiKey);
System.out.println(result.getOutput());
System.out.println(result.getUsage());
}
public static void main(String[] args) {
try {
image2video();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
Response example
- Response example of creating a task
{
"request_id": "5dbf9dc5-4f4c-9605-85ea-xxxxxxxx",
"output": {
"task_id": "7277e20e-aa01-4709-xxxxxxxx",
"task_status": "PENDING"
}
}
- Response example of querying the task result
The video_url is valid for 24 hours. Download the video promptly.
{
"request_id": "87c091bb-7a3c-4904-8501-xxxxxx",
"output": {
"task_id": "413ed6e4-5f3a-4f57-8d58-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx.mp4?Expires=xxx",
"orig_prompt": "一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由他的rap构成,没有其他对话或杂音。",
"submit_time": "2026-01-22 23:25:45.729",
"scheduled_time": "2026-01-22 23:25:45.771",
"end_time": "2026-01-22 23:26:44.942"
},
"usage": {
"video_count": 1,
"duration": 10.0,
"input_video_duration": 0.0,
"output_video_duration": 10.0,
"SR": "720"
},
"status_code": 200,
"code": "",
"message": ""
}
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.
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 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.