通用开放接口视频 API
POST /v1/videos
POST
/v1/videos创建视频任务。
鉴权:Bearer Token
Content-Type:application/json 或 multipart/form-data
请求体(JSON)
{ "model": "sora-2", "prompt": "A cinematic shot of a cat walking on the beach at sunset, soft ocean waves, warm golden lighting", "size": "1280x720", "seconds": 8}请求字段
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 视频模型名 |
prompt | string | 是 | 视频描述(≤ 2500 字符) |
size | string | 条件 | 分辨率,如 1280x720、720x1280;sora-2 等模型必填 |
seconds | int / string | 条件 | 时长(秒);sora-2 允许 4/8/12/16/20 |
input_reference | object / file | 否 | 参考图 |
带参考图(JSON URL):
{ "model": "sora-2", "prompt": "动态化这张图,轻微镜头移动", "size": "1280x720", "seconds": 8, "input_reference": { "image_url": "https://example.com/ref.jpg" }}带参考图(Base64 data URI):
{ "model": "sora-2", "prompt": "动态化这张图,轻微镜头移动", "size": "1280x720", "seconds": 8, "input_reference": { "image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRg..." }}multipart/form-data:input_reference 为 file 类型表单字段,其余字段同名。
请求示例(curl)
JSON:
curl https://www.yunsell.com/v1/videos \ -H "Authorization: Bearer sk-xxx" \ -H "Content-Type: application/json" \ -d '{ "model": "sora-2", "prompt": "A cinematic shot of a cat walking on the beach at sunset, soft ocean waves, warm golden lighting", "size": "1280x720", "seconds": 8 }'带参考图(JSON):
curl https://www.yunsell.com/v1/videos \ -H "Authorization: Bearer sk-xxx" \ -H "Content-Type: application/json" \ -d '{ "model": "sora-2", "prompt": "动态化这张图,轻微镜头移动", "size": "1280x720", "seconds": 8, "input_reference": { "image_url": "https://example.com/ref.jpg" } }'multipart/form-data(上传参考图):
curl https://www.yunsell.com/v1/videos \ -H "Authorization: Bearer sk-xxx" \ -F "model=sora-2" \ -F "prompt=动态化这张图,轻微镜头移动" \ -F "size=1280x720" \ -F "seconds=8" \ -F "input_reference=@/path/to/ref.jpg"响应体
HTTP 200
{ "id": "task_abc123xyz", "status": "queued", "progress": 0, "created_at": 1712697600}响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务 ID,用于查询和下载 |
status | string | 初始为 queued |
progress | integer | 进度 0–100 |
created_at | integer | Unix 时间戳(秒) |
失败响应
HTTP 400
{ "code": "invalid_request", "message": "seconds must be one of 4, 8, 12, 16, 20"}| 字段 | 类型 | 说明 |
|---|---|---|
code | string | 错误码 |
message | string | 校验失败原因 |
错误格式说明见 任务类错误。