POST
/services/aigc/image2video/video-synthesis
cURL
复制
curl 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis/' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model": "wan2.2-s2v",
"input": {
"image_url": "https://img.alicdn.com/imgextra/i3/O1CN011FObkp1T7Ttowoq4F_!!6000000002335-0-tps-1440-1797.jpg",
"audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250825/iaqpio/input_audio.MP3"
},
"parameters": {
"resolution": "480P"
}
}'复制
{
"output": {
"task_id": "a8532587-fa8c-4ef8-82be-xxxxxx",
"task_status": "PENDING"
},
"request_id": "7574ee8f-38a3-4b1e-9280-xxxxxx"
}请先获取 API Key 并配置为环境变量。
- Python SDK
复制
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# 若没有配置环境变量,请用千问AI平台API Key将下行替换为:api_key="sk-xxx"
# 获取API Key:https://platform.qianwenai.com/home/api-keys
api_key = os.getenv("DASHSCOPE_API_KEY")
def sample_async_call():
# 异步提交视频生成任务
rsp = VideoSynthesis.async_call(api_key=api_key,
model='wan2.2-s2v',
img_url='https://img.alicdn.com/imgextra/i3/O1CN011FObkp1T7Ttowoq4F_!!6000000002335-0-tps-1440-1797.jpg',
audio_url='https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250825/iaqpio/input_audio.MP3',
resolution='480P')
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(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))
# 等待任务完成
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()
鉴权
string
header
必填
千问AI平台 API Key。详见获取 API Key。
Header 参数
enum<string>
必填
固定值为 enable,表示使用异步调用方式。
可选值:enable
请求体
application/jsonenum<string>
必填
指明需要调用的模型。
可选值:wan2.2-s2v
示例:wan2.2-s2v
object
必填
显示子属性
显示子属性
string
必填
上传的图片 URL。
- 图像格式:支持 jpg、jpeg、png、bmp、webp。
- 图像分辨率:图像的宽度和高度范围为 [400, 7000] 像素。
- 仅支持公网可访问的 HTTP/HTTPS 链接。本地文件可通过上传文件获取临时URL。
示例:http://aaa/bbb.jpg
string
必填
上传的音频文件 URL。
- 音频格式:支持 wav、mp3。
- 音频限制:文件 < 15M,时长 < 20s。
- 音频内容:需包含清晰、响亮的人声语音,并去除环境噪音、背景音乐等干扰。
- 仅支持公网可访问的 HTTP/HTTPS 链接。本地文件可通过上传文件获取临时URL。
示例:http://aaa/bbb.mp3