minimax-video-h3-max API

MiniMax H3-Max 影片生成:文生影片、首幀/首尾幀圖生影片,480P / 768P,5–15 秒(不足 5 秒按 5 秒生成並計費),按秒計費。

POST /v1/videos/generations

支援文生影片、首幀圖生影片與首尾幀生影片,480P / 768P,5–15 秒。

文生视频

必填参数: model, prompt, resolution

可用参数: model, prompt, content, resolution, duration, ratio, aspect_ratio, aigc_watermark, wait, idempotency_key

首帧图生视频

必填参数: model, first_frame_url, resolution

可用参数: model, prompt, content, resolution, duration, ratio, aspect_ratio, aigc_watermark, wait, idempotency_key, first_frame_url

首尾帧生视频

必填参数: model, first_frame_url, last_frame_url, resolution

可用参数: model, prompt, content, resolution, duration, ratio, aspect_ratio, aigc_watermark, wait, idempotency_key, first_frame_url, last_frame_url

请求参数

参数类型必填说明
modelstring是模型 ID。 可选: minimax-video-h3-max
promptstring否文字提示词,描述画面内容与运动。文生视频必填;图生视频可选,用来描述画面如何变化。也可以改用 content 数组传入(传了 content 时以 content 为准)。
resolutionstring是输出分辨率,必填,大小写均可。仅支持 480P / 768P,请勿传 720P、1080P、2K 等其他取值。 可选: 480P / 768P
durationinteger否视频时长(秒),5–15 的整数,默认 5。不足 5 秒按 5 秒生成并计费。
ratiostring否画面比例。文生视频不传时默认 16:9;图生视频不传时跟随首帧图片的比例。 可选: 16:9 / 9:16 / 1:1 / 4:3 / 3:4 / 21:9
first_frame_urlstring否首帧图片 URL,视频从这张图开始。
last_frame_urlstring否尾帧图片 URL,需与 first_frame_url 一起传,视频从首帧过渡到尾帧。
contentarray否原生输入数组,可代替 prompt / first_frame_url / last_frame_url(传了 content 时这三个字段不再生效)。元素类型: - 文字:{ "type": "text", "text": "..." } - 图片:{ "type": "image_url", "image_url": { "url": "..." }, "role": "first_frame" | "last_frame" } 最多 2 张图片(首帧、尾帧各 1 张);不支持参考图 / 参考视频 / 参考音频。
aspect_ratiostring否与 ratio 等价,传其一即可;同时传时以 ratio 为准。
aigc_watermarkboolean否是否在视频中添加 AIGC 生成标识水印,默认不加。
waitboolean否true 时最长等待约 60 秒:期间生成完成则直接返回结果,否则返回进行中的任务,需再用查询接口获取。建议使用默认的异步方式。
idempotency_keystring否幂等键:同一个键重复提交返回同一个任务,不会重复创建和计费。
## 完整示例(Python) 提交任务 → 轮询结果 → 下载视频: ```python import time import requests API_KEY = "sk-你的令牌" BASE = "https://api.router.ai/v1/videos/generations" headers = {"Authorization": f"Bearer {API_KEY}"} # 1) 提交任务 resp = requests.post(BASE, headers=headers, json={ "model": "minimax-video-h3-max", "prompt": "一只橙色小猫坐在窗台上,慢慢转头看向镜头,午后阳光", "resolution": "768P", "duration": 5, "ratio": "16:9", }) resp.raise_for_status() task_id = resp.json()["id"] # 2) 每 10 秒查询一次,直到结束 while True: task = requests.get(f"{BASE}/{task_id}", headers=headers).json() if task["status"] in ("succeeded", "failed", "timeout"): break time.sleep(10) # 3) 下载视频(链接 12 小时内有效) if task["status"] == "succeeded": url = task["task"]["content"]["url"] with open("output.mp4", "wb") as f: f.write(requests.get(url).content) print("已保存 output.mp4") else: print("生成失败:", task.get("error")) ``` ## 生成失败时的查询结果 ```json { "id": "vt_7f3c2a9e5b1d4c8a9e0b7d6e5f4a3b2c", "model": "minimax-video-h3-max", "status": "failed", "created_at": 1791734400, "error": { "code": "failed", "message": "<失败原因>" } } ``` **失败或超时的任务不收费。** ## 任务状态 | 状态 | 含义 | |---|---| | `pending` / `submitted` / `processing` | 进行中,继续查询 | | `succeeded` | 生成成功,视频地址在 `task.content.url` | | `failed` | 生成失败,原因见 `error.message` | | `timeout` | 生成超时 |

请求示例

# 1) 提交任务:返回 202 和任务 id
curl https://api.router.ai/v1/videos/generations \
  -H "Authorization: Bearer sk-你的令牌" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "minimax-video-h3-max",
    "prompt": "一只橙色小猫坐在窗台上,慢慢转头看向镜头,午后阳光",
    "resolution": "768P",
    "duration": 5,
    "ratio": "16:9"
  }'

# 2) 查询结果:用上一步返回的 id,每 10 秒查一次,
#    直到 status 为 succeeded(成功)或 failed / timeout(失败)
curl https://api.router.ai/v1/videos/generations/vt_7f3c2a9e5b1d4c8a9e0b7d6e5f4a3b2c \
  -H "Authorization: Bearer sk-你的令牌"

接口通用说明: 提交影片任務