外观
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.completedvideo.failed
示例回调:
json
{
"id": "evt_abc123",
"object": "event",
"created_at": 1758941485,
"type": "video.completed",
"data": {
"id": "video_abc123"
}
}