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

# Sora 2

> Sora 2：支持同步音频的视频生成模型。包含 MixRoute 调用示例与参数。

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. 使用 [查询视频任务](/zh-hans/api-reference/endpoint/query-video-task) 轮询至成功或终止失败状态。
3. 使用结果 URL；需要独立下载接口的路由，调用 [下载视频](/zh-hans/api-reference/endpoint/download-video)。

HTTP 错误或业务错误不代表任务已创建。平台路由错误需要检查路由配置，修改提示词或添加未定义字段不能解决此类错误。


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