The Wan image-to-video model generates a smooth video from a first frame image and a text prompt. The supported features include the following:
Basic features: You can select a video duration from 3 to 10 seconds, specify a video resolution of 480p, 720p, or 1080p, use prompt rewriting, and add watermarks.
Audio capabilities: You can use automatic audio generation or provide a custom audio file for audio-video synchronization. (Supported only by wan2.5)
Quick links: Try it online on the Wan official website | Video effect list
The features available on the Wan official website may differ from those supported by the API. This document describes the API's capabilities and is updated promptly to reflect new features.
Overview
Input first frame image and audio | Output video (wan2.5) |
Input audio: | |
Input prompt: A scene of urban fantasy art. A dynamic graffiti art character. A boy painted with spray paint comes to life from a concrete wall. He sings an English rap song at a very fast pace while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single streetlight, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of the boy's rap, with no other dialogue or noise. | |
Model | Description | Output video specifications |
wan2.5-i2v-preview | Wan 2.5 preview (Video with audio) New audio capabilities: Supports automatic audio generation and the use of custom audio files. | Resolution tiers: 480p, 720p, 1080p Video duration: 5 or 10 seconds Fixed specifications: 24 fps, MP4 (H.264 encoding) |
wan2.2-i2v-flash | Wan 2.2 Flash Edition (Silent video) 50% faster than the 2.1 model. | Resolution tiers: 480p, 720p, 1080p Video duration: 5 seconds Fixed specifications: 30 fps, MP4 (H.264 encoding) |
wan2.2-i2v-plus | Wan 2.2 Professional Edition (Silent video) Improved stability and success rate compared to the 2.1 model. | Resolution tiers: 480p, 1080p Video duration: 5 seconds Fixed specifications: 30 fps, MP4 (H.264 encoding) |
wanx2.1-i2v-plus | Wan 2.1 Professional Edition (Silent video) | Resolution tiers: 720p Video duration: 5 seconds Fixed specifications: 30 fps, MP4 (H.264 encoding) |
wanx2.1-i2v-turbo | Wan 2.1 Flash Edition (Silent video) | Resolution tiers: 480p, 720p Video duration: 3, 4, or 5 seconds Fixed specifications: 30 fps, MP4 (H.264 encoding) |
Before making a call, check the models and pricing supported in each region.
Prerequisites
Before making a call, you must create an API key and then export the API key as an environment variable. To make calls using an SDK, install the DashScope SDK.
The Beijing and Singapore regions have separate API keys and request endpoints. Do not use them interchangeably. Cross-region calls cause authentication failures or service errors.
HTTP
Image-to-video tasks can take a long time to complete, typically 1 to 5 minutes. For this reason, the API uses asynchronous invocation. The process involves two core steps: Create a task and then poll for results. The steps are as follows:
The actual time required depends on the number of tasks in the queue and the service execution status. Please be patient while you wait for the result.
Step 1: Create a task to get a task ID
Singapore: POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Beijing: POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
After the task is created, use the returned
task_idto query the result. The task_id is valid for 24 hours. Do not create duplicate tasks. Use polling to retrieve the result.
Request parameters | Automatic audio generationThis feature is supported only by the wan2.5-i2v-preview model. Automatic audio generation is enabled by default and requires no configuration. To explicitly enable this feature, set the The API keys for the Singapore and Beijing regions are different. For more information, see Obtain an API key. The following example uses the base URL for the Singapore region. If you use a model in the Beijing region, replace the base URL with https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis. Provide an audio fileThis feature is supported only by the wan2.5-i2v-preview model. Provide the audio link in the The API keys for the Singapore and Beijing regions are different. For more information, see Obtain an API key. The following example uses the base URL for the Singapore region. If you use a model in the Beijing region, replace the base URL with https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis. Generate a silent videoThe method for generating a silent video varies by model version:
The API keys for the Singapore and Beijing regions are different. For more information, see Obtain API key. The following example uses the base URL for the Singapore region. If you use a model in the Beijing region, replace the base URL with https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis. Use a negative promptUse negative_prompt to prevent the generated video from including "flowers". The API keys for the Singapore and Beijing regions are different. For more information, see Obtain an API key. The following example uses the base URL for the Singapore region. If you use a model in the Beijing region, replace the base URL with https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis. |
Request headers | |
Content-Type The content type of the request. Set this parameter to | |
Authorization The identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx. | |
X-DashScope-Async The asynchronous processing configuration parameter. HTTP requests support only asynchronous processing. You must set this parameter to Important If this request header is missing, the error message "current user api does not support synchronous calls" is returned. | |
Request body | |
model The model name. Example: wan2.2-i2v-plus. For a list of models and their prices, see Models and pricing. | |
input Basic input information, such as the prompt. | |
parameters Video processing parameters, such as the video resolution, video duration, prompt rewriting, and watermark. |
Response parameters | Successful responseSave the task_id to query the task status and result. Error responseThe task creation failed. For more information, see 429-Error messages to resolve the issue. |
output The task output information. | |
request_id The unique request ID. You can use this ID to trace and troubleshoot issues. | |
code The error code for a failed request. This parameter is not returned if the request is successful. For more information, see 429-Error messages. | |
message The detailed information about a failed request. This parameter is not returned if the request is successful. For more information, see 429-Error messages. |
Step 2: Query the result by task ID
Singapore region: GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id}
Beijing region: GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
Polling suggestion: Video generation takes several minutes. Use a polling mechanism and set a reasonable query interval, such as 15 seconds, to retrieve the result.
Task status transition: PENDING (In queue) → RUNNING (Processing) → SUCCEEDED (Successful) or FAILED (Failed).
Result link: After the task is successful, a video link is returned. The link is valid for 24 hours. After you retrieve the link, immediately download and save the video to a permanent storage service, such as Alibaba Cloud OSS.
task_id validity: 24 hours. After this period, you cannot query the result, and the API returns a task status of
UNKNOWN.
Request parameters | Query task resultsReplace The API keys for the Singapore and Beijing regions are different. Obtain an API key. The following code provides the base_url for the Singapore region. If you use a model in the Beijing region, replace the base_url with https://dashscope.aliyuncs.com/api/v1/tasks/{task_id} |
Request headers | |
Authorization The identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx. | |
URL path parameters | |
task_id The task ID. |
Response parameters | Task succeededVideo URLs are retained for only 24 hours and are automatically purged after this period. You must save the generated videos promptly. Task failedIf a task fails, task_status is set to FAILED, and an error code and message are provided. For more information, see 429-Error messages to resolve the issue. Task query expiredThe task_id is valid for 24 hours. After this period, the query fails and the following error message is returned. |
output The task output information. | |
usage Statistics for the output information. Only successful results are counted. | |
request_id The unique request ID. You can use this ID to trace and troubleshoot issues. |
DashScope SDK
The parameter names in the SDK are mostly consistent with the HTTP API. The parameter structure is encapsulated based on the features of the programming language.
Because image-to-video tasks can take a long time to complete, typically 1 to 5 minutes, the SDK encapsulates the asynchronous HTTP call process at the underlying layer and supports both synchronous and asynchronous call methods.
The actual time required depends on the number of tasks in the queue and the service execution status. Please be patient while you wait for the result.
Python SDK
The Python SDK supports three image input methods: public URL, Base64-encoded string, and local file path (absolute or relative). You can choose one of these methods. For more information, see Input image.
We recommend that you install the latest version of the DashScope Python SDK to avoid potential runtime errors. For more information, see Install or upgrade the SDK.
Sample code
Synchronous
A synchronous call blocks and waits until the video generation is complete and the result is returned. This example shows three image input methods: public URL, Base64 encoding, and local file path.
Request example
import base64
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import mimetypes
import dashscope
# The following is the URL for the Singapore region. If you use a model in the Beijing region, replace the URL with: https://dashscope.aliyuncs.com/api/v1
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# If you have not configured an environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx"
# The API keys for the Singapore and Beijing regions are different. Get an API key: https://www.alibabacloud.com/help/zh/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")
# --- Helper function for Base64 encoding ---
# Format: 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("Unsupported or unknown image format")
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}"
"""
Image input methods:
The following are three image input methods.
1. Use a public URL - Suitable for publicly accessible images.
2. Use a local file - Suitable for local development and testing.
3. Use Base64 encoding - Suitable for private images or scenarios requiring encrypted transmission.
"""
# [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" # Path relative to the current execution file
# [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():
# Synchronous call, returns the result directly
print('Please wait...')
rsp = VideoSynthesis.call(api_key=api_key,
model='wan2.5-i2v-preview',
prompt='A scene of urban fantasy art. A dynamic graffiti art character. A boy painted with spray paint comes to life from a concrete wall. He sings an English rap song at a very fast pace while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single streetlight, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of the boy'\''s rap, with no other dialogue or noise.',
img_url=img_url,
audio_url=audio_url,
resolution="480P",
duration=10,
# audio=True,
prompt_extend=True,
watermark=False,
negative_prompt="",
seed=12345)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print("video_url:", rsp.output.video_url)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
sample_call_i2v()Response example
The `video_url` is valid for 24 hours. Download the video promptly.
{
"status_code": 200,
"request_id": "55194b9a-d281-4565-8ef6-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "e2bb35a2-0218-4969-8c0d-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?Expires=xxx",
"submit_time": "2025-10-28 13:45:48.620",
"scheduled_time": "2025-10-28 13:45:57.378",
"end_time": "2025-10-28 13:48:05.361",
"orig_prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy painted with spray paint comes to life from a concrete wall. He sings an English rap song at a very fast pace while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single streetlight, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of the boy'\''s rap, with no other dialogue or noise.",
"actual_prompt": "A boy made of spray paint emerges from a concrete wall, stands still, and begins to sing an English rap, his mouth opening and closing, his head nodding to the rhythm, and his eyes focused. He gives a thumbs-up with his right hand, puts his left hand on his hip, and moves his body rhythmically in place. The background is a night scene under a railway bridge, lit by a single streetlight. The audio is the boy'\''s rap performance, with the lyrics: 'Skyscrapers loom, shadows kiss the pavement. Dreams stack high, but the soul'\''s in the basement. Pocket full of lint, chasing gold like it'\''s sacred. Every breath a gamble, the odds never patient.'"
},
"usage": {
"video_count": 1,
"video_duration": 0,
"video_ratio": "",
"duration": 10,
"SR": 480
}
}Asynchronous
This example shows an asynchronous call. This method immediately returns a task ID, and you must poll for or wait for the task to complete.
Request example
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
# The following is the URL for the Singapore region. If you use a model in the Beijing region, replace the URL with: https://dashscope.aliyuncs.com/api/v1
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# If you have not configured an environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx"
# The API keys for the Singapore and Beijing regions are different. Get an API key: https://www.alibabacloud.com/help/zh/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")
# 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, returns a task_id
rsp = VideoSynthesis.async_call(api_key=api_key,
model='wan2.5-i2v-preview',
prompt='A scene of urban fantasy art. A dynamic graffiti art character. A boy painted with spray paint comes to life from a concrete wall. He sings an English rap song at a very fast pace while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single streetlight, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of the boy'\''s rap, with no other dialogue or noise.',
img_url=img_url,
audio_url=audio_url,
resolution="480P",
duration=10,
# audio=True,
prompt_extend=True,
watermark=False,
negative_prompt="",
seed=12345)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print("task_id: %s" % rsp.output.task_id)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
# Get asynchronous task information
status = VideoSynthesis.fetch(task=rsp, api_key=api_key)
if status.status_code == HTTPStatus.OK:
print(status.output.task_status)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(status.status_code, status.code, status.message))
# Wait for the asynchronous task to finish
rsp = VideoSynthesis.wait(task=rsp, api_key=api_key)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.video_url)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
sample_async_call_i2v()Response example
1. Response example for creating a task
{
"status_code": 200,
"request_id": "6dc3bf6c-be18-9268-9c27-xxxxxx",
"code": "",
"message": "",
"output": {
"task_id": "686391d9-7ecf-4290-a8e9-xxxxxx",
"task_status": "PENDING",
"video_url": ""
},
"usage": null
}2. Response example for querying a task result
The `video_url` is valid for 24 hours. Download the video promptly.
{
"status_code": 200,
"request_id": "55194b9a-d281-4565-8ef6-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "e2bb35a2-0218-4969-8c0d-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?Expires=xxx",
"submit_time": "2025-10-28 13:45:48.620",
"scheduled_time": "2025-10-28 13:45:57.378",
"end_time": "2025-10-28 13:48:05.361",
"orig_prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy painted with spray paint comes to life from a concrete wall. He sings an English rap song at a very fast pace while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single streetlight, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of the boy'\''s rap, with no other dialogue or noise.",
"actual_prompt": "A boy made of spray paint emerges from a concrete wall, stands still, and begins to sing an English rap, his mouth opening and closing, his head nodding to the rhythm, and his eyes focused. He gives a thumbs-up with his right hand, puts his left hand on his hip, and moves his body rhythmically in place. The background is a night scene under a railway bridge, lit by a single streetlight. The audio is the boy'\''s rap performance, with the lyrics: 'Skyscrapers loom, shadows kiss the pavement. Dreams stack high, but the soul'\''s in the basement. Pocket full of lint, chasing gold like it'\''s sacred. Every breath a gamble, the odds never patient.'"
},
"usage": {
"video_count": 1,
"video_duration": 0,
"video_ratio": "",
"duration": 10,
"SR": 480
}
}Java SDK
The Java SDK supports three image input methods: public URL, Base64-encoded string, and local file path (absolute path only). You can choose one of these methods. For more information, see Input image.
We recommend that you install the latest version of the DashScope Java SDK to avoid potential runtime errors. For more information, see Install or upgrade the SDK.
Sample code
Synchronous
A synchronous call blocks and waits until the video generation is complete and the result is returned. This example shows 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.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.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
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 {
Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
// The preceding is the URL for the Singapore region. If you use a model in the Beijing region, replace the URL with: https://dashscope.aliyuncs.com/api/v1
}
// If you have not configured an environment variable, replace the following line with your Model Studio API key: apiKey="sk-xxx"
// The API keys for the Singapore and Beijing regions are different. Get an API key: https://www.alibabacloud.com/help/zh/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. Use a local file - Suitable for local development and testing.
* 3. Use Base64 encoding - Suitable for private images or scenarios requiring encrypted transmission.
*/
// [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.5-i2v-preview")
.prompt("A scene of urban fantasy art. A dynamic graffiti art character. A boy painted with spray paint comes to life from a concrete wall. He sings an English rap song at a very fast pace while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single streetlight, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of the boy'\''s rap, with no other dialogue or noise.")
.imgUrl(imgUrl)
.audioUrl(audioUrl)
//.audio(true)
.duration(10)
.parameters(parameters)
.resolution("480P")
.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("File does not exist: " + filePath);
}
// Detect MIME type
String mimeType = null;
try {
mimeType = Files.probeContentType(path);
} catch (IOException e) {
throw new IllegalArgumentException("Cannot detect file type: " + filePath);
}
if (mimeType == null || !mimeType.startsWith("image/")) {
throw new IllegalArgumentException("Unsupported or unknown image format");
}
// Read file content and encode
byte[] fileBytes = null;
try{
fileBytes = Files.readAllBytes(path);
} catch (IOException e) {
throw new IllegalArgumentException("Cannot read file content: " + 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": "f1bfb531-6e13-4e17-8e93-xxxxxx",
"output": {
"task_id": "9ddebba6-f784-4f55-b845-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?Expires=xxx"
},
"usage": {
"video_count": 1
}
}Asynchronous
This example shows an asynchronous call. This method immediately returns a task ID, and you must poll for or wait for the task to complete.
Request example
// Copyright (c) Alibaba, Inc. and its affiliates.
// dashscope sdk >= 2.20.1
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.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.HashMap;
import java.util.Map;
public class Image2Video {
static {
// The following is the URL for the Singapore region. If you use a model in the Beijing region, replace the URL with: https://dashscope.aliyuncs.com/api/v1
Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
}
// If you have not configured an environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx"
// The API keys for the Singapore and Beijing regions are different. Get an API key: https://www.alibabacloud.com/help/zh/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
// Set the 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.5-i2v-preview")
.prompt("A scene of urban fantasy art. A dynamic graffiti art character. A boy painted with spray paint comes to life from a concrete wall. He sings an English rap song at a very fast pace while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single streetlight, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of the boy'\''s rap, with no other dialogue or noise.")
.imgUrl(imgUrl)
.audioUrl(audioUrl)
//.audio(true)
.duration(10)
.parameters(parameters)
.resolution("480P")
.negativePrompt("")
.build();
// Asynchronous call
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("Please wait...");
// Get the result
VideoSynthesisResult result = vs.wait(task, apiKey);
System.out.println(JsonUtils.toJson(result));
}
// Get 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);
}
// Get a single task result
public static void fetchTask(String taskId) throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
// If DASHSCOPE_API_KEY is set as an environment variable, apiKey can be null.
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
1. Response example for creating a task
{
"request_id": "5dbf9dc5-4f4c-9605-85ea-xxxxxxxx",
"output": {
"task_id": "7277e20e-aa01-4709-xxxxxxxx",
"task_status": "PENDING"
}
}2. Response example for querying a task result
The `video_url` is valid for 24 hours. Download the video promptly.
{
"request_id": "f1bfb531-6e13-4e17-8e93-xxxxxx",
"output": {
"task_id": "9ddebba6-f784-4f55-b845-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?Expires=xxx"
},
"usage": {
"video_count": 1
}
}Limitations
Data retention: The task_id and video URL are retained for only 24 hours. After this period, they cannot be queried or downloaded.
Audio support: The wan2.5 model supports videos with audio, including automatic audio generation or a custom audio file. The wan2.2 and earlier versions only output silent videos. If needed, you can use speech synthesis to generate audio.
Content moderation: The input prompt and video, along with the output video, are subject to content moderation. Non-compliant content results in an "IPInfringementSuspect" or "DataInspectionFailed" error. For more information, see Error codes.
Network access configuration: Video links are stored in Alibaba Cloud OSS. If your business system cannot access external OSS links due to security policies, you must add the following OSS domain names to your network access whitelist.
# OSS domain name list dashscope-result-bj.oss-cn-beijing.aliyuncs.com dashscope-result-hz.oss-cn-hangzhou.aliyuncs.com dashscope-result-sh.oss-cn-shanghai.aliyuncs.com dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com dashscope-result-zjk.oss-cn-zhangjiakou.aliyuncs.com dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com dashscope-result-hy.oss-cn-heyuan.aliyuncs.com dashscope-result-cd.oss-cn-chengdu.aliyuncs.com dashscope-result-gz.oss-cn-guangzhou.aliyuncs.com dashscope-result-wlcb-acdr-1.oss-cn-wulanchabu-acdr-1.aliyuncs.com
Key parameter descriptions
Input image
The img_url parameter specifies the input image and supports the following three input methods:
Method 1: Public URL
A publicly accessible address that supports HTTP/HTTPS.
Example:
https://example.com/images/cat.png.
Method 2: Base64 encoding
Example:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABDg......(Snippet shown due to length limit). When making a call, pass the complete string.Encoding format: Use the
data:{MIME_type};base64,{base64_data}format, where:{base64_data}: The Base64-encoded string of the image file.
{MIME_type}: The media type of the image, which must correspond to the file format.
Image format
MIME Type
JPEG
image/jpeg
JPG
image/jpeg
PNG
image/png
BMP
image/bmp
WEBP
image/webp
Method 3: Local file path (SDK only)
Python SDK: Supports both absolute and relative file paths. The file path rules are as follows:
System
Passed file path
Example (absolute path)
Example (relative path)
Linux or macOS
file://{absolute or relative path of the file}
file:///home/images/test.png
file://./images/test.png
Windows
file://D:/images/test.png
file://./images/test.png
Java SDK: Supports only the absolute path of the file. The file path rules are as follows:
System
Passed file path
Example (absolute path)
Linux or macOS
file://{absolute path of the file}
file:///home/images/test.png
Windows
file:///{absolute path of the file}
file:///D:/images/test.png
Audio settings
Supported model: wan2.5-i2v-preview.
Audio settings: You can control the audio behavior using the input.audio_url and parameters.audio parameters. Priority: audio_url > audio. Three modes are supported:
Generate a silent video
Parameter settings: Do not pass `audio_url`, and set `audio` to `false`.
Scenario: This is useful for purely visual content where you plan to add your own audio or music later.
Generate audio automatically
Parameter settings: Do not pass `audio_url`, and set `audio` to `true`.
Effect description: The model automatically generates matching background audio or music based on the prompt and visual content.
Use custom audio
Parameter settings: Pass an `audio_url`. The `audio` parameter is ignored in this case.
Effect description: The video content is aligned with the audio content, such as lip movements and rhythm.
Billing and rate limiting
For information about the model's free quota and pricing, see Models and pricing.
For more information about model rate limiting, see Wan series.
Billing description:
You are charged based on the duration in seconds of successfully generated videos. A charge is incurred only when the query result API returns a
task_statusofSUCCEEDEDand the video is successfully generated.Failed model calls or processing errors do not incur any fees or consume the free quota.
Error codes
If a model call fails and an error message is returned, see 429-Error messages for more information.
FAQ
For video-related questions, see the 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 first frame image (img_url), but an exact ratio, such as a strict 3:4, cannot be guaranteed.
How it works: The model uses the aspect ratio of the input image as a baseline and then adapts it to a supported resolution based on the resolution parameter, such as 480p, 720p, or 1080p. Because the output resolution must meet technical requirements where the width and height must be divisible by 16, the final aspect ratio may have a slight deviation, for example, an adjustment from 0.75 to 0.739. This is normal behavior.
Example: An input image is 750 × 1000 (aspect ratio 3:4 = 0.75), and `resolution` is set to "720p" (target total pixels approx. 920,000). The actual output is 816 × 1104 (aspect ratio ≈ 0.739, total pixels approx. 900,000).
Note that the resolution parameter mainly controls the video's definition (total pixel count). The final video aspect ratio is still based on the input image, with only necessary minor adjustments.
Best practice: To strictly match a target aspect ratio, use an input image with that ratio and then post-process the output video by cropping or padding it. For example, you can use a video editing tool to crop the output video to the target ratio, or add black bars or a blurred background for padding.
Appendix
Examples of basic image-to-video features
Feature | Input first frame image | Input prompt | Output video |
Silent video |
| A cat running on the grass |

