跳转到主要内容
POST
/
v1
/
videos
/
generations
Sora-2 Video Generation
curl --request POST \
  --url https://api.foxapi.cc/v1/videos/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "sora-2-preview",
  "prompt": "A cat playing in the grass",
  "image_url": "https://example.com/image.png",
  "duration": 5,
  "size": "auto",
  "model_params": {},
  "callback_url": "https://your-domain.com/webhooks/video-task-completed"
}
'
{
  "created": 1757165031,
  "id": "task-unified-1757165031-uyujaw3d",
  "model": "<string>",
  "object": "video.generation.task",
  "progress": 0,
  "status": "pending",
  "task_info": {
    "can_cancel": true,
    "estimated_time": 45
  },
  "type": "video"
}

授权

Authorization
string
header
必填

所有接口均需要使用Bearer Token进行认证

使用时在请求头中添加:

Authorization: Bearer YOUR_API_KEY

请求体

application/json
model
enum<string>
默认值:sora-2-preview
必填

Sora-2 Preview 模型,用于视频生成

可用选项:
sora-2-preview
示例:

"sora-2-preview"

prompt
string
必填

提示词,描述想要生成的视频,限制为2000token

Maximum string length: 2000
示例:

"A cat playing in the grass"

image_url
string<uri>

参考图片URL,用于图生视频

示例:

"https://example.com/image.png"

duration
integer

视频时长(秒)

示例:

5

size
enum<string>

生成视频的宽高比,默认值为 auto

可用选项:
auto,
1:1,
2:3,
3:2,
3:4,
4:3,
4:5,
5:4,
9:16,
16:9,
21:9
model_params
object

模型扩展参数

callback_url
string<uri>

任务完成后的HTTPS回调地址

回调时机:

  • 任务完成(completed)、失败(failed)或取消(cancelled)时触发

安全限制:

  • 仅支持HTTPS协议
  • 禁止回调到内网IP地址 (127.0.0.1, 10.x.x.x, 172.16-31.x.x, 192.168.x.x, etc.)
  • URL长度不超过 2048 字符

回调机制:

  • 超时时间: 10
  • 失败后最多重试 3 次(会分别在失败的 1 秒/2 秒/4 秒后进行重试)
  • 回调响应体格式与任务查询接口返回的格式一致
  • 回调地址若返回2xx状态码视为成功,其他状态码会触发重试
示例:

"https://your-domain.com/webhooks/video-task-completed"

响应

视频生成任务创建成功

created
integer

任务创建时间戳

示例:

1757165031

id
string

任务ID

示例:

"task-unified-1757165031-uyujaw3d"

model
string

实际使用的模型名称

object
enum<string>

任务的具体类型

可用选项:
video.generation.task
progress
integer

任务进度百分比 (0-100)

必填范围: 0 <= x <= 100
示例:

0

status
enum<string>

任务状态

可用选项:
pending,
processing,
completed,
failed
示例:

"pending"

task_info
object

异步任务信息

type
enum<string>

任务的输出类型

可用选项:
text,
image,
audio,
video
示例:

"video"