# Seedance 火山原生格式视频生成

使用火山方舟官方请求格式调用 Seedance 2.0、Seedance 2.0 Fast、Seedance 2.0 Mini、Seedance 2.5 和 Seedance 2.5 Flash。请求体、`content` 素材结构和查询结果与火山方舟「创建视频生成任务」接口保持一致，已有火山接入代码只需替换域名和 API Key。

视频生成采用异步任务流程：

1. 创建视频任务，取得任务 `id`。
2. 使用任务 `id` 查询生成状态。
3. 状态为 `succeeded` 后从 `content.video_url` 读取视频地址。

## 接口与鉴权

```http
POST https://vip.brioi.com/api/v3/contents/generations/tasks
GET  https://vip.brioi.com/api/v3/contents/generations/tasks/{task_id}
```

新接入请统一使用上述不带前缀的路径；`SD｜火山` 分组同时兼容旧版 `/doubao/api/v3/contents/generations/tasks` 前缀路径。

所有请求均通过 Bearer API Key 鉴权：

```http
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
```

本页模型在 `SD｜火山` 或 `auto` 分组的 API Key 中可见，账号实际可用模型以 `GET /v1/models` 返回结果为准。

## 支持模型

`model` 填火山方舟的完整模型 ID：

| 模型 | 输出分辨率 | 输出时长 | 参考素材上限 | 样片模式 |
|---|---|---|---|---|
| `doubao-seedance-2-0-260128` | `480p`、`720p`、`1080p`、`4k` | `4–15` 秒，或 `-1` | 9 张图、3 个视频、3 段音频 | 不支持 |
| `doubao-seedance-2-0-fast-260128` | `480p`、`720p` | `4–15` 秒，或 `-1` | 9 张图、3 个视频、3 段音频 | 不支持 |
| `doubao-seedance-2-0-mini-260615` | `480p`、`720p` | `4–15` 秒，或 `-1` | 9 张图、3 个视频、3 段音频 | 不支持 |
| `doubao-seedance-2-5-260628` | `480p`、`720p`、`1080p`、`4k` | `4–30` 秒，或 `-1` | 30 张图、10 个视频、10 段音频 | 支持 |
| `doubao-seedance-2-5-flash-261115` | `480p`、`720p` | `4–30` 秒，或 `-1` | 10 张图、5 个视频、5 段音频 | 不支持 |

- 4K 的请求值为小写 `4k`。
- 请求模型不支持的分辨率时，任务不会创建，接口直接返回错误。
- `duration` 为 `-1` 时由模型在有效范围内自选时长。

## 请求字段

| 字段 | 类型 | 必填 | 说明 |
|---|---|---:|---|
| `model` | string | 是 | 上表中的模型 ID。 |
| `content` | object[] | 是 | 按顺序提交文本和素材，结构见下文。 |
| `resolution` | string | 否 | 输出分辨率，取值见上表。 |
| `ratio` | string | 否 | `21:9`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16` 或 `adaptive`。 |
| `duration` | integer | 否 | 输出时长（秒）。 |
| `generate_audio` | boolean | 否 | 是否生成有声视频。 |
| `seed` | integer | 否 | 随机种子。 |
| `watermark` | boolean | 否 | 是否添加水印。 |
| `return_last_frame` | boolean | 否 | 是否返回尾帧图片。 |
| `draft` | boolean | 否 | 仅 Seedance 2.5：`true` 时生成 480p 样片。 |

本页只列常用字段。请求体原样提交，平台不额外补默认值：省略的字段按火山方舟官方默认值处理；其余火山方舟官方字段（如 `omni_reference_task_type`、`tools`）同样原样提交，是否适用于所选模型以接口返回为准。不支持 `callback_url`，传入会直接返回参数错误，请轮询查询接口获取结果。字段说明见[火山方舟创建视频生成任务](https://docs.volcengine.com/docs/ark/create-video-generation-task-api?lang=zh)。

### `content` 元素

| 类型 | 写法 | `role` |
|---|---|---|
| 文本 | `{"type":"text","text":"..."}` | 不填 |
| 图片 | `{"type":"image_url","image_url":{"url":"..."},"role":"..."}` | `reference_image`、`first_frame` 或 `last_frame` |
| 视频 | `{"type":"video_url","video_url":{"url":"..."},"role":"reference_video"}` | `reference_video` |
| 音频 | `{"type":"audio_url","audio_url":{"url":"..."},"role":"reference_audio"}` | `reference_audio` |
| 样片 | `{"type":"draft_task","draft_task":{"id":"<样片任务 id>"}}` | 不填 |

- 素材 URL 须是任务处理期间可直接下载的公网地址；图片素材也可填入由 [Seedance 素材登记](https://docs.brioi.com/2552243m0.md) 获取的 `asset://` 引用。
- 首帧、首尾帧和全模态参考（参考图、视频、音频）是三种互斥场景，不能混用。
- Seedance 2.0、2.0 Fast、2.0 Mini 不能只传音频，须同时有参考图或参考视频；Seedance 2.5 和 2.5 Flash 支持只传音频。
- 提示词中可用 `@image1`、`@video1`、`@audio1` 按同类素材顺序引用素材。

## 请求示例

### 文生视频

```json
{
  "model": "doubao-seedance-2-5-flash-261115",
  "content": [
    {"type": "text", "text": "清晨的海边，镜头缓慢向前推进"}
  ],
  "resolution": "720p",
  "ratio": "16:9",
  "duration": 5,
  "generate_audio": false
}
```

### 首帧生视频

```json
{
  "model": "doubao-seedance-2-0-260128",
  "content": [
    {"type": "text", "text": "人物微笑并向镜头挥手"},
    {"type": "image_url", "image_url": {"url": "https://example.com/first.png"}, "role": "first_frame"}
  ],
  "resolution": "1080p",
  "ratio": "adaptive",
  "duration": 5
}
```

### 图片、视频和音频同时参考

```json
{
  "model": "doubao-seedance-2-5-260628",
  "content": [
    {"type": "text", "text": "以 @image1 的人物为主角，参考 @video1 的运镜，配合 @audio1 的节奏生成竖屏视频"},
    {"type": "image_url", "image_url": {"url": "https://example.com/character.png"}, "role": "reference_image"},
    {"type": "video_url", "video_url": {"url": "https://example.com/motion.mp4"}, "role": "reference_video"},
    {"type": "audio_url", "audio_url": {"url": "https://example.com/bgm.mp3"}, "role": "reference_audio"}
  ],
  "resolution": "720p",
  "ratio": "9:16",
  "duration": 12
}
```

## 样片与正片（仅 Seedance 2.5）

先提交 `draft: true`、`resolution: "480p"` 生成样片：

```json
{
  "model": "doubao-seedance-2-5-260628",
  "draft": true,
  "resolution": "480p",
  "content": [
    {"type": "text", "text": "虚拟人物微笑挥手"},
    {"type": "image_url", "image_url": {"url": "https://example.com/portrait.png"}, "role": "reference_image"}
  ]
}
```

样片 `status` 为 `succeeded` 后，用样片任务 `id` 单独提交正片，可指定 `1080p` 或 `4k`：

```json
{
  "model": "doubao-seedance-2-5-260628",
  "content": [
    {"type": "draft_task", "draft_task": {"id": "task_YOUR_DRAFT_ID"}}
  ],
  "resolution": "4k"
}
```

正片继承样片的提示词、参考素材、时长、比例和种子，不要重新填写。样片和正片是两笔独立任务，分别计费。

## 响应

创建成功返回任务 `id`：

```json
{"id": "task_EXAMPLE"}
```

查询返回火山方舟的任务结构，`id` 为本平台任务 ID：

```json
{
  "id": "task_EXAMPLE",
  "model": "doubao-seedance-2-5-260628",
  "status": "succeeded",
  "content": {"video_url": "https://.../result.mp4"},
  "resolution": "720p",
  "ratio": "9:16",
  "duration": 12,
  "usage": {"completion_tokens": 129600, "total_tokens": 129600}
}
```

`status` 取值：`queued`、`running`、`succeeded`、`failed`、`cancelled`、`expired`。失败时查看 `error.code` 和 `error.message`。视频链接有效期较短，请及时下载保存。建议每 5–10 秒查询一次，终态后停止。

## 计费

按任务实际返回的 `usage.completion_tokens` 结算，单价按模型、输出分辨率以及输入是否包含参考视频区分，再乘以 API Key 所在分组的倍率。提交时先按请求预扣，任务完成后按实际用量多退少补；任务失败按原路退回预扣。

不要因为查询未完成就重复提交创建请求，每次提交都是一笔新的生成任务。

## 错误处理

创建和查询的错误响应使用火山方舟的错误结构：

```json
{"error": {"code": "InvalidParameter", "message": "具体错误说明"}}
```

| HTTP 状态 | `error.code` | 常见原因 |
|---:|---|---|
| `400` | `InvalidParameter` | 参数错误，例如模型不支持所选分辨率、传了 `callback_url`、`content` 为空 |
| `401` | `AuthenticationError` | API Key 缺失或无效 |
| `403` | `AccessDenied` | 余额或额度不足，或没有模型权限 |
| `404` | `NotFound` | 请求的资源不存在 |
| `429` | `AccountRateLimitExceeded` | 请求过于频繁 |
| `500`、`502`、`503` | `InternalServiceError` | 服务暂时异常或暂时不可用 |

任务执行失败时，查询响应的 `status` 为 `failed`，原因见 `error.code` 和 `error.message`。

