花椰菜 · 文档

视频生成

网关挂载 POST /v1/videos/generations(别名 POST /v1/videos)。视频是异步任务:先提交拿 id,再轮询状态,完成后下载成品。无密钥返回 401 API_KEY_REQUIRED。

支持的模型

模型 ID说明
minimax-h3-videoMiniMax H3 文生视频,推荐使用
minimax-h3同一能力的别名,等价

需要选用带视频能力的分组(控制台「创建密钥」里选「视频 H3」),模型列表用 GET /v1/models 自查。

1. 提交任务

curl -sS https://xshell.club/v1/videos/generations \
  -H "Authorization: Bearer sk-YOUR-KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "minimax-h3-video",
    "prompt": "海面泛起轻柔的波浪,镜头缓慢向前推进,写实电影风格",
    "duration": 4,
    "aspect_ratio": "16:9",
    "resolution": "720p"
  }'

成功返回任务编号,请立即保存:

{"id": "task_xxxxxxxx", "status": "pending"}

2. 查询任务

curl -sS https://xshell.club/v1/videos/TASK_ID \
  -H "Authorization: Bearer sk-YOUR-KEY"

status 为 pending 时继续等待(建议每 5 秒一次);done 时 video.url 是成品地址;failed 停止轮询。

{"id": "task_xxxxxxxx", "status": "done", "model": "minimax-h3-video",
 "video": {"url": "/v1/videos/task_xxxxxxxx/content"}}

失败任务不计费;重复查询同一个已完成任务不会重复扣费。重新提交属于新任务,会再次计费。

3. 下载视频

curl -sS -L "https://xshell.club/v1/videos/TASK_ID/content" \
  -H "Authorization: Bearer sk-YOUR-KEY" \
  --output out.mp4

成品在站内保存 6 小时,请及时下载另行保存。

请求参数

参数必填取值
model是minimax-h3-video 或 minimax-h3
prompt是非空文本描述
duration否整数 3–15 秒,默认 4
aspect_ratio否16:9(默认)或 9:16
resolution否720p(默认)或 1080p

本线路不提供 480p 与 2K 档:480p 会按 720p 出片并按 720p 计费,2k 会被拒绝并返回 400。请只使用 720p / 1080p。

价格

按秒计费:720p $0.09 / 秒,1080p $0.16 / 秒。3 秒 720p 即 $0.27。实际单价以控制台对应分组页显示为准。

客户端示例(Python)

import time, requests

BASE = "https://xshell.club"
H = {"Authorization": "Bearer sk-YOUR-KEY", "Content-Type": "application/json"}

task = requests.post(BASE + "/v1/videos/generations", headers=H, json={
    "model": "minimax-h3-video",
    "prompt": "夜色中的城市天际线,延时摄影",
    "duration": 4,
    "aspect_ratio": "16:9",
    "resolution": "720p",
}, timeout=120).json()
task_id = task["id"]
print("task:", task_id)

while True:
    data = requests.get(f"{BASE}/v1/videos/{task_id}", headers=H, timeout=60).json()
    if data["status"] == "done":
        url = BASE + data["video"]["url"]
        with requests.get(url, headers=H, stream=True, timeout=300) as r:
            with open("out.mp4", "wb") as fh:
                for chunk in r.iter_content(65536):
                    fh.write(chunk)
        print("saved out.mp4")
        break
    if data["status"] == "failed":
        raise SystemExit("generation failed")
    time.sleep(5)

返回文档首页