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)。

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

APIMaster 视频按 生成秒数 × 每秒单价 计费。下表为 720p 基准单价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)。

提交任务

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

请求头

Header
Authorization Bearer YOUR_API_KEY
Content-Type application/json

请求体

字段 类型 必填 说明
model string sora-2 / sora-2-pro(或 sora
prompt string 视频描述
duration integer 4 / 8 / 12 / 16 / 20,默认 4
resolution string sora-2720psora-2-pro 还可 1080p / 1024p,默认 720p
aspect_ratio string 横屏 16:9 / landscape;竖屏 9:16 / portrait,默认 16:9
image_urls string[] 图生视频,最多 1 张公网图片 URL

示例(文生视频)

curl -s "https://apimaster.ai/v1/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"
    }
  ]
}

task_idAPIMaster 任务 ID,后续轮询与下载均使用该 ID。

查询任务

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

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

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

完成示例(字段随版本可能略有差异):

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

注意:响应中的 url 始终为 APIMaster 域名下的下载地址,请直接使用该链接获取 MP4。

下载视频

任务 completed 后:

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

图生视频

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

传入 image_urls 时,会按参考图自动判断横竖屏,aspect_ratio 可省略。

OpenAI 兼容提交(可选)

curl -s "https://apimaster.ai/v1/v1/videos" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2",
    "prompt": "A calm ocean wave at sunset",
    "seconds": "4",
    "size": "1280x720"
  }'
OpenAI 字段 映射
seconds duration
size=1280x720 720p + 16:9
size=720x1280 720p + 9:16
input_reference / 参考图 image_urls

轮询建议

  • 提交后 10–20 秒 再开始查询,间隔 3–5 秒
  • 典型生成时间约 1–3 分钟(视时长与负载而定)
  • 视频链接有效期约 24 小时,请尽快保存到自有存储

错误码

常见 HTTP / code

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

相关链接