APIMaster.ai

Sora 2 视频生成 API

使用 APIMaster.ai 调用 sora-2 / sora-2-pro 文生视频与图生视频。任务轮询与视频下载均走 APIMaster 域名。

Sora 2 视频生成

通过 APIMaster 调用 Sora 2 视频生成。支持模型:sora-2sora-2-pro(请求里写 sora 会自动映射为 sora-2)。

Base URLhttps://apimaster.ai/v1https://apimaster.ai/v1。路径写 https://apimaster.ai/v1/videos/...不要再拼一层 /v1

价格(官方价 8 折,按秒计费)

生成秒数 × 每秒单价 计费。下表为各档单价(sora-2-pro 更高分辨率按档加收,与官方一致)。

模型 分辨率 官方价 APIMaster 价
sora-2 720p $0.10 / 秒 $0.08 / 秒
sora-2-pro 720p $0.30 / 秒 $0.24 / 秒
sora-2-pro 1024p $0.50 / 秒 $0.40 / 秒
sora-2-pro 1080p $0.70 / 秒 $0.56 / 秒

示例:sora-2 生成 4 秒 720p 视频 ≈ $0.32($0.08 × 4)。

提交任务

提供两种入口,任选其一。

方式 A(推荐):原生 JSON

POST https://apimaster.ai/v1/videos/generations

字段 类型 必填 说明
model string sora-2 / sora-2-pro(或 sora
prompt string 视频描述
duration integer 常用 4 / 8 / 12 / 16 / 20,默认 4
resolution string sora-2720psora-2-pro 还可 1024p / 1080p,默认 720p
aspect_ratio string 横屏 16:9 / landscape;竖屏 9:16 / portrait,默认 16:9
image_urls string[] 图生视频,建议 1 张公网 URL
curl -s "https://apimaster.ai/v1/videos/generations" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2",
    "prompt": "瀑布倾泻而下形成彩虹,电影感",
    "duration": 4,
    "resolution": "720p",
    "aspect_ratio": "16:9"
  }'

提交响应

{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_xxxxxxxx"
    }
  ]
}

图生视频时请显式传 aspect_ratio(竖图 9:16)。未传时网关默认 16:9

方式 B:OpenAI Video 兼容

POST https://apimaster.ai/v1/videos(JSON 或 multipart)

字段 类型 必填 说明
model string sora-2 / sora-2-pro(或 sora
prompt string 视频描述
seconds string 时长秒数,如 "4";整数字段 duration 也可,默认 4
size string 像素尺寸,决定分辨率与横竖屏(见下表),默认 720x1280
images string[] 图生视频,最多 1 张 URL;也可用 input_reference 传单张

size 取值

模型 横屏(16:9) 竖屏(9:16)
sora-2 1280x720(720p) 720x1280(720p)
sora-2-pro 1280x720(720p)/ 1792x1024(1024p) 720x1280(720p)/ 1024x1792(1024p)

非法 size(如 1920x1080)返回 400 invalid_size。OpenAI 路径最高 1024p;1080p 请用方式 A 的 resolution: "1080p"

curl -s "https://apimaster.ai/v1/videos" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2",
    "prompt": "瀑布倾泻而下形成彩虹,电影感",
    "seconds": "4",
    "size": "1280x720"
  }'

提交响应

{
  "id": "task_xxxxxxxx",
  "object": "video",
  "model": "sora-2",
  "status": "queued"
}

两种方式均使用返回的 task_id / id 进行轮询与下载。

查询任务

GET https://apimaster.ai/v1/videos/{task_id}

返回 OpenAI Video 兼容 JSON,status 常见值:queued / in_progress / completed / failed

curl -s "https://apimaster.ai/v1/videos/task_xxxxxxxx" \
  -H "Authorization: Bearer YOUR_API_KEY"

完成示例:

{
  "id": "task_xxxxxxxx",
  "status": "completed",
  "url": "https://apimaster.ai/v1/videos/task_xxxxxxxx/content"
}

completed 后使用 https://apimaster.ai/v1/videos/{task_id}/content 下载 MP4(APIMaster 域名)。

下载视频

curl -L "https://apimaster.ai/v1/videos/task_xxxxxxxx/content" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o output.mp4

图生视频示例

方式 A(显式比例):

curl -s "https://apimaster.ai/v1/videos/generations" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2",
    "prompt": "镜头缓慢推进,微风吹动发丝",
    "duration": 8,
    "resolution": "720p",
    "aspect_ratio": "9:16",
    "image_urls": ["https://example.com/reference.jpg"]
  }'

方式 B(OpenAI 字段 images):

curl -s "https://apimaster.ai/v1/videos" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2",
    "prompt": "镜头缓慢推进,微风吹动发丝",
    "seconds": "8",
    "images": ["https://example.com/reference.jpg"]
  }'

轮询建议

  • 提交后 10–20 秒 再开始查询,间隔 3–5 秒
  • 典型生成时间约 1–3 分钟
  • 建议生成完成后尽快保存 MP4(上游 CDN 可能有时效)

错误码

code 含义
400 参数无效(如 invalid_size
401 API Key 无效
402 余额不足
429 请求过频
500 / 502 服务临时错误,可重试

相关链接