通义万相-图生视频模型根据首帧图像和文本提示词,生成一段流畅的视频。支持的能力包括:
基础能力:时长灵活(3-10秒)、指定视频分辨率、智能改写prompt、添加水印。
音频能力:支持自动配音,或传入自定义音频文件,实现音画同步。(仅wan2.5支持)
视频特效:部分模型内置“魔法悬浮”、“气球膨胀”等特效模板,可直接调用。
快速入口:通义万相官网在线体验 | 视频特效列表
通义万相官网的功能与API支持的能力可能存在差异,具体以API文档中列出的能力为准。如有新增功能,API文档会及时更新,敬请关注。
模型概览
输入首帧图像和音频 | 输出视频(wan2.5) |
输入音频: | |
输入提示词:一幅都市奇幻艺术的场景。一个充满动感的涂鸦艺术角色。一个由喷漆所画成的少年,正从一面混凝土墙上活过来。他一边用极快的语速演唱一首英文rap,一边摆着一个经典的、充满活力的说唱歌手姿势。场景设定在夜晚一个充满都市感的铁路桥下。灯光来自一盏孤零零的街灯,营造出电影般的氛围,充满高能量和惊人的细节。视频的音频部分完全由少年的rap构成,没有其他对话或杂音。 |
模型名称(model) | 模型简介 | 输出视频规格 |
wan2.5-i2v-preview | 万相2.5 preview(有声视频) 新增音频能力:支持自动配音,或传入自定义音频文件 | 分辨率档位:480P、720P、1080P 视频时长:5秒,10秒 固定规格:24fps、MP4 (H.264编码) |
wan2.2-i2v-flash | 万相2.2极速版(无声视频) 较2.1模型速度提升50% | 分辨率档位:480P、720P、1080P 视频时长:5秒 固定规格:30fps、MP4 (H.264编码) |
wan2.2-i2v-plus | 万相2.2专业版(无声视频) 较2.1模型稳定性与成功率全面提升 | 分辨率档位:480P、1080P 视频时长:5秒 固定规格:30fps、MP4 (H.264编码) |
wanx2.1-i2v-plus | 万相2.1专业版(无声视频) | 分辨率档位:720P 视频时长:5秒 固定规格:30fps、MP4 (H.264编码) |
wanx2.1-i2v-turbo | 万相2.1极速版(无声视频) | 分辨率档位:480P、720P 视频时长:3、4、5秒 固定规格:30fps、MP4 (H.264编码) |
调用前,请查阅各地域支持的模型列表与价格。
前提条件
在调用前,先获取API Key,再配置API Key到环境变量。如需通过SDK进行调用,请安装DashScope SDK。
北京和新加坡地域拥有独立的 API Key 与请求地址,不可混用,跨地域调用将导致鉴权失败或服务报错。
HTTP调用
由于图生视频任务耗时较长(通常为1-5分钟),API采用异步调用。整个流程包含 “创建任务 -> 轮询获取” 两个核心步骤,具体如下:
具体耗时受限于排队任务数和服务执行情况,请在获取结果时耐心等待。
步骤1:创建任务获取任务ID
北京地域:POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
新加坡地域:POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
创建成功后,使用接口返回的
task_id
查询结果,task_id 有效期为 24 小时。请勿重复创建任务,轮询获取即可。新手指引请参见Postman。
请求参数 | 自动配音仅 wan2.5-i2v-preview 支持。模型已默认开启自动配音功能,无需配置;如需显式声明,可将
传入音频文件仅wan2.5-i2v-preview支持。请通过
生成无声视频生成无声视频因模型版本而异:
使用Base64img_url 参数支持传入图像的 Base64 编码字符串。先下载img_base64文件,并将完整内容粘贴至 格式参见输入图像。
使用视频特效
使用反向提示词通过 negative_prompt 指定生成的视频避免出现“花朵”元素。
|
请求头(Headers) | |
Content-Type 请求内容类型。此参数必须设置为 | |
Authorization 请求身份认证。接口使用阿里云百炼API-Key进行身份认证。示例值:Bearer sk-xxxx。 | |
X-DashScope-Async 异步处理配置参数。HTTP请求只支持异步,必须设置为 重要 缺少此请求头将报错:“current user api does not support synchronous calls”。 | |
请求体(Request Body) | |
model 模型名称。示例值:wan2.2-i2v-plus。 模型列表与价格详见模型价格。 | |
input 输入的基本信息,如提示词等。 | |
parameters 视频处理参数,如设置视频分辨率、设置视频时长、开启prompt智能改写、添加水印等。 |
响应参数 | 成功响应请保存 task_id,用于查询任务状态与结果。
异常响应创建任务失败,请参见错误信息进行解决。
|
output 任务输出信息。 | |
request_id 请求唯一标识。可用于请求明细溯源和问题排查。 | |
code 请求失败的错误码。请求成功时不会返回此参数,详情请参见错误信息。 | |
message 请求失败的详细信息。请求成功时不会返回此参数,详情请参见错误信息。 |
步骤2:根据任务ID查询结果
GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
请求参数 | 查询任务结果请将
|
请求头(Headers) | |
Authorization 请求身份认证。接口使用阿里云百炼API-Key进行身份认证。示例值:Bearer sk-xxxx。 | |
URL路径参数(Path parameters) | |
task_id 任务ID。 |
响应参数 | 任务执行成功视频URL仅保留24小时,超时后会被自动清除,请及时保存生成的视频。
任务执行失败若任务执行失败,task_status将置为 FAILED,并提供错误码和信息。请参见错误信息进行解决。
任务查询过期task_id查询有效期为 24 小时,超时后将无法查询,返回以下报错信息。
|
output 任务输出信息。 | |
usage 输出信息统计,只对成功的结果计数。 | |
request_id 请求唯一标识。可用于请求明细溯源和问题排查。 |
DashScope SDK调用
SDK 的参数命名与HTTP接口基本一致,参数结构根据语言特性进行封装。
由于图生视频任务耗时较长(通常为1-5分钟),SDK 在底层封装了 HTTP 异步调用流程,支持同步、异步两种调用方式。
具体耗时受限于排队任务数和服务执行情况,请在获取结果时耐心等待。
Python SDK调用
Python SDK 支持三种图像输入方式:公网 URL、Base64 编码字符串、本地文件路径(绝对/相对),任选其一即可,具体参见输入图像。
推荐安装最新版DashScope Python SDK,否则可能运行报错:安装或升级SDK。
wan2.5-i2v-preview模型暂不支持SDK调用。
示例代码
同步调用
同步调用会阻塞等待,直到视频生成完成并返回结果。本示例展示三种图像输入方式:公网URL、Base64编码、本地文件路径。
请求示例
import base64
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import mimetypes
import dashscope
# 以下为北京地域url,若使用新加坡地域的模型,需将url替换为:https://dashscope-intl.aliyuncs.com/api/v1
dashscope.base_http_api_url = 'https://dashscope.aliyuncs.com/api/v1'
# 若没有配置环境变量,请用百炼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")
# --- 辅助函数:用于 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://cdn.translate.alibaba.com/r/wanx-demo-1.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")
def sample_call_i2v():
# 同步调用,直接返回结果
print('please wait...')
rsp = VideoSynthesis.call(api_key=api_key,
model='wan2.2-i2v-plus',
prompt='一只猫在草地上奔跑',
resolution="1080P",
img_url=img_url)
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()
响应示例
video_url 有效期24小时,请及时下载视频。
{
"status_code": 200,
"request_id": "a77bde74-d20a-97cb-8384-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "66ca2804-1e64-468f-b554-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/xxx.mp4?xxxxxx",
"submit_time": "2025-07-27 21:15:19.582",
"scheduled_time": "2025-07-27 21:15:19.613",
"end_time": "2025-07-27 21:18:00.047",
"orig_prompt": "一只猫在草地上奔跑",
"actual_prompt": "一只白猫在草地上奔跑,尾巴高高扬起,步伐轻快。"
},
"usage": {
"video_count": 1,
"video_duration": 0,
"video_ratio": "",
"duration": 5,
"SR": 1080
}
}
异步调用
本示例展示异步调用方式。该方式会立即返回任务ID,需要自行轮询或等待任务完成。
请求示例
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
# 以下为北京地域url,若使用新加坡地域的模型,需将url替换为:https://dashscope-intl.aliyuncs.com/api/v1
dashscope.base_http_api_url = 'https://dashscope.aliyuncs.com/api/v1'
# 若没有配置环境变量,请用百炼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")
# 使用公网可访问的图片URL
img_url = "https://cdn.translate.alibaba.com/r/wanx-demo-1.png"
def sample_async_call_i2v():
# 异步调用,返回一个task_id
rsp = VideoSynthesis.async_call(api_key=api_key,
model='wan2.2-i2v-plus',
prompt='一只猫在草地上奔跑',
resolution="1080P",
img_url=img_url)
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))
# 获取异步任务信息
status = VideoSynthesis.fetch(rsp)
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))
# 等待异步任务结束
rsp = VideoSynthesis.wait(rsp)
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()
响应示例
1、创建任务的响应示例
{
"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、查询任务结果的响应示例
video_url 有效期24小时,请及时下载视频。
{
"status_code": 200,
"request_id": "a77bde74-d20a-97cb-8384-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "66ca2804-1e64-468f-b554-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/xxx.mp4?xxxxxx",
"submit_time": "2025-07-27 21:15:19.582",
"scheduled_time": "2025-07-27 21:15:19.613",
"end_time": "2025-07-27 21:18:00.047",
"orig_prompt": "一只猫在草地上奔跑",
"actual_prompt": "一只白猫在草地上奔跑,尾巴高高扬起,步伐轻快。"
},
"usage": {
"video_count": 1,
"video_duration": 0,
"video_ratio": "",
"duration": 5,
"SR": 1080
}
}
Java SDK调用
Java SDK 支持三种图像输入方式:公网 URL、Base64 编码字符串、本地文件路径(绝对路径),任选其一即可,具体参见输入图像。
推荐安装最新版DashScope Java SDK,否则可能运行报错:安装或升级SDK。
wan2.5-i2v-preview模型暂不支持SDK调用。
示例代码
同步调用
同步调用会阻塞等待,直到视频生成完成并返回结果。本示例展示三种图像输入方式:公网URL、Base64编码、本地文件路径。
请求示例
// 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;
/**
* 环境要求
* dashscope java SDK >= 2.20.9
* 更新maven依赖:
* https://mvnrepository.com/artifact/com.alibaba/dashscope-sdk-java
*/
public class Image2Video {
static {
// 以下为北京地域url,若使用新加坡地域的模型,需将url替换为:https://dashscope-intl.aliyuncs.com/api/v1
Constants.baseHttpApiUrl = "https://dashscope.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");
/**
* 图像输入方式说明:三选一即可
*
* 1. 使用公网URL - 适合已有公开可访问的图片
* 2. 使用本地文件 - 适合本地开发测试
* 3. 使用Base64编码 - 适合私有图片或需要加密传输的场景
*/
//【方式一】公网URL
static String imgUrl = "https://cdn.translate.alibaba.com/r/wanx-demo-1.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");
public static void image2video() throws ApiException, NoApiKeyException, InputRequiredException {
// 设置parameters参数
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
VideoSynthesis vs = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.2-i2v-plus")
.prompt("一只猫在草地上奔跑")
.imgUrl(imgUrl)
.parameters(parameters)
.resolution("1080P")
.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);
}
}
响应示例
video_url 有效期24小时,请及时下载视频。
{
"request_id": "3171aa20-c479-9dc2-ae55-xxxxxx",
"output": {
"task_id": "8b61b356-45ad-45f3-9be2-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?xxxxxx"
},
"usage": {
"video_count": 1,
"video_duration": 5,
"video_ratio": "standard"
}
}
异步调用
本示例展示异步调用方式。该方式会立即返回任务ID,需要自行轮询或等待任务完成。
请求示例
// 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;
/**
* 环境要求
* dashscope java SDK >= 2.20.1
* 更新maven依赖:
* https://mvnrepository.com/artifact/com.alibaba/dashscope-sdk-java
*/
public class Image2Video {
static {
// 以下为北京地域url,若使用新加坡地域的模型,需将url替换为:https://dashscope-intl.aliyuncs.com/api/v1
Constants.baseHttpApiUrl = "https://dashscope.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");
static String imgUrl = "https://cdn.translate.alibaba.com/r/wanx-demo-1.png";
public static void image2video() throws ApiException, NoApiKeyException, InputRequiredException {
// 设置parameters参数
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
VideoSynthesis vs = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wanx2.1-i2v-turbo")
.prompt("一只猫在草地上奔跑")
.imgUrl(imgUrl)
.parameters(parameters)
.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 listTask() throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
AsyncTaskListParam param = AsyncTaskListParam.builder().build();
VideoSynthesisListResult result = is.list(param);
System.out.println(result);
}
// 获取单个任务结果
public void fetchTask(String taskId) throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
// 如果已设置 DASHSCOPE_API_KEY 为环境变量,apiKey 可为空。
VideoSynthesisResult result = is.fetch(taskId, null);
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);
}
}
响应示例
1、创建任务的响应示例
{
"request_id": "5dbf9dc5-4f4c-9605-85ea-xxxxxxxx",
"output": {
"task_id": "7277e20e-aa01-4709-xxxxxxxx",
"task_status": "PENDING"
}
}
2、查询任务结果的响应示例
video_url 有效期24小时,请及时下载视频。
{
"request_id": "3d740fc4-a968-9c36-b0e7-xxxxxxxx",
"output": {
"task_id": "34dcf4b0-ed84-441e-91cb-xxxxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-hz.oss-cn-hangzhou.aliyuncs.com/xxx.mp4?xxxxxx"
},
"usage": {
"video_count": 1,
"video_duration": 5,
"video_ratio": "standard"
}
}
使用限制
数据时效:任务task_id和 视频url均只保留 24 小时,过期后将无法查询或下载。
音频支持:wan2.5 支持有声视频(自动配音或上传自定义音频)。wan2.2 及以下版本仅输出无声视频,如有需要,可通过语音合成生成音频。
内容审核:输入 prompt 和视频、输出视频均会经过内容安全审核,含违规内容将返回 “IPInfringementSuspect”或“DataInspectionFailed”错误,详见参见错误信息。
网络访问配置:视频链接存储于阿里云 OSS,如果业务系统因安全策略无法访问外部OSS链接,请将以下 OSS 域名加入网络访问白名单。
# OSS域名列表 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
关键参数说明
输入图像
输入图像 img_url
参数支持以下三种方式传入:
方式一:公网URL
一个公网可直接访问的地址,支持 HTTP/HTTPS。本地文件可通过上传文件获取临时URL。
示例值:
https://example.com/images/cat.png
。
方式二:Base 64编码
示例值:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABDg......
(因长度限制仅展示片段)。调用时,需传入完整字符串。编码格式:遵循
data:{MIME_type};base64,{base64_data}
的格式,其中:{base64_data}:图像文件经过 Base64 编码后的字符串。
{MIME_type}:图像的媒体类型,需与文件格式对应。
图像格式
MIME Type
JPEG
image/jpeg
JPG
image/jpeg
PNG
image/png
BMP
image/bmp
WEBP
image/webp
方式三:本地文件路径(仅限 SDK)
Python SDK:支持传入文件的绝对路径和相对路径。文件路径规则如下:
系统
传入的文件路径
示例(绝对路径)
示例(相对路径)
Linux或macOS系统
file://{文件的绝对路径或相对路径}
file:///home/images/test.png
file://./images/test.png
Windows系统
file://D:/images/test.png
file://./images/test.png
Java SDK:仅支持传入文件的绝对路径。文件路径规则如下:
系统
传入的文件路径
示例(绝对路径)
Linux或macOS系统
file://{文件的绝对路径}
file:///home/images/test.png
Windows系统
file:///{文件的绝对路径}
file:///D:/images/test.png
音频设置
支持的模型:wan2.5-i2v-preview。
音频设置:通过input.audio_url
和 parameters.audio
参数组合控制音频行为,参数优先级:audio_url > audio
。支持三种模式:
生成无声视频
参数设置:不传audio_url,且 audio 为 false。
适用场景:纯视觉内容展示,后期自行添加音频或配乐。
自动生成音频
参数设置:不传audio_url,且 audio 为 true。
效果说明:模型根据提示词和画面内容,自动生成匹配的背景音频或音乐。
使用自定义音频
参数设置:传入 audio_url(此时 audio参数无效)。
效果说明:视频画面会与音频内容对齐(如口型、节奏等)。
计费与限流
错误码
如果模型调用失败并返回报错信息,请参见错误信息进行解决。
常见问题
视频FAQ快速入口:常见问题。
Q:如何生成特定宽高比(如9:16)的视频?
A: 输出视频的宽高比完全由输入的首帧图像 img_url 决定。例如,要生成 9:16 的竖屏视频,必须提供一张 9:16 比例的输入图片。resolution 参数仅用于调整视频的清晰度(总像素),不会改变其宽高比。
附录
图生视频基础功能示例
模型功能 | 输入首帧图像 | 输入提示词 | 输出视频 |
无声视频 | 一只猫在草地上奔跑 | ||
视频特效 | 输入特效参数:“template:flying” | 无 | “魔法悬浮”特效 |