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

# Doubao SeeDance 視頻生成

> 使用字節跳動豆包 Doubao SeeDance 模型生成視頻

* 字節跳動豆包視頻生成模型
* 通過 model 參數選擇 `doubao-seedance-1-0-pro-fast` 或 `doubao-seedance-1-0-pro-quality` 模型
* 支持文本到視頻生成
* 支持首幀/尾幀/參考圖控制
* 異步任務管理，通過任務 ID 查詢結果

<Warning>
  **重要變更**：爲了更好的性能和成本控制，我們不再支持在 `image_urls` 中直接傳入 base64 圖片數據。請先使用 [上傳圖片接口](../../uploads/images) 上傳圖片，獲取 URL 後再調用本接口。
</Warning>

## Authorizations

<ParamField header="Authorization" type="string" required>
  所有接口均需要使用 Bearer Token 進行認證

  獲取 API Key：訪問 [API Key 管理頁面](https://toapis.com/console/token) 獲取您的 API Key

  使用時在請求頭中添加：

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Body

<ParamField body="model" type="string" default="doubao-seedance-1-0-pro-fast" required>
  視頻生成模型名稱

  可用模型：

  * `doubao-seedance-1-0-pro-fast` - 快速版（40-90 秒生成）
  * `doubao-seedance-1-0-pro-quality` - 高質量版（90-300 秒生成）
</ParamField>

<ParamField body="prompt" type="string" required>
  視頻內容描述

  詳細描述場景、動作、風格以獲得更好的生成效果

  示例：`"海灘日落，金色陽光照在海面上，海浪輕輕拍打沙灘"`
</ParamField>

<ParamField body="duration" type="integer" default={5}>
  視頻時長（秒）

  支持範圍：`2` \~ `12` 秒

  默認：`5`
</ParamField>

<ParamField body="aspect_ratio" type="string" default="16:9">
  視頻寬高比

  可選項：

  * `16:9` - 橫屏
  * `9:16` - 豎屏
  * `1:1` - 方形
  * `4:3` - 傳統比例
  * `3:4` - 豎向傳統比例
  * `21:9` - 超寬屏

  默認：`16:9`
</ParamField>

<ParamField body="resolution" type="string" default="720p">
  視頻分辨率

  可選項：

  * `480p` - 標清
  * `720p` - 高清
  * `1080p` - 全高清

  默認：`720p`

  **1080p 限制**：使用參考圖（`image_with_roles` 中 `role: reference`）時，不支持 1080p 分辨率
</ParamField>

## 分辨率與寬高比組合

| 分辨率   | 支持的寬高比                          | 備註     |
| ----- | ------------------------------- | ------ |
| 480p  | 16:9, 4:3, 1:1, 3:4, 9:16, 21:9 | 全部支持   |
| 720p  | 16:9, 4:3, 1:1, 3:4, 9:16, 21:9 | 全部支持   |
| 1080p | 16:9, 4:3, 1:1, 3:4, 9:16, 21:9 | 不支持參考圖 |

<ParamField body="image_urls" type="string[]">
  首幀圖像 URL 數組，用於圖生視頻

  **⚠️ 僅支持 URL 格式（不再支持 base64）**

  * 公開可訪問的圖像 URL（http\:// 或 https\://）
  * 可使用 [上傳圖片接口](../../uploads/images) 上傳本地圖片獲取 URL

  示例：`["https://example.com/cat.png"]`

  `image_urls` 和 `image_with_roles` 不能同時使用
</ParamField>

<ParamField body="image_with_roles" type="array">
  帶角色的圖像數組，用於更精確的控制

  <Expandable title="字段說明">
    <ParamField body="url" type="string" required>
      圖像 URL 地址
    </ParamField>

    <ParamField body="role" type="string" required>
      圖像角色

      可選項：

      * `first_frame` - 首幀圖，作爲視頻起始畫面（僅支持一張）
      * `last_frame` - 尾幀圖，作爲視頻結束畫面（**僅 quality 版本支持**，僅支持一張）
      * `reference` - 參考圖，用於指導視頻風格（僅支持一張）
    </ParamField>
  </Expandable>

  示例：

  ```json theme={null}
  [
    {"url": "https://example.com/start.png", "role": "first_frame"},
    {"url": "https://example.com/end.png", "role": "last_frame"}
  ]
  ```

  <Warning>
    * `image_urls` 和 `image_with_roles` 不能同時使用
    * 每種角色的圖片僅支持上傳一張
    * `last_frame`（尾幀圖）僅 `doubao-seedance-1-0-pro-quality` 版本支持，fast 版本不支持首尾幀同時使用
  </Warning>
</ParamField>

<ParamField body="metadata" type="object">
  擴展參數（可選）

  <Expandable title="字段說明">
    <ParamField body="seed" type="integer">
      種子整數，用於控制生成內容的隨機性

      取值範圍：`-1` \~ `2^32-1`

      相同 seed 值會生成類似結果，但不保證完全一致
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="id" type="string">
  任務唯一標識符，用於查詢任務狀態
</ResponseField>

<ResponseField name="object" type="string">
  對象類型，固定爲 `generation.task`
</ResponseField>

<ResponseField name="model" type="string">
  使用的模型名稱
</ResponseField>

<ResponseField name="status" type="string">
  任務狀態

  * `queued` - 排隊等待處理
  * `in_progress` - 處理中
  * `completed` - 成功完成
  * `failed` - 失敗
</ResponseField>

<ResponseField name="progress" type="integer">
  任務進度百分比（0-100）
</ResponseField>

<ResponseField name="created_at" type="integer">
  任務創建時間戳（Unix 時間戳）
</ResponseField>

<ResponseField name="metadata" type="object">
  任務元數據
</ResponseField>

<RequestExample>
  ```bash cURL（快速預覽橫屏視頻） theme={null}
  curl --request POST \
    --url https://toapis.com/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "doubao-seedance-1-0-pro-fast",
      "prompt": "海灘日落，金色陽光照在海面上，海浪輕輕拍打沙灘",
      "duration": 5,
      "aspect_ratio": "16:9",
      "resolution": "720p"
    }'
  ```

  ```bash cURL（高質量豎屏短視頻） theme={null}
  curl --request POST \
    --url https://toapis.com/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "doubao-seedance-1-0-pro-quality",
      "prompt": "女孩在櫻花樹下旋轉，花瓣隨風飄落",
      "duration": 5,
      "aspect_ratio": "9:16",
      "resolution": "1080p"
    }'
  ```

  ```bash cURL（首尾幀動態過渡） theme={null}
  curl --request POST \
    --url https://toapis.com/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "doubao-seedance-1-0-pro-quality",
      "prompt": "畫面從白天逐漸過渡到夜晚，城市燈光逐漸亮起",
      "duration": 5,
      "image_with_roles": [
        {"url": "https://example.com/day.png", "role": "first_frame"},
        {"url": "https://example.com/night.png", "role": "last_frame"}
      ]
    }'
  ```

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

  response = requests.post(
      "https://toapis.com/v1/videos/generations",
      headers={
          "Authorization": "Bearer your-ToAPIs-key",
          "Content-Type": "application/json"
      },
      json={
          "model": "doubao-seedance-1-0-pro-fast",
          "prompt": "海灘日落，金色陽光照在海面上，海浪輕輕拍打沙灘",
          "duration": 5,
          "aspect_ratio": "16:9",
          "resolution": "720p"
      }
  )

  task = response.json()
  print(f"任務 ID: {task['id']}")
  print(f"狀態: {task['status']}")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://toapis.com/v1/videos/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your-ToAPIs-key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'doubao-seedance-1-0-pro-fast',
      prompt: '海灘日落，金色陽光照在海面上，海浪輕輕拍打沙灘',
      duration: 5,
      aspect_ratio: '16:9',
      resolution: '720p'
    })
  });

  const task = await response.json();
  console.log(`任務 ID: ${task.id}`);
  console.log(`狀態: ${task.status}`);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "task_vid_xyz789ghi012",
    "object": "generation.task",
    "model": "doubao-seedance-1-0-pro-fast",
    "status": "queued",
    "progress": 0,
    "created_at": 1703884800,
    "metadata": {}
  }
  ```
</ResponseExample>
