Sora 2 Pro API

整合 Sora 2 Pro API

透過可預測的輪詢和點數控制,建立文字轉影片、圖片轉影片和分鏡腳本工作流程。

Sora 2 Pro API 提供的功能

啟動生產就緒的 Sora 2 Pro 管線所需的一切。

五種模型變體

根據品質和成本選擇 sora-2 文字/圖片或 sora-2-pro 文字/圖片/分鏡腳本。

分鏡腳本支援

使用 shots[] 和每個鏡頭的持續時間定義多鏡頭敘事。

統一回應

所有端點都會回傳 code/message/data,即使錯誤時 HTTP 狀態為 200。

驗證與基礎 URL

基礎 URL:https://freesoragenerator.com。使用 API 金鑰或已登入的 session cookie 進行驗證。

  • Authorization: Bearer [TOKEN](API 金鑰 sk- 或 JWT),或傳送 session cookie。
  • POST 請求主體需傳送 Content-Type: application/json。
  • 大多數錯誤仍會回傳 HTTP 200;請務必檢查 code 欄位。

核心端點

使用 /sora-pro 建立任務,然後輪詢 check-result 查詢狀態。

建立生成任務

驗證輸入、扣除點數、建立任務並回傳 taskId。

方法: POST路徑: /api/v1/video/sora-pro

請求參數

  • 必填。sora-2-text-to-video、sora-2-image-to-video、sora-2-pro-text-to-video、sora-2-pro-image-to-video、sora-2-pro-storyboard 其中之一。
  • 條件必填。除 sora-2-pro-storyboard 外,所有模型都需要。
  • 條件必填。Base64 資料 URL,如 data:image/png;base64,...。若無 imageUrl,圖片轉影片需要此欄位。
  • 條件必填。當未提供 imageData 時使用的公開圖片 URL。
  • 選填。portrait 或 landscape。預設:landscape。
  • 選填。10、15 或 25(僅限分鏡腳本)。預設值因模型而異。
  • 選填。standard 或 high。僅適用於 Pro 文字/圖片模型。
  • 選填。移除非分鏡腳本模型的浮水印。預設:true。
  • 條件必填。sora-2-pro-storyboard 需要。'{ Scene, duration }' 的陣列。

備註

  • 當同時提供 imageData 和 imageUrl 時,imageData 優先。
  • prompt 對於分鏡腳本是選填的,不會傳送給供應商;請使用 shots 提供內容。
  • nFrames 會根據每個模型的允許值進行標準化。
  • 非分鏡腳本模型的 removeWatermark 預設為 true。
  • shots 必須包含 Scene(大寫 S)且 duration > 0。

請求範例

文字轉影片
curl -X POST https://freesoragenerator.com/api/v1/video/sora-pro \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2-pro-text-to-video",
    "prompt": "A cinematic shot of a futuristic city at sunset.",
    "aspectRatio": "landscape",
    "nFrames": "10",
    "size": "high",
    "removeWatermark": true
  }'
圖片轉影片
curl -X POST https://freesoragenerator.com/api/v1/video/sora-pro \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2-image-to-video",
    "prompt": "Turn this image into a dynamic 10s clip.",
    "imageUrl": "https://example.com/reference.png",
    "aspectRatio": "portrait",
    "nFrames": "10"
  }'
分鏡腳本
curl -X POST https://freesoragenerator.com/api/v1/video/sora-pro \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2-pro-storyboard",
    "shots": [
      { "Scene": "Establishing shot of a city skyline at dusk", "duration": 5 },
      { "Scene": "Close-up of a runner splashing through puddles", "duration": 5 }
    ],
    "aspectRatio": "landscape",
    "nFrames": "10"
  }'

回應範例

{
  "code": 0,
  "message": "ok",
  "data": {
    "taskId": "281e5b0*********************f39b9"
  }
}

查詢任務狀態

透過 taskId 取得狀態、進度和結果 URL。

方法: POST路徑: /api/video-generations/check-result

請求參數

  • 必填。建立時回傳的 taskId。

備註

  • 狀態值:pending | running | succeeded | failed | cancelled。
  • result_url 和 result_urls 在準備就緒時回傳最終影片連結。

請求範例

curl -X POST https://freesoragenerator.com/api/video-generations/check-result \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "taskId": "281e5b0*********************f39b9"
  }'

回應範例

{
  "code": 0,
  "message": "Success",
  "data": {
    "status": "running",
    "progress": 35,
    "result_url": "https://your-domain.com/storage/videos/xxx.mp4",
    "result_urls": [
      "https://your-domain.com/storage/videos/xxx.mp4"
    ],
    "failure_reason": "",
    "error_message": null
  }
}

取得使用者點數

在提交任務前檢查目前點數餘額。

方法: POST路徑: /api/get-user-credits

備註

  • 選填端點;適用於預檢查。
  • 回傳 left_credits 和 is_vip 標記。

請求範例

curl -X POST https://freesoragenerator.com/api/get-user-credits \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

回應範例

{
  "code": 0,
  "message": "ok",
  "data": {
    "left_credits": 120,
    "is_vip": false
  }
}

常見錯誤代碼

錯誤透過回應主體中的 code 欄位呈現。

  • 401:未授權
  • 402:點數不足
  • -1:無效的模型參數
  • -1:需要提示詞
  • -1:圖片轉影片需要圖片
  • -1:分鏡腳本需要 shots
  • -1:圖片上傳失敗
  • -1:建立影片生成記錄失敗

點數參考

點數因模型、尺寸和 nFrames 而異。請以此表格作為基準。

模型參數點數
sora-2-text-to-video1020
sora-2-text-to-video1530
sora-2-image-to-video1020
sora-2-image-to-video1530
sora-2-pro-text-to-videostandard + 10375
sora-2-pro-text-to-videostandard + 15675
sora-2-pro-text-to-videohigh + 10825
sora-2-pro-text-to-videohigh + 151,575
sora-2-pro-image-to-videostandard + 10375
sora-2-pro-image-to-videostandard + 15675
sora-2-pro-image-to-videohigh + 10825
sora-2-pro-image-to-videohigh + 151,575
sora-2-pro-storyboard10375
sora-2-pro-storyboard15675
sora-2-pro-storyboard25675

1. 建立任務

使用您的模型和請求內容 POST /api/v1/video/sora-pro。

2. 追蹤進度

輪詢 /api/video-generations/check-result 直到狀態為 succeeded 或 failed。

3. 驗證點數

在提交大量批次前,可選擇呼叫 /api/get-user-credits。

常見問題

我可以使用 API 金鑰或 session cookie 嗎?

可以。傳送 Authorization: Bearer [TOKEN](API 金鑰或 JWT)或已登入的 session cookie。

如何格式化分鏡腳本的 shots?

將 shots 提供為 '{ Scene, duration }' 的陣列,其中 Scene 首字母大寫,duration 為秒數。

為什麼不同模型的點數不同?

所有模型的點數都會隨 nFrames 調整;Pro 模型還會因 size 而異。

實用資源

開始使用 Sora 2 Pro API

產生 API 金鑰,立即啟動您的第一個 Sora 2 Pro 工作流程。