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

# 统一视频 API

> Crazyrouter 统一视频生成接口，支持多种模型通过统一格式调用

> 更新日期：2026-06-06

# 统一视频 API

Crazyrouter 提供统一的视频生成接口，支持多种视频模型通过相同的 API 格式调用。

<Note>
  `Seedance` 当前不再推荐走统一 `/v1/video/*` 协议；请改用原生 `/volc/v1/contents/generations/tasks`，见 [Seedance](/video/seedance)。
</Note>

## 支持的模型

| 模型                   | 说明                     |
| -------------------- | ---------------------- |
| `veo-3.1-fast`       | Google Veo 3.1 Fast    |
| `veo-3.1-quality`    | Google Veo 3.1 Quality |
| `wan2.2-t2v-plus`    | Wan 文生视频               |
| `wan2.5-t2v-preview` | Wan 文生视频               |

***

## 创建视频

```
POST /v1/video/create
```

### 请求参数

| 参数             | 类型      | 必填 | 说明                      |
| -------------- | ------- | -- | ----------------------- |
| `model`        | string  | 是  | 模型名称                    |
| `prompt`       | string  | 是  | 视频描述提示词                 |
| `aspect_ratio` | string  | 否  | 宽高比：`16:9`、`9:16`、`1:1` |
| `size`         | string  | 否  | 视频尺寸，如 `1280x720`       |
| `images`       | array   | 否  | 当前公开图生视频一般传 `1` 张图片 URL |
| `duration`     | integer | 否  | 视频时长（秒）                 |

### 请求示例

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.crazyrouter.com/v1/video/create \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -d '{
      "model": "veo-3.1-quality",
      "prompt": "一只金毛犬在海滩上奔跑，慢动作，电影级画质",
      "aspect_ratio": "16:9"
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.crazyrouter.com/v1/video/create",
      headers={
          "Content-Type": "application/json",
          "Authorization": "Bearer YOUR_API_KEY"
      },
      json={
          "model": "veo-3.1-quality",
          "prompt": "一只金毛犬在海滩上奔跑，慢动作，电影级画质",
          "aspect_ratio": "16:9"
      }
  )

  data = response.json()
  task_id = data["task_id"]
  print(f"任务 ID: {task_id}")
  ```
</CodeGroup>

### 创建响应

```json theme={null}
{
  "task_id": "video_task_abc123",
  "status": "processing"
}
```

***

## 图生视频

在 `images` 参数中传入参考图片：

```bash cURL theme={null}
curl -X POST https://api.crazyrouter.com/v1/video/create \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "wan-ai/wan2.1-i2v-14b-720p",
    "prompt": "图片中的人物开始微笑并挥手",
    "images": ["https://example.com/portrait.jpg"],
    "aspect_ratio": "16:9"
  }'
```

***

## 查询任务

```
GET /v1/video/query?id={task_id}
```

### 请求示例

```bash cURL theme={null}
curl "https://api.crazyrouter.com/v1/video/query?id=video_task_abc123" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### 查询响应（处理中）

```json theme={null}
{
  "code": "success",
  "message": "",
  "data": {
    "task_id": "video_task_abc123",
    "status": "processing",
    "url": ""
  }
}
```

### 查询响应（已完成）

```json theme={null}
{
  "code": "success",
  "message": "",
  "data": {
    "task_id": "video_task_abc123",
    "status": "SUCCESS",
    "url": "https://media.crazyrouter.com/task-artifacts/example.mp4",
    "artifact_url": "https://media.crazyrouter.com/task-artifacts/example.mp4"
  }
}
```

### 任务状态

| 状态           | 说明  |
| ------------ | --- |
| `queued`     | 排队中 |
| `processing` | 处理中 |
| `SUCCESS`    | 已完成 |
| `failed`     | 失败  |

***

## 完整流程示例

```python Python theme={null}
import requests
import time

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.crazyrouter.com"
headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {API_KEY}"
}

# 1. 创建视频任务
resp = requests.post(f"{BASE_URL}/v1/video/create", headers=headers, json={
    "model": "veo-3.1-quality",
    "prompt": "一只金毛犬在海滩上奔跑，慢动作",
    "aspect_ratio": "16:9"
})
task_id = resp.json()["task_id"]
print(f"任务已创建: {task_id}")

# 2. 轮询查询状态
while True:
    resp = requests.get(f"{BASE_URL}/v1/video/query?id={task_id}", headers=headers)
    result = resp.json().get("data", resp.json())
    status = result["status"]
    print(f"状态: {status}")

    if status == "SUCCESS":
        print(f"视频地址: {result.get('artifact_url') or result.get('url')}")
        break
    elif status == "failed":
        print("视频生成失败")
        break

    time.sleep(10)
```

<Note>
  视频生成通常需要 1-5 分钟，建议轮询间隔为 10 秒。
</Note>
