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
复制
import dashscope
import os
from dashscope.v2 import DashScopeError
# 若没有配置环境变量,请用千问AI平台API Key将下行替换为:api_key="sk-xxx"
# 获取API Key:https://platform.qianwenai.com/home/api-keys
client = dashscope.Client(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://maas.qianwenaiapi.com/api/v1",
)
def sample_async_call():
# 异步提交视频生成任务
try:
job = client.videos.jobs.create(
model='MiniMax/MiniMax-H3',
prompt='史诗级太空歌剧院线预告:女舰长独自站在巨大观景窗前,最后一支舰队正在集结并跃迁离去,强光爆闪、舰桥震动,她被留在原地。',
resolution='768P',
ratio='16:9',
duration=5,
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("请参考文档:/api-reference/preparation/error-messages")
return
# 查询任务状态
try:
snapshot = client.videos.jobs.fetch(job.task_id)
print(snapshot.status)
except DashScopeError as e:
print(f"HTTP返回码:{e.status_code}")
print(f"错误码:{e.code}")
print(f"错误信息:{e.message}")
print("请参考文档:/api-reference/preparation/error-messages")
# 等待任务完成(指数退避轮询,默认总预算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("请参考文档:/api-reference/preparation/error-messages")
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