OpenAI 视频格式
Ce contenu n’est pas encore disponible dans votre langue.
OpenAI 视频格式
Section titled “OpenAI 视频格式”本页总览
OpenAI 视频格式
Section titled “OpenAI 视频格式”调用OpenAI视频生成接口生成视频,支持 Sora 等模型,也支持使用 OpenAI 视频格式调用可灵,即梦和 vidu。
API 端点
Section titled “API 端点”POST /v1/videos| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Authorization | string | 是 | 用户认证令牌 (Bearer: sk-xxxx) |
| Content-Type | string | 是 | 本地文件使用 multipart/form-data;URL/Base64 JSON 使用 application/json |
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| prompt | string | 是 | 描述要生成视频的文本提示词 |
| model | string | 否 | 视频生成模型,默认为 sora-2 |
| seconds | string | 否 | 视频时长(秒),默认为 4 秒 |
| size | string | 否 | 输出分辨率,格式为宽度x高度,默认为 720x1280 |
| input_reference | file | 否 | 可选图片参考,用于指导生成 |
| duration | integer | 否 | Grok 视频时长,1–15 秒 |
| resolution | string | 否 | Grok 输出档位,例如 480p、720p |
curl https://你的4All API服务器地址/v1/videos \ -H "Authorization: Bearer sk-xxxx" \ -F "model=sora-2" \ -F "prompt=A calico cat playing a piano on stage"Grok Imagine Video 1.5 请求规范
Section titled “Grok Imagine Video 1.5 请求规范”本站入口保持 OpenAI Videos API 的 /v1/videos 路径,并在内部转换成 xAI
原生 JSON。两种格式的请求头和字段不要混用。
上传本地首帧图片
Section titled “上传本地首帧图片”本地文件使用 OpenAI 的 input_reference 字段。不要手动设置
Content-Type,curl 会自动生成包含正确 boundary 的 multipart 请求头。
curl https://api.4allapi.com/v1/videos \ -H "Authorization: Bearer $API_KEY" \ -F "model=grok-imagine-video-1.5" \ -F "prompt=女孩在暖色书吧中寻找一本书,电影 MV 镜头" \ -F "duration=15" \ -F "resolution=480p" \ -F "input_reference=@girl.png;type=image/png"实际请求头形态:
Authorization: Bearer YOUR_API_KEYContent-Type: multipart/form-data; boundary=<由客户端自动生成>使用公网 URL 或 Base64
Section titled “使用公网 URL 或 Base64”URL 和 data URI 使用 JSON:
curl https://api.4allapi.com/v1/videos \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "grok-imagine-video-1.5", "prompt": "让瀑布奔流,镜头缓慢拉远", "duration": 12, "resolution": "720p", "image": {"url": "https://example.com/waterfall.png"} }'image.url 支持公网 HTTPS URL 或 data:image/png;base64,...。本站还接受
OpenAI 兼容对象 input_reference.image_url,并转换为 xAI 的 image.url。
xAI 原生格式(内部转换目标)
Section titled “xAI 原生格式(内部转换目标)”xAI 原生提交端点为 POST https://api.x.ai/v1/videos/generations,请求头为:
Authorization: Bearer XAI_API_KEYContent-Type: application/json首帧字段必须是 "image":{"url":"..."};多张非首帧参考图片使用
reference_images。xAI 原生端点不接收 OpenAI 的 multipart 文件字段,因此
本站会把上传文件编码为 image.url=data:<mime>;base64,... 后再转发。
不要发送“JSON 内容 + multipart 请求头”。本站兼容层会纠正历史请求中的这种
错配,但新接入必须让 Content-Type 与真实请求体一致。
规范来源:OpenAI Videos API、 xAI Image-to-Video、 xAI Reference-to-Video。
200 - 成功响应
Section titled “200 - 成功响应”{ "id": "video_123", "object": "video", "model": "sora-2", "status": "queued", "progress": 0, "created_at": 1712697600, "size": "1024x1808", "seconds": "8", "quality": "standard"}响应字段说明
Section titled “响应字段说明”| 字段 | 类型 | 描述 |
|---|---|---|
| id | string | 视频任务ID |
| object | string | 对象类型,固定为 “video” |
| model | string | 使用的模型名称 |
| status | string | 任务状态(queued: 排队中, processing: 处理中, completed: 完成, failed: 失败) |
| progress | integer | 处理进度(0-100) |
| created_at | integer | 创建时间戳 |
| size | string | 视频分辨率 |
| seconds | string | 视频时长(秒) |
| quality | string | 视频质量 |
根据任务ID查询视频生成任务的状态和结果
API 端点
Section titled “API 端点”GET /v1/videos/{video_id}| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| video_id | string | 是 | 视频任务ID |
curl 'https://你的4All API服务器地址/v1/videos/video_123' \ -H "Authorization: Bearer sk-xxxx"200 - 成功响应
Section titled “200 - 成功响应”{ "id": "video_123", "object": "video", "model": "sora-2", "status": "completed", "progress": 100, "created_at": 1712697600, "size": "1024x1808", "seconds": "8", "quality": "standard", "url": "https://example.com/video.mp4"}响应字段说明
Section titled “响应字段说明”| 字段 | 类型 | 描述 |
|---|---|---|
| id | string | 视频任务ID |
| object | string | 对象类型,固定为 “video” |
| model | string | 使用的模型名称 |
| status | string | 任务状态(queued: 排队中, processing: 处理中, completed: 完成, failed: 失败) |
| progress | integer | 处理进度(0-100) |
| created_at | integer | 创建时间戳 |
| size | string | 视频分辨率 |
| seconds | string | 视频时长(秒) |
| quality | string | 视频质量 |
| url | string | 视频下载链接(完成时) |
获取视频任务状态
Section titled “获取视频任务状态”根据任务ID获取视频生成任务的详细信息
API 端点
Section titled “API 端点”GET /v1/videos/{video_id}| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| video_id | string | 是 | 要获取的视频任务标识符 |
curl 'https://你的4All API服务器地址/v1/videos/video_123' \ -H "Authorization: Bearer sk-xxxx"200 - 成功响应
Section titled “200 - 成功响应”{ "id": "video_123", "object": "video", "model": "sora-2", "status": "completed", "progress": 100, "created_at": 1712697600, "completed_at": 1712698000, "expires_at": 1712784400, "size": "1024x1808", "seconds": "8", "quality": "standard", "remixed_from_video_id": null, "error": null}响应字段说明
Section titled “响应字段说明”| 字段 | 类型 | 描述 |
|---|---|---|
| id | string | 视频任务的唯一标识符 |
| object | string | 对象类型,固定为 “video” |
| model | string | 生成视频的模型名称 |
| status | string | 视频任务的当前生命周期状态 |
| progress | integer | 生成任务的近似完成百分比 |
| created_at | integer | 任务创建时的Unix时间戳(秒) |
| completed_at | integer | 任务完成时的Unix时间戳(秒),如果已完成 |
| expires_at | integer | 可下载资源过期时的Unix时间戳(秒),如果已设置 |
| size | string | 生成视频的分辨率 |
| seconds | string | 生成视频片段的时长(秒) |
| quality | string | 视频质量 |
| remixed_from_video_id | string | 如果此视频是混音,则为源视频的标识符 |
| error | object | 如果生成失败,则包含错误信息的对象 |
获取视频内容
Section titled “获取视频内容”下载已完成的视频内容
API 端点
Section titled “API 端点”GET /v1/videos/{video_id}/content| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| video_id | string | 是 | 要下载的视频标识符 |
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| variant | string | 否 | 要返回的可下载资源类型,默认为MP4视频 |
curl 'https://你的4All API服务器地址/v1/videos/video_123/content' \ -H "Authorization: Bearer sk-xxxx" \ -o "video.mp4"200 - 成功响应
Section titled “200 - 成功响应”直接返回视频文件流,Content-Type为 video/mp4
| 字段 | 类型 | 描述 |
|---|---|---|
| Content-Type | string | 视频文件类型,通常为 video/mp4 |
| Content-Length | string | 视频文件大小(字节) |
| Content-Disposition | string | 文件下载信息 |
400 - 请求参数错误
Section titled “400 - 请求参数错误”{ "error": { "message": "Invalid request parameters", "type": "invalid_request_error", "code": "invalid_parameter" }}401 - 未授权
Section titled “401 - 未授权”{ "error": { "message": "Invalid API key", "type": "authentication_error", "code": "invalid_api_key" }}403 - 无权限
Section titled “403 - 无权限”{ "error": { "message": "Insufficient permissions", "type": "permission_error", "code": "insufficient_permissions" }}429 - 请求频率限制
Section titled “429 - 请求频率限制”{ "error": { "message": "Rate limit exceeded", "type": "rate_limit_error", "code": "rate_limit_exceeded" }}500 - 服务器内部错误
Section titled “500 - 服务器内部错误”{ "error": { "message": "Internal server error", "type": "server_error", "code": "internal_error" }}