image-to-video - based on first frame
The Wan Image-to-Video model accepts multimodal input (text, image, or audio) and generates videos up to 15 seconds long at 1080P resolution.
- Basic Settings: Supports integer video durations from 2 to 15 seconds, configurable video resolution (480P, 720P, or 1080P), smart prompt rewriting, and optional watermarking.
- Audio Capabilities: Supports automatic dubbing or uploading an audio file to achieve audio-visual synchronization. (Supported by Wan 2.5 and Wan 2.6)
- Multi-shot Narrative: Generates multi-shot videos while preserving subject consistency across shot transitions. (Supported by Wan 2.6 only)
- Video Effects: Includes built-in templates such as “Magic Float” and “Balloon Expand.” Use them directly.
Quick links:Try it online (Beijing|Singapore|Virginia)|API reference| Video effects list
Getting Started
| Input Prompt | Input First Frame Image | Output Video (Multi-shot, Audio Video) |
The camera slowly moves up from below the turtle, which swims gracefully, its belly details clearly visible. | ![]() |
Before making calls, first obtain and configure an API Key, then configure the API Key in environment variables. To call through the SDK, please install the DashScope SDK.
Python SDK
ImportantMake sure the DashScope Python SDK version is no lower 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.
import os
import dashscope
from dashscope import DashScopeError
# 以下为华北2(北京)地域的配置。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的region取值不同。
# 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
client = dashscope.Client(
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="cn-beijing",
)
print('please wait...')
# generate 为一步式调用(提交任务并等待完成),返回已完成的 Job
# shot_type 不在具名签名内,经 parameters 透传
try:
job = client.videos.generate(model='wan2.6-i2v-flash',
prompt='镜头从海龟下方缓缓上移,海龟悠然游动,腹部细节清晰可见。',
image_url="https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260121/zlpocv/wan-i2v-haigui.webp",
resolution="720P",
duration=10,
prompt_extend=True,
watermark=True,
parameters={'shot_type': "multi"})
print(job)
print("video_url:", job.video_url)
except DashScopeError as e:
print(f"HTTP返回码:{e.status_code}")
print(f"错误码:{e.code}")
print(f"错误信息:{e.message}")
print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")
Java SDK
ImportantMake sure the DashScope Java SDK version is no lower 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. Refer to Install SDK to update.
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;
public class Image2Video {
static {
// 以下为北京地域URL。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的URL不同,获取URL:https://help.aliyun.com/zh/model-studio/image-to-video-api-reference
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
}
// 若没有配置环境变量,请用百炼API Key将下行替换为:apiKey="sk-xxx"
// 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void image2video() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.6-i2v-flash")
.prompt("镜头从海龟下方缓缓上移,海龟悠然游动,腹部细节清晰可见。")
.imgUrl("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260121/zlpocv/wan-i2v-haigui.webp")
.duration(10)
.resolution("720P")
.shotType("multi")
.promptExtend(true)
.watermark(true)
.build();
System.out.println("please wait...");
VideoSynthesisResult result = vs.call(param);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
image2video();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
curl
Step 1: Create a task to obtain the task IDcurl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.6-i2v-flash",
"input": {
"prompt": "镜头从海龟下方缓缓上移,海龟悠然游动,腹部细节清晰可见。",
"img_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260121/zlpocv/wan-i2v-haigui.webp"
},
"parameters": {
"resolution": "720P",
"prompt_extend": true,
"watermark": true,
"duration": 10,
"shot_type":"multi"
}
}'
Step 2: Get the result by task IDReplace {task_id} entirely with the value of task_id returned by the API in the previous step. The task_id can be queried within 24 hours. Also replace {WorkspaceId} with your actual Workspace ID.
curl -X GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
The
video_urlis valid for 24 hours. Download the video promptly.
{
"request_id": "c1209113-8437-424f-a386-xxxxxx",
"output": {
"task_id": "966cebcd-dedc-4962-af88-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
...
},
...
}
Applicable scope
- The models supported vary by region, and resources are independent of each other. For the models supported in each region, see the Bailian console.
- When making calls, ensure that the model, Endpoint URL, and API Key all belong to the same region; cross-region calls will fail.
NoteThe sample code in this document applies to the Beijing region.
Core capabilities
Creating multi-shot videos
Supported models: wan2.6 series models.
Overview: The model can automatically switch between shots, for example from a wide shot to a close-up, making it suitable for scenarios such as MV production.
Parameter settings:
shot_type: must be set to"multi".prompt_extend: must be set totrue(enables intelligent rewriting to optimize shot descriptions).
| Input Prompt | Input First Frame Image | Output video (wan2.6, multi-shot video) |
An urban fantasy art scene. A dynamic graffiti art character. A youth painted with spray paint is coming to life from a concrete wall. He performs an English rap at a breakneck 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 lonely streetlamp, creating a cinematic atmosphere full of high energy and stunning detail. The audio portion of the video consists entirely of rap, with no other dialogue or noise. | ![]() Input audio: |
Python SDK
Make sure the DashScope Python SDK version is no lower than 2.0.1. See Install SDK to update.
import os
import dashscope
from dashscope import DashScopeError
# 以下为华北2(北京)地域的配置。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的region取值不同。
client = dashscope.Client(
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
# 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="cn-beijing",
)
def sample_async_call_i2v():
# 异步调用,返回一个task_id
try:
# audio_url / negative_prompt 为 input 段字段,不在具名签名内,经 extra_input 透传
# shot_type(多镜头)为 parameters 段字段,经 parameters 透传
job = client.videos.jobs.create(model='wan2.6-i2v-flash',
prompt='一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由rap构成,没有其他对话或杂音。',
image_url="https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png",
extra_input={'audio_url': "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3",
'negative_prompt': ""},
resolution="720P",
duration=10,
prompt_extend=True,
watermark=True,
seed=12345,
parameters={'shot_type': "multi"})
print(job)
print("task_id: %s" % job.task_id)
except DashScopeError as e:
print(f"HTTP返回码:{e.status_code}")
print(f"错误码:{e.code}")
print(f"错误信息:{e.message}")
print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")
return
# 等待异步任务结束(指数退避轮询,默认总预算24小时)
try:
done = client.videos.jobs.wait(job)
print(done)
print(done.video_url)
except DashScopeError as e:
print(f"HTTP返回码:{e.status_code}")
print(f"错误码:{e.code}")
print(f"错误信息:{e.message}")
print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")
if __name__ == '__main__':
sample_async_call_i2v()
Java SDK
Make sure the DashScope Java SDK version is no lower than
2.22.6. See Install SDK to update.
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;
public class Image2Video {
static {
// 以下为北京地域URL。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的URL不同,获取URL:https://help.aliyun.com/zh/model-studio/image-to-video-api-reference
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
}
// 若没有配置环境变量,请用百炼API Key将下行替换为:apiKey="sk-xxx"
// 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
//设置输入图像url
static String imgUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png";
// 设置音频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 {
VideoSynthesis vs = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.6-i2v-flash")
.prompt("一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由rap构成,没有其他对话或杂音。")
.imgUrl(imgUrl)
.audioUrl(audioUrl)
.shotType("multi")
.duration(10)
.resolution("720P")
.negativePrompt("")
.promptExtend(true)
.watermark(true)
.seed(12345)
.build();
// 异步调用
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("please wait...");
//获取结果
VideoSynthesisResult result = vs.wait(task, apiKey);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
image2video();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
curl
Step 1: Create a task to obtain the task ID# 以下为华北2(北京)地域的URL,调用时请将 {WorkspaceId} 替换为真实的业务空间ID,各地域的URL不同。
curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.6-i2v-flash",
"input": {
"prompt": "一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由他的rap构成,没有其他对话或杂音。",
"img_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png",
"audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
},
"parameters": {
"resolution": "720P",
"prompt_extend": true,
"duration": 10,
"shot_type":"multi"
}
}'
Step 2: Get the result by task IDReplace {task_id} entirely with the value of task_id returned by the API in the previous step. The task_id can be queried within 24 hours. Also replace {WorkspaceId} with your actual Workspace ID.
curl -X GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
Achieving audio-visual synchronization
Supported models: wan2.5 and wan2.6 series models.
Overview: Make the person in a photo "speak" or sing, with lip movements matched to the audio. For more examples, see Video voice generation.
Parameter settings:- Provide an audio file: pass in
audio_url. The model aligns lip movements with the audio file. - Automatic dubbing: no need to pass in
audio_url; a video with audio is output by default. The model automatically generates background sound effects, music, or vocals based on the visuals.
| Input Prompt | Input First Frame Image | Output video (video with audio) |
An urban fantasy art scene. A dynamic graffiti art character. A youth painted with spray paint is coming to life from a concrete wall. He performs an English rap at a breakneck 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 lonely streetlamp, creating a cinematic atmosphere full of high energy and stunning detail. The audio portion of the video consists entirely of rap, with no other dialogue or noise. | ![]() Input audio: |
Python SDK
Make sure the DashScope Python SDK version is no lower than 2.0.1. See Install SDK to update.
import os
import dashscope
from dashscope import DashScopeError
# 以下为华北2(北京)地域的配置。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的region取值不同。
client = dashscope.Client(
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
# 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="cn-beijing",
)
def sample_async_call_i2v():
# 异步调用,返回一个task_id
try:
# audio_url / negative_prompt 为 input 段字段,不在具名签名内,经 extra_input 透传
job = client.videos.jobs.create(model='wan2.6-i2v-flash',
prompt='一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由rap构成,没有其他对话或杂音。',
image_url="https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png",
extra_input={'audio_url': "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3",
'negative_prompt': ""},
resolution="720P",
duration=10,
prompt_extend=True,
watermark=True,
seed=12345)
print(job)
print("task_id: %s" % job.task_id)
except DashScopeError as e:
print(f"HTTP返回码:{e.status_code}")
print(f"错误码:{e.code}")
print(f"错误信息:{e.message}")
print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")
return
# 等待异步任务结束(指数退避轮询,默认总预算24小时)
try:
done = client.videos.jobs.wait(job)
print(done)
print(done.video_url)
except DashScopeError as e:
print(f"HTTP返回码:{e.status_code}")
print(f"错误码:{e.code}")
print(f"错误信息:{e.message}")
print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")
if __name__ == '__main__':
sample_async_call_i2v()
Java SDK
Make sure the DashScope Java SDK version is no lower than
2.22.6. See Install SDK to update.
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;
public class Image2Video {
static {
// 以下为北京地域URL。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的URL不同,获取URL:https://help.aliyun.com/zh/model-studio/image-to-video-api-reference
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
}
// 若没有配置环境变量,请用百炼API Key将下行替换为:apiKey="sk-xxx"
// 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
//设置输入图像url
static String imgUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png";
// 设置音频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 {
VideoSynthesis vs = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.6-i2v-flash")
.prompt("一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由rap构成,没有其他对话或杂音。")
.imgUrl(imgUrl)
.audioUrl(audioUrl)
.duration(10)
.resolution("720P")
.negativePrompt("")
.promptExtend(true)
.watermark(true)
.seed(12345)
.build();
// 异步调用
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("please wait...");
//获取结果
VideoSynthesisResult result = vs.wait(task, apiKey);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
image2video();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
curl
Step 1: Create a task to obtain the task ID# 以下为华北2(北京)地域的URL,调用时请将 {WorkspaceId} 替换为真实的业务空间ID,各地域的URL不同。
curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.5-i2v-preview",
"input": {
"prompt": "一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由他的rap构成,没有其他对话或杂音。",
"img_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png",
"audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
},
"parameters": {
"resolution": "480P",
"prompt_extend": true,
"duration": 10
}
}'
# 以下为华北2(北京)地域的URL,调用时请将 {WorkspaceId} 替换为真实的业务空间ID,各地域的URL不同。
curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.5-i2v-preview",
"input": {
"prompt": "一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由他的rap构成,没有其他对话或杂音。",
"img_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
},
"parameters": {
"resolution": "480P",
"prompt_extend": true,
"duration": 10
}
}'
Replace {task_id} entirely with the value of task_id returned by the API in the previous step. The task_id can be queried within 24 hours. Also replace {WorkspaceId} with your actual Workspace ID.
curl -X GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
Step 1: Create a task to obtain the task ID
Automatic dubbing
Input audio files
Tab 2 content
Step 2: Get results based on the task ID
Generate silent videos
Supported models: wan2.6-i2v-flash, wan2.2 series models, and wanx2.1 series models.
Overview: Suitable for purely visual display scenarios that do not require audio, such as dynamic posters and silent short videos.
Parameter settings:
wan2.6-i2v-flash: Generates videos with audio by default. To generate a silent video, you must explicitly setaudio=false. Even ifaudio_urlis passed in, as long asaudio=false, the output is still a silent video and is billed as a silent video.wan2.2 and earlier series models: Generate silent videos by default; no additional configuration is required.
| Prompt | Input First Frame Image | Output video (silent video) |
A cat running on the grass | ![]() |
Python SDK
Make sure the DashScope Python SDK version is no lower than 2.0.1. See Install SDK to update.
import os
import dashscope
from dashscope import DashScopeError
# 以下为华北2(北京)地域的配置。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的region取值不同。
client = dashscope.Client(
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
# 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="cn-beijing",
)
def sample_async_call_i2v():
# 异步调用,返回一个task_id
try:
# negative_prompt 为 input 段字段,经 extra_input 透传
# audio(必须显式设置为False,表示输出无声视频)为 parameters 段字段,经 parameters 透传
job = client.videos.jobs.create(model='wan2.6-i2v-flash',
prompt='一只猫在草地上奔跑',
image_url="https://cdn.translate.alibaba.com/r/wanx-demo-1.png",
extra_input={'negative_prompt': ""},
resolution="720P",
duration=5,
prompt_extend=True,
watermark=True,
seed=12345,
parameters={'audio': False})
print(job)
print("task_id: %s" % job.task_id)
except DashScopeError as e:
print(f"HTTP返回码:{e.status_code}")
print(f"错误码:{e.code}")
print(f"错误信息:{e.message}")
print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")
return
# 等待异步任务结束(指数退避轮询,默认总预算24小时)
try:
done = client.videos.jobs.wait(job)
print(done)
print(done.video_url)
except DashScopeError as e:
print(f"HTTP返回码:{e.status_code}")
print(f"错误码:{e.code}")
print(f"错误信息:{e.message}")
print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")
if __name__ == '__main__':
sample_async_call_i2v()
Java SDK
Make sure the DashScope Java SDK version is no lower than
2.22.6. See Install SDK to update.
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;
public class Image2Video {
static {
// 以下为北京地域URL。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的URL不同,获取URL:https://help.aliyun.com/zh/model-studio/image-to-video-api-reference
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
}
// 若没有配置环境变量,请用百炼API Key将下行替换为:apiKey="sk-xxx"
// 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void image2video() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.6-i2v-flash")
.prompt("一只猫在草地上奔跑")
.imgUrl("https://cdn.translate.alibaba.com/r/wanx-demo-1.png")
.audio(false) /*必须显式设置为false,表示输出无声视频*/
.duration(10)
.resolution("720P")
.negativePrompt("")
.promptExtend(true)
.watermark(true)
.seed(12345)
.build();
// 异步调用
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("please wait...");
//获取结果
VideoSynthesisResult result = vs.wait(task, apiKey);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
image2video();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
curl
Step 1: Create a task to obtain the task IDcurl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.6-i2v-flash",
"input": {
"prompt": "一只猫在草地上奔跑",
"img_url": "https://cdn.translate.alibaba.com/r/wanx-demo-1.png"
},
"parameters": {
"audio": false,
"resolution": "720P",
"prompt_extend": true,
"watermark": true,
"duration": 5
}
}'
# 以下为华北2(北京)地域的URL,调用时请将 {WorkspaceId} 替换为真实的业务空间ID,各地域的URL不同。
curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.2-i2v-plus",
"input": {
"prompt": "一只猫在草地上奔跑",
"img_url": "https://cdn.translate.alibaba.com/r/wanx-demo-1.png"
},
"parameters": {
"resolution": "480P",
"prompt_extend": true
}
}'
Replace {task_id} entirely with the value of task_id returned by the API in the previous step. The task_id can be queried within 24 hours. Also replace {WorkspaceId} with your actual Workspace ID.
curl -X GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
Use video effects
Supported models: wanx2.1-i2v-turbo and wanx2.1-i2v-plus.
Overview: No prompt is required. Simply use the built-in effect templates (such as "magic levitation" and "balloon inflation") to bring static images to life.
Parameter settings:template: Required. Specifies the effect name (for example, "flying" for magic levitation). Before calling, check the video effects list to confirm that the model supports the effect, to avoid call failures.prompt: Ignored. When using effects, the prompt field is invalid; it is recommended to leave it empty or not pass it.
| Prompt | Input First Frame Image | Output video ("magic levitation" effect) |
None | ![]() |
Python SDK
Make sure the DashScope Python SDK version is no lower than 2.0.1. See Install SDK to update.
import os
import dashscope
from dashscope import DashScopeError
# 以下为华北2(北京)地域的配置。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的region取值不同。
client = dashscope.Client(
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
# 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="cn-beijing",
)
def sample_async_call_i2v():
# 异步调用,返回一个task_id
try:
# template(模型特效)为 input 段字段,不在具名签名内,经 extra_input 透传
job = client.videos.jobs.create(model='wanx2.1-i2v-turbo',
image_url="https://cdn.translate.alibaba.com/r/wanx-demo-1.png",
extra_input={'template': "flying"},
resolution="720P",
watermark=True)
print(job)
print("task_id: %s" % job.task_id)
except DashScopeError as e:
print(f"HTTP返回码:{e.status_code}")
print(f"错误码:{e.code}")
print(f"错误信息:{e.message}")
print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")
return
# 等待异步任务结束(指数退避轮询,默认总预算24小时)
try:
done = client.videos.jobs.wait(job)
print(done)
print(done.video_url)
except DashScopeError as e:
print(f"HTTP返回码:{e.status_code}")
print(f"错误码:{e.code}")
print(f"错误信息:{e.message}")
print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")
if __name__ == '__main__':
sample_async_call_i2v()
Java SDK
Make sure the DashScope Java SDK version is no lower than
2.22.6. See Install SDK to update.
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;
public class Image2Video {
static {
// 以下为北京地域URL。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的URL不同,获取URL:https://help.aliyun.com/zh/model-studio/image-to-video-api-reference
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
}
// 若没有配置环境变量,请用百炼API Key将下行替换为:apiKey="sk-xxx"
// 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void image2video() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wanx2.1-i2v-turbo")
.imgUrl("https://cdn.translate.alibaba.com/r/wanx-demo-1.png")
.template("flying") /*模型特效*/
.resolution("720P")
.build();
// 异步调用
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("please wait...");
//获取结果
VideoSynthesisResult result = vs.wait(task, apiKey);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
image2video();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
curl
Step 1: Create a task to obtain the task ID# 以下为华北2(北京)地域的URL,调用时请将 {WorkspaceId} 替换为真实的业务空间ID,各地域的URL不同。
curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wanx2.1-i2v-turbo",
"input": {
"img_url": "https://cdn.translate.alibaba.com/r/wanx-demo-1.png",
"template": "flying"
},
"parameters": {
"resolution": "720P"
}
}'
Step 2: Get the result by task IDReplace {task_id} entirely with the value of task_id returned by the API in the previous step. The task_id can be queried within 24 hours. Also replace {WorkspaceId} with your actual Workspace ID.
curl -X GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
How to input images and audio
Input an image
- Number of images: 1.
- Input methods: Image URL, local file path, or Base64-encoded string.
Method 2: Local file path (SDK only)
The file path requirements differ slightly between Python and Java. Strictly follow the rules below to format the path.
Python SDK: Supports absolute and relative paths. The file path rules are as follows:
Operating system | Input file path | Example (absolute path) | Example (relative path) |
|---|---|---|---|
Linux / 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 absolute paths. The file path rules are as follows:
Operating system | Input file path | Example (absolute path) |
|---|---|---|
Linux / macOS | file://{absolute_path_of_the_file} | file:///home/images/test.png |
Windows | file:///{absolute_path_of_the_file} | file:///D:/images/test.png |
Method 3: Base64-encoded string (HTTP interface and SDK)
-
Example value:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABDg......(The example is truncated for demonstration purposes only). -
Format requirements: Follow the
data:{MIME_type};base64,{base64_data}format, where:-
{base64_data}: The Base64-encoded string of the image file.
-
{MIME_type}: The Multipurpose Internet Mail Extensions (MIME) type of the image. It 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
-
Example code: Three input methods
import base64
import os
import mimetypes
import dashscope
from dashscope import DashScopeError
# 以下为华北2(北京)地域的配置,调用时请将 {WorkspaceId} 替换为真实的业务空间ID,各地域的region取值不同。
client = dashscope.Client(
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
# 获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="cn-beijing",
)
# --- 辅助函数:用于 Base64 编码 ---
# 格式为 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编码 - 适合私有图片或需要加密传输的场景
"""
# 【方式一】使用公网可访问的图片URL
# 示例:使用一个公开的图片URL
img_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
# 【方式二】使用本地文件(支持绝对路径和相对路径)
# 格式要求:file:// + 文件路径
# 示例(绝对路径):
# img_url = "file://" + "/path/to/your/img.png" # Linux/macOS
# img_url = "file://" + "/C:/path/to/your/img.png" # Windows
# 示例(相对路径):
# img_url = "file://" + "./img.png" # 相对当前执行文件的路径
# 【方式三】使用Base64编码的图片
# img_url = encode_file("./img.png")
# 设置音频audio url
audio_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
def sample_call_i2v():
# generate 为一步式调用(提交任务并等待完成),返回已完成的 Job
print('please wait...')
# audio_url / negative_prompt 为 input 段字段,不在具名签名内,经 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返回码:{e.status_code}")
print(f"错误码:{e.code}")
print(f"错误信息:{e.message}")
print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")
if __name__ == '__main__':
sample_call_i2v()
// 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 {
// 以下为华北2(北京)地域的URL,调用时请将 {WorkspaceId} 替换为真实的业务空间ID,各地域的URL不同。
// 获取URL:https://help.aliyun.com/zh/model-studio/image-to-video-api-reference
Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
}
// 若没有配置环境变量,请用百炼API Key将下行替换为:apiKey="sk-xxx"
// 获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
/**
* 图像输入方式说明:三选一即可
*
* 1. 使用公网URL - 适合已有公开可访问的图片
* 2. 使用本地文件 - 适合本地开发测试
* 3. 使用Base64编码 - 适合私有图片或需要加密传输的场景
*/
//【方式一】公网URL
static String imgUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png";
//【方式二】本地文件路径(file://+绝对路径)
// static String imgUrl = "file://" + "/your/path/to/img.png"; // Linux/macOS
// static String imgUrl = "file://" + "/C:/your/path/to/img.png"; // Windows
//【方式三】Base64编码
// static String imgUrl = Image2Video.encodeFile("/your/path/to/img.png");
// 设置音频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 {
// 设置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));
}
/**
* 将文件编码为Base64字符串
* @param filePath 文件路径
* @return Base64字符串,格式为 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);
}
// 检测MIME类型
String mimeType = null;
try {
mimeType = Files.probeContentType(path);
} catch (IOException e) {
throw new IllegalArgumentException("无法检测文件类型: " + filePath);
}
if (mimeType == null || !mimeType.startsWith("image/")) {
throw new IllegalArgumentException("不支持或无法识别的图像格式");
}
// 读取文件内容并编码
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);
}
}
Input Audio
-
Number of audio files: One.
-
Input methods:
- Public URL: Supports the HTTP or HTTPS protocol.
- Temporary URL: Supports the OSS protocol. You must upload a file to obtain a temporary URL.
Output video
-
Number of videos: 1.
-
Output video specifications: Output specifications vary by model. For more information, see Scope.
-
Output video URL validity period: 24 hours.
-
Output video dimensions: Dimensions depend on the input image and the configured
resolution.- The model attempts to maintain the input image’s aspect ratio while scaling it to a total pixel count near the target value. To comply with encoding standards, the width and height must be multiples of 16. The model automatically fine-tunes the dimensions.
- For example: For an input image of 750 × 1000 pixels (aspect ratio 3:4 = 0.75) with resolution set to “720P” (target pixel count of about 920,000), the final output might be 816 × 1104 pixels (aspect ratio ≈ 0.739, total pixels ≈ 900,000). Both the width and height are multiples of 16.
Billing and throttling
-
For the model’s free quota and pricing, see Model pricing.
-
For model throttling, see Wan series.
-
Billing details:
- Inputs are not billed. Outputs are billed based on the duration in seconds of successfully generated videos.
- Failed model invocations or processing faults do not incur any fees and do not consume the free quota for new users.
- Image-to-video also supports savings plans.
API reference
Image-to-video (first frame) API reference
FAQ
Q: Why can’t I set the video aspect ratio directly (such as 16:9)?
A: The current API does not support setting the video aspect ratio directly. You can only configure the video resolution using the resolution parameter.
The resolution parameter controls the total number of pixels—not a fixed aspect ratio. The model preserves the original aspect ratio of the first input frame (approximately) and then fine-tunes it to meet video encoding requirements. Specifically, both the width and height must be multiples of 16.
Q: Why does the SDK code return “url error, please check url!”?
A: Make sure that:
- Your DashScope Python SDK version is at least 2.0.1.
- Your DashScope Java SDK version is at least
2.22.6.
If your SDK version is too low, you may see the “url error, please check url!” error. For instructions, see Upgrading the SDK.


