Sora 2 影片生成 API
在 APIMaster.ai 上呼叫 sora-2 及 sora-2-pro 以進行文字轉影片與圖片轉影片。輪詢與下載使用 APIMaster 網址。
Sora 2 影片生成
透過 APIMaster 使用 Sora 2 生成影片。支援的模型:sora-2、sora-2-pro。名稱 sora 對應至 sora-2。
基礎網址:
https://apimaster.ai/v1為https://apimaster.ai/v1。請使用https://apimaster.ai/v1/videos/...— 切勿再添加/v1。
定價(官方價格八折,每秒計費)
計費方式為 持續時間(秒)× 每秒費率。
| 模型 | 解析度 | 官方 | 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 / 秒 |
範例:4 秒的 sora-2 720p ≈ $0.32($0.08 × 4)。
提交任務
提供兩個進入點 — 可任選其一。
選項 A(建議):原生 JSON
POST https://apimaster.ai/v1/videos/generations
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
model |
字串 | 是 | sora-2 / sora-2-pro(或 sora) |
prompt |
字串 | 是 | 影片描述 |
duration |
整數 | 否 | 常用:4 / 8 / 12 / 16 / 20,預設 4 |
resolution |
字串 | 否 | sora-2:720p;sora-2-pro:亦可使用 1024p / 1080p,預設 720p |
aspect_ratio |
字串 | 否 | 16:9 / landscape 或 9:16 / portrait,預設 16:9 |
image_urls |
字串陣列 | 否 | 圖片轉影片;建議使用 1 個公開網址 |
curl -s "https://apimaster.ai/v1/videos/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2",
"prompt": "A waterfall forming a rainbow, cinematic",
"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 影片相容
POST https://apimaster.ai/v1/videos(JSON 或多部分形式)
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
model |
字串 | 是 | sora-2 / sora-2-pro(或 sora) |
prompt |
字串 | 是 | 影片描述 |
seconds |
字串 | 否 | 持續時間,例如 "4";整數 duration 亦可,預設 4 |
size |
字串 | 否 | 像素尺寸 — 解析度 + 方向(下方表格),預設 720x1280 |
images |
字串陣列 | 否 | 圖片轉影片;最多 1 個網址。亦可使用單一 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": "A waterfall forming a rainbow, cinematic",
"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}
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"
}
透過
https://apimaster.ai/v1/videos/{task_id}/content下載 MP4。
下載影片
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": "Slow push-in, gentle breeze in the hair",
"duration": 8,
"resolution": "720p",
"aspect_ratio": "9:16",
"image_urls": ["https://example.com/reference.jpg"]
}'
選項 B(images 欄位):
curl -s "https://apimaster.ai/v1/videos" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2",
"prompt": "Slow push-in, gentle breeze in the hair",
"seconds": "8",
"images": ["https://example.com/reference.jpg"]
}'
輪詢技巧
- 提交後等待 10–20 秒,然後每 3–5 秒輪詢一次
- 通常耗時:1–3 分鐘
- 完成後立即儲存 MP4
錯誤代碼
| 代碼 | 含義 |
|---|---|
| 400 | 參數無效(例如 invalid_size) |
| 401 | API 金鑰無效 |
| 402 | 餘額不足 |
| 429 | 請求過於頻繁 |
| 500 / 502 | 暫時性錯誤,請重試 |