Skip to content

Videos

/v1/videos 用于创建和管理 OpenAI 兼容的视频生成任务。

创建视频任务

text
POST https://mux.la/v1/videos

请求示例

bash
curl https://mux.la/v1/videos \
  -H "Authorization: Bearer sk-xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2",
    "prompt": "A calico cat playing a piano on stage",
    "seconds": "8",
    "size": "1280x720"
  }'

常用请求字段

字段必填说明
model视频模型名称
prompt视频生成提示词
seconds视频时长
size输出尺寸

查询任务状态

text
GET https://mux.la/v1/videos/{video_id}
bash
curl https://mux.la/v1/videos/video_123 \
  -H "Authorization: Bearer sk-xxxxxxxxxxxx"

处理中

json
{
  "id": "video_123",
  "object": "video",
  "status": "processing",
  "progress": 42,
  "created_at": 1712697600,
  "model": "sora-2",
  "prompt": "A calico cat playing a piano on stage",
  "seconds": "8",
  "size": "1280x720"
}

完成

json
{
  "id": "video_123",
  "object": "video",
  "status": "completed",
  "progress": 100,
  "created_at": 1712697600,
  "completed_at": 1712701415,
  "model": "sora-2",
  "prompt": "A calico cat playing a piano on stage",
  "seconds": "8",
  "size": "1280x720"
}

失败

json
{
  "id": "video_123",
  "object": "video",
  "status": "failed",
  "progress": 12,
  "created_at": 1712697600,
  "model": "sora-2",
  "seconds": "8",
  "size": "1280x720",
  "error": {
    "code": "invalid_reference_image",
    "message": "Input images with human faces are currently rejected."
  }
}

下载视频内容

默认返回 MP4 视频内容,也支持通过 variant 查询不同下载内容:

参数说明
variant=video下载视频文件,默认值
variant=thumbnail下载缩略图
variant=spritesheet下载 spritesheet

下载视频

bash
curl https://mux.la/v1/videos/video_123/content \
  -H "Authorization: Bearer sk-xxxxxxxxxxxx" \
  --output video.mp4

下载缩略图

bash
curl "https://mux.la/v1/videos/video_123/content?variant=thumbnail" \
  -H "Authorization: Bearer sk-xxxxxxxxxxxx" \
  --output thumbnail.webp

可选:Webhook 回调

如果不想轮询,也可以配置 webhook 接收任务结果通知。视频任务常见事件包括:

  • video.completed
  • video.failed

示例回调:

json
{
  "id": "evt_abc123",
  "object": "event",
  "created_at": 1758941485,
  "type": "video.completed",
  "data": {
    "id": "video_abc123"
  }
}