> ## Documentation Index
> Fetch the complete documentation index at: https://mixroute.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Sora 2

> Sora 2：支援同步音訊的影片生成模型。包含 MixRoute 呼叫範例與參數。

<link rel="alternate" hrefLang="en" href="https://mixroute.ai/docs/model-api/openai/sora-2" />

<link rel="alternate" hrefLang="zh-Hans" href="https://mixroute.ai/docs/zh-hans/model-api/openai/sora-2" />

<link rel="alternate" hrefLang="zh-Hant" href="https://mixroute.ai/docs/zh-hant/model-api/openai/sora-2" />

<link rel="alternate" hrefLang="ja" href="https://mixroute.ai/docs/ja/model-api/openai/sora-2" />

<link rel="alternate" hrefLang="x-default" href="https://mixroute.ai/docs/model-api/openai/sora-2" />

Sora 2 生成帶同步音訊的影片。MixRoute 路由使用 `POST /v1/video/generations`，請求採用下列 Sora 建立欄位。

<Warning>
  OpenAI 計劃於 2026-09-24 關閉 Sora 2 模型與 Videos API。接入前請確認 MixRoute 路由許可權；模型目錄中存在 ID，並不保證影片路由已經啟用，也不代表上游關閉後仍會繼續提供服務。
</Warning>

## 請求參數

| 欄位 | 型別 | 必填 | 說明 |
| - | - | - | - |
| `model` | string | 是 | 使用 `sora-2`。 |
| `prompt` | string | 是 | 描述場景、運動和期望音訊。 |
| `seconds` | string | 否 | 影片時長："4"、"8" 或 "12"，預設 "4"。型別為字串，不是 duration 整數。 |
| `size` | string | 否 | Sora 2 使用 `720x1280`（預設，豎屏）或 `1280x720`（橫屏）；不要套用方形輸出或 Pro 專用尺寸。 |
| `input_reference` | object \| file | 否 | 原生首幀輸入：包含 image\_url 或 file\_id 的 JSON 物件，或 multipart 檔案上傳；所選 MixRoute 路由須開通媒體輸入能力。 |

這些都是 Sora 頂層欄位。不要替換為 Seedance 風格的 `duration`、`resolution`、`aspect_ratio`，也不要放入 `metadata`。

參考圖須與請求 size 的畫素尺寸一致，格式為 JPEG、PNG 或 WebP。JSON 原生結構為 `input_reference: {"image_url": "..."}` 或 `input_reference: {"file_id": "..."}`，不是頂層 image\_url；檔案 ID 須可被上游賬戶訪問。

影片混剪屬於獨立影片操作，不是建立請求中的 `remix_url` 欄位。不要將任意源影片 URL 作為該欄位傳入。

## 文生影片

呼叫前設定環境變數 `MIXROUTE_API_KEY`。

```bash theme={null}
curl --request POST "https://api.mixroute.ai/v1/video/generations" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "sora-2",
  "prompt": "A red paper square slowly rotates on a plain white background.",
  "seconds": "4",
  "size": "720x1280"
}'
```

### Python

```python theme={null}
import json
import os
import requests

payload = json.loads(r'''
{
  "model": "sora-2",
  "prompt": "A red paper square slowly rotates on a plain white background.",
  "seconds": "4",
  "size": "720x1280"
}
''')
response = requests.post(
    "https://api.mixroute.ai/v1/video/generations",
    headers={"Authorization": "Bearer " + os.environ["MIXROUTE_API_KEY"]},
    json=payload,
    timeout=60,
)
response.raise_for_status()
result = response.json()
if result.get("code") not in (None, 0, 200, "0", "200", "success"):
    raise RuntimeError(result.get("message") or result)
print(result)
```

## 呼叫流程

1. 向已開通的 Sora 路由提交請求，儲存返回的 MixRoute 任務 ID。
2. 使用 [查詢影片任務](/docs/zh-hant/api-reference/endpoint/query-video-task) 輪詢至成功或終止失敗狀態。
3. 使用結果 URL；需要獨立下載介面的路由，呼叫 [下載影片](/docs/zh-hant/api-reference/endpoint/download-video)。

HTTP 錯誤或業務錯誤不代表任務已建立。平臺路由錯誤需要檢查路由配置，修改提示詞或新增未定義欄位不能解決此類錯誤。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.