POST
/services/aigc/video-generation/video-synthesis
复制
curl --location 'https://maas.qianwenaiapi.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": "MiniMax/MiniMax-H3",
"input": {
"prompt": "Epic space opera trailer: a female captain stands alone before a giant observation window, the last fleet assembles and jumps away, bright flashes, bridge shakes, she is left behind."
},
"parameters": {
"resolution": "768P",
"ratio": "16:9",
"duration": 5,
"watermark": true
}
}'复制
{
"request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx",
"output": {
"task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx",
"task_status": "PENDING"
}
}- 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='MiniMax/MiniMax-H3',
prompt='史诗级太空歌剧院线预告:女舰长独自站在巨大观景窗前,最后一支舰队正在集结并跃迁离去,强光爆闪、舰桥震动,她被留在原地。',
resolution='768P',
ratio='16:9',
duration=5,
watermark=True)
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,表示异步提交任务。缺少此请求头将报错:"current user api does not support synchronous calls"。
可选值:enable
请求体
application/jsonenum<string>
必填
模型名称。固定值:MiniMax/MiniMax-H3。
可选值:MiniMax/MiniMax-H3
示例:MiniMax/MiniMax-H3
object
必填
输入信息。
显示子属性
显示子属性
string
必填
文本提示词,用来描述期望生成的视频内容。支持中英文,不超过 7000 个字符,超过部分会自动截断。
示例:Epic space opera trailer: a female captain stands alone before a giant observation window, the last fleet assembles and jumps away, bright flashes, bridge shakes, she is left behind.
取值范围:length <= 7000