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

# Seedance 2.0 API：多模態影片生成

> 位元組跳動多模式影片生成 API，支援文字到影片、第一影格與最後一影格以及全參考工作流程，並支援 4K

## 概覽

Seedance 2.0 是位元組跳動的影片生成模型，可以只憑提示詞生成影片，也支援首尾影格動畫和多模態參考生成。在 APIXO Playground 試用後，可依本頁範例呼叫 API。

| 功能 | 值 |
| - | - |
| 模型 ID | `seedance-2-0` |
| 模式 | `text-to-video`, `first_and_last_frames`, `omni_reference` |
| 提示詞 | 必填，且必須是非空字串 |
| 可用解析度 | `480p`, `720p`, `1080p`, `4k` |
| 持續時間 | 從 `4` 到 `15` 秒的任何整數 |
| 縱橫比 | `auto`, `16:9`, `4:3`, `1:1`, `3:4`, `9:16`, `21:9` |
| 參考圖片 | 1-2 `first_and_last_frames` 的 URL；1-9 `omni_reference` 的 URL |
| 參考影片/音訊 | 1-3 每個 `omni_reference` 的 URL；每個檔案 2-15 秒，每個媒體類型總共最多 15 秒 |
| 輸出 | MP4 影片 URL 陣列位於 `resultJson.resultUrls` 中 |

## 端點與身分驗證

API 基底網址：

```text theme={null}
https://api.apixo.ai/api/v1
```

| 方法 | 端點 | 用途 |
| - | - | - |
| `POST` | `/generateTask/seedance-2-0` | 送出生成任務 |
| `GET` | `/statusTask/seedance-2-0?taskId={taskId}` | 查詢任務狀態並取得結果 |

每個請求都必須附上 APIXO API 金鑰：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

送出任務時，還需設定以下請求標頭：

```http theme={null}
Content-Type: application/json
```

## 非同步請求範例

以下範例提交一個最簡單的文字生成影片任務，回應中會傳回 `taskId`。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/seedance-2-0" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video",
      "prompt": "a cinematic tracking shot through a rainy neon street",
      "resolution": "4k",
      "duration": 5,
      "aspect_ratio": "16:9",
      "sound": true,
      "web_search": false
    }
  }'
```

成功回應：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
```

請保留 `taskId`，後續輪詢結果時會用到。

## 輪詢結果

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/seedance-2-0?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

任務處理中的回應範例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
```

成功回應：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/video.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965890929,
    "costTime": 280000
  }
}
```

任務失敗時的回應範例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "UPSTREAM_ERROR",
    "failMsg": "The service could not complete the task",
    "createTime": 1767965610929,
    "completeTime": 1767965620132
  }
}
```

等 `state` 變為 `success` 後，再解析 `resultJson`：

```javascript theme={null}
const payload = JSON.parse(data.resultJson);
const videoUrls = payload.resultUrls;
```

## 請求體

### 文生影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "text-to-video",
    "prompt": "a slow tracking shot through a foggy pine forest at dawn",
    "resolution": "4k",
    "duration": 10,
    "aspect_ratio": "16:9",
    "sound": true,
    "web_search": false
  }
}
```

### 第一影格和最後一影格

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "first_and_last_frames",
    "prompt": "turn the still frames into a smooth cinematic camera move",
    "image_urls": [
      "https://example.com/frame-start.png",
      "https://example.com/frame-end.png"
    ],
    "resolution": "720p",
    "duration": 5,
    "aspect_ratio": "9:16",
    "sound": true,
    "web_search": false
  }
}
```

### 全參考

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "omni_reference",
    "prompt": "create a stylish product ad using the visual references and voice rhythm",
    "image_urls": [
      "https://example.com/product-shot.png"
    ],
    "video_urls": [
      "https://example.com/ref-motion.mp4"
    ],
    "audio_urls": [
      "https://example.com/ref-audio.mp3"
    ],
    "resolution": "720p",
    "duration": 6,
    "aspect_ratio": "auto",
    "sound": true,
    "web_search": false
  }
}
```

## 參數

**request\_type** `string` (default: async)

指定取得結果的方式。省略此欄位或設為 `async` 時，可透過 `statusTask` 輪詢；設為 `callback` 時，透過 Webhook 接收。

**callback\_url** `string`

當 `request_type` 為 `callback` 時必填。請提供可從網際網路存取的 HTTPS 網址，以接收任務的最終結果。詳見 [Webhook](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md)。

**input** `object` *required*

Seedance 2.0 的輸入參數。

**屬性**

**mode** `string` *required*

生成模式。可用值為 `text-to-video`、`first_and_last_frames`、`omni_reference`。

**prompt** `string` *required*

描述所需影片的文字提示。後端修剪空白並拒絕空提示。最大長度：10000 個字元。

**resolution** `string` (default: 720p)

輸出分辨率。支援的值：`480p`、`720p`、`1080p`、`4k`。值會被修剪並轉為小寫，因此 `4K` 與 `4k` 的處理結果相同。

**duration** `integer|string` (default: 5)

輸出持續時間（以秒為單位）。支援從 `4` 到 `15` 的整數，包括數字字串，例如 `"10"`。

**aspect\_ratio** `string` (default: auto)

輸出畫面的長寬比。可用值為 `auto`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16`、`21:9`。

**sound** `boolean` (default: true)

是否隨影片生成音訊。提供時必須是布林值。

**web\_search** `boolean` (default: false)

生成期間是否允許即時網路搜尋。提供時必須是布林值。

**nsfw\_checker** `boolean` (default: false)

對此請求啟用內容安全過濾。預設為`false`；提供時必須是布林值。

**image\_urls** `string[]`

參考影像 URL。用於 `first_and_last_frames` 時需提供 1-2 張影像；用於 `omni_reference` 時最多可提供 9 張影像，為可選。

**video\_urls** `string[]`

`omni_reference` 的參考影片 URL。支援 1-3 URL（如果提供）。每個影片必須為 2-15 秒，參考影片總時長不能超過 15 秒。

**audio\_urls** `string[]`

`omni_reference` 的參考音訊 URL。支援 1-3 URL（如果提供）。每個音訊檔案必須為 2-15 秒，總參考音訊持續時間不能超過 15 秒。

| 模式 | 所需媒體 | 可選的媒體 | 計費說明 |
| - | - | - | - |
| `text-to-video` | 無 | 無 | 使用無影片參考速率。 |
| `first_and_last_frames` | `image_urls` 應包含 1 至 2 張影像 | 無 | 使用無影片參考速率。 |
| `omni_reference` | 經驗證無，除非提供 `audio_urls`。 | `image_urls`, `video_urls`, `audio_urls` | 提供 `video_urls` 時使用影片參考計費。 |

> [!TIP]
>
> 在 `omni_reference` 中，僅音訊請求會被拒絕。若提供 `audio_urls`，請同時提供至少一張影像或影片參考。

> [!TIP]
>
> 對所有參考媒體使用公有、可直接存取的 URL。在送出任務前會檢查影片和音訊的持續時間。

> [!TIP]
>
> `image_urls` 範例使用 URL 字串。後端亦接受包含非空 `url` 欄位的物件項目，並將其標準化為 URL 字串。

## 回應格式

### 送出任務時的回應

任務受理後，`POST /generateTask/seedance-2-0` 會傳回任務 ID：

**code** `integer`

API 狀態碼。`200` 表示任務已受理。

**message** `string`

狀態說明。

**data.taskId** `string`

任務的唯一 ID，用於查詢任務狀態。

### 狀態回應欄位

**taskId** `string`

任務的唯一識別碼。

**state** `string`

目前的任務狀態，可能的值為 `pending`、`processing`、`success`、`failed`。

**resultJson** `string`

當 `state` 為 `success` 時傳回。解析此 JSON 字串後，即可從 `resultUrls` 取得生成的影片連結。

**failCode** `string`

供程式判讀的錯誤碼，僅在 `state` 為 `failed` 時傳回。

**failMsg** `string`

失敗原因說明，僅在 `state` 為 `failed` 時傳回。

**createTime** `integer`

任務建立時的 Unix 時間戳記，單位為毫秒。

**completeTime** `integer`

任務完成時的 Unix 時間戳記，單位為毫秒。任務完成後才會傳回。

**costTime** `integer`

處理時間，以毫秒為單位。任務完成且有計時資料時才會傳回。

**billing** `object`

新任務成功結束後，查詢狀態的回應和回撥通知都會在 `data.billing` 中傳回最終計費明細。舊任務可能沒有此物件，相容規則見本頁計費說明。

**billing.settlementState** `string`

結算狀態。最終快照使用 `final`。

**billing.billingRuleVersion** `string`

建立此任務時捕獲的計費規則的不透明標識符。不要從輪詢時間推斷規則。

**billing.inputVideoSeconds** `number`

所有參考影片的實際總時長，單位為秒。未提供參考影片時為零。此處記錄實際值，不會調高到最低計費時長。

**billing.minimumInputVideoSeconds** `number`

新任務如有參考影片，按 `ceil(outputVideoSeconds * 2 / 3)` 計算，無條件進位至整秒。沒有參考影片或沿用舊規則時，此值為零。

**billing.billableInputVideoSeconds** `number`

取 `inputVideoSeconds` 和 `minimumInputVideoSeconds` 中較大的值。沒有參考影片時為零。

**billing.outputVideoSeconds** `number`

用於計費的輸出持續時間，以秒為單位。

**billing.totalBillableSeconds** `number`

計費總秒數為 `outputVideoSeconds + billableInputVideoSeconds`。

**billing.unit** `string`

時間單位，值為 `second`。

## Webhook 回呼模式

若希望後端自動收到最終結果，可使用回呼模式，無須輪詢。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/seedance-2-0" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "first_and_last_frames",
      "prompt": "turn the still frames into a smooth cinematic camera move",
      "image_urls": [
        "https://example.com/frame-start.png",
        "https://example.com/frame-end.png"
      ],
      "resolution": "720p",
      "duration": 5,
      "aspect_ratio": "9:16",
      "sound": true,
      "web_search": false
    }
  }'
```

回呼有效負載使用與狀態輪詢相同的頂級結構，包含 `code`、`message` 與 `data`。成功回呼會包含最終的 `state` 與 `resultJson`；新任務的終端成功回呼亦會包含 `data.billing`。請參閱 [Webhooks](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md) 以取得傳遞要求與重試行為說明。

## 計費

新提交的非 LLM 請求按 **1 點 = `$0.001`** 計費。先依用量和加購項目計算總額，再套用帳戶折扣，最後將請求總額無條件進位至整數點數。若已約定固定單價，則保留該單價的精度，不再使用標準價或另行打折；最終點數仍須進位。詳見[積分換算與進位](https://apixo.ai/docs/zh-hant/pricing.md#credit-conversion-and-rounding)。

Seedance 2.0 按秒計費。所選的 `resolution` 與 `omni_reference` 是否包含 `video_urls` 會決定每秒的單價。

| 設定 | APIXO 價格 |
| - | - |
| `480p`，無影片參考 | `$0.094 / second` |
| `480p`，有影片參考 | `$0.058 / second` |
| `720p`，無影片參考 | `$0.20 / second` |
| `720p`，有影片參考 | `$0.124 / second` |
| `1080p`，無影片參考 | `$0.494 / second` |
| `1080p`，有影片參考 | `$0.305 / second` |
| `4k`，無影片參考 | `$1.04 / second` |
| `4k`，有影片參考 | `$0.622 / second` |

無影片參考的公式為：

```text theme={null}
total cost = output duration * unit price
```

含影片參考的公式為：

```text theme={null}
billable seconds = output seconds + max(actual total reference video seconds, ceil(output seconds * 2 / 3))
total cost = billable seconds * unit price
```

`text-to-video`和`first_and_last_frames`始終使用無影片參考速率。`omni_reference`僅在提供`video_urls`時才使用帶影片參考速率。影像和音訊參考不會增加額外的計費秒數。

`ceil` 將秒數無條件進位。先合計所有參考影片的時長，再應用一次最低計費時長。例如，輸出 5 秒、參考影片合計 3 秒，計費時長為 `5 + max(3, 4) = 9` 秒。輸出 6 秒、參考影片合計 2 秒，則按 10 秒計費。

新規則適用於計費更新後建立的任務。已有任務沿用建立時記錄的規則：有參考影片時按 `(output duration + actual total reference video duration) * unit price` 計算，沒有參考影片時只計輸出時長。單價、折扣和結算方式也沿用原記錄。即使在更新後查詢狀態或收到回撥，已有任務的規則也不會改變。

成功的最終狀態和新任務的回呼回應包括`data.billing`。持續時間值使用具有三位小數的秒數；`minimumInputVideoSeconds` 是無條件進位至整秒的最低計費輸入秒數。`inputVideoSeconds`仍然是實際輸入持續時間，而`billableInputVideoSeconds`是計費輸入時長。快照在重複輪詢中保持穩定。較舊的任務可能會省略 `billing` 或新欄位；用戶端不得要求歷史任務一定傳回這些欄位。

例如，5輸出秒和3參考影片秒的計費明細包括：

```json theme={null}
{
  "billing": {
    "settlementState": "final",
    "inputVideoSeconds": 3.000,
    "minimumInputVideoSeconds": 4.000,
    "billableInputVideoSeconds": 4.000,
    "outputVideoSeconds": 5.000,
    "totalBillableSeconds": 9.000,
    "unit": "second"
  }
}
```

最新的美元費率請見 [API 價目表](https://apixo.ai/pricing/api)。

## 耗時與輪詢

影片生成為長時間運行的流程。使用手冊記載典型的 Seedance 2.0 生成時間約為 4 至 8 分鐘。實際延遲可能因提示複雜度、持續時間、解析度、參考媒體的可存取性、路由佇列負載以及儲存傳輸時間而異。

| 工作量 | 一般生成時間 | 建議首次查詢時間 | 輪詢間隔 |
| - | - | - | - |
| 文字轉影片或第一影格和最後一影格 | 4-8 分鐘 | 任務建立 300 秒後 | 10s-20s |
| 具有影像/影片/音訊輸入的全方位參考 | 4-8 分鐘或更長時間 | 任務建立 300 至 400 秒後 | 10s-20s |

> [!TIP]
>
> 正式環境建議使用回呼，以免在影片生成期間頻繁輪詢。

結果連結有時效。任務完成後，請盡快下載並儲存重要檔案。

請求頻率與並行數上限會依帳戶、API 金鑰和路由而異。收到 `429` 時，請降低請求頻率，並逐步拉長重試間隔。帳戶層級的限制請見[系統 API](https://apixo.ai/docs/zh-hant/api-reference/system.md)。

## 錯誤與排查

### HTTP 錯誤

| 代碼 | 含義 | 處理方式 |
| - | - | - |
| `400` | 請求主體無效、缺少`input`、不受支援的`mode`、缺少`prompt`、無效`resolution`、無效`duration`、無效`aspect_ratio`、無效布林值或無效媒體陣列 | 修正請求後再試 |
| `401` | 缺少 API 金鑰，或金鑰無效 | 檢查 `Authorization` 請求標頭 |
| `402` | 餘額或配額不足 | 充值或更換帳號或金鑰 |
| `403` | 金鑰或路由無權訪問該模型 | 檢查權限和路由策略 |
| `404` | 輪詢時未找到任務 | 檢查`taskId` |
| `429` | 已達到速率或並行限制 | 以指數退避方式重試 |
| `500` | 伺服器錯誤或未知任務失敗 | 逐步拉長間隔後重試 |
| `502` | 服務錯誤 | 逐步拉長間隔後重試 |
| `504` | 服務超時 | 重新嘗試；耗時較長的任務可改用回呼模式 |

### 驗證說明

| 條件 | 後端行為 |
| - | - |
| 缺少 `input` | 請求會遭拒，系統不會建立任務。 |
| 缺失、非字串或空 `prompt` | 請求會遭拒，系統不會建立任務。 |
| 缺少 `mode` | 請求會遭拒，系統不會建立任務。 |
| 不支援的 `mode` 值 | 請求會遭拒，系統不會建立任務。可用值為 `text-to-video`、`first_and_last_frames`、`omni_reference`。 |
| 缺少 `resolution` | 預設值為 `720p`。 |
| 不支援的 `resolution` 值 | 請求會遭拒，系統不會建立任務。可用值為 `480p`、`720p`、`1080p`、`4k`。 |
| 缺少 `duration` | 預設值為 `5`。 |
| `duration` 不在 `4` 到 `15` 之間 | 請求會遭拒，系統不會建立任務。 |
| 缺少 `aspect_ratio` | 預設值為 `auto`。 |
| 不支援的 `aspect_ratio` 值 | 請求會遭拒，系統不會建立任務。 |
| `sound` 或 `web_search` 不是布林值 | 請求會遭拒，系統不會建立任務。 |
| `first_and_last_frames` 無 `image_urls` | 請求會遭拒，系統不會建立任務。 |
| `first_and_last_frames` 模式的圖片超過 2 張 | 請求會遭拒，系統不會建立任務。 |
| `omni_reference` 模式下，圖片超過 9 張、影片超過 3 個或音訊檔案超過 3 個 | 請求會遭拒，系統不會建立任務。 |
| `omni_reference` 模式下僅提供了 `audio_urls` | 請求會遭拒，系統不會建立任務。 |
| 參考影片或音訊的時長不足 2 秒或超過 15 秒 | 請求會遭拒，系統不會建立任務。 |
| 總參考影片持續時間或總參考音訊持續時間超過 15 秒 | 請求會遭拒，系統不會建立任務。 |

### 任務失敗代碼

`failCode` 表示任務失敗的原因，常見值如下。

| 錯誤碼 | 含義 | 處理方式 |
| - | - | - |
| `SensitiveContent` | 提示或輸入/輸出內容被安全檢查拒絕 | 更改提示或參考媒體 |
| `PromptInvalid` | 提示詞無效或遭拒 | 修改提示詞後再試一次 |
| `ImageFormatIncorrect` | 無法處理參考影像格式 | 請提供可公開存取的圖片直連網址，並使用常見的圖片格式 |
| `RateLimited` | 請求頻率已達上限 | 以指數退避方式重試 |
| `Timeout` | 任務逾時 | 稍後重試或使用回呼模式 |
| `StreamError` | 由於伺服器錯誤，影片生成失敗 | 逐步拉長間隔後重試 |
| `Unknown error` | 任務因不明原因失敗 | 逐步拉長間隔後重試，或聯絡支援團隊並提供 `taskId` |

完整列表見[錯誤碼](https://apixo.ai/docs/zh-hant/api-reference/errors.md)。

## MCP 整合

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/seedance-2-0.json) 中的 `mcp.result` 指定結果的解析方式，`mcp.attachments` 列出可繫結檔案的欄位。這些中繼資料供用戶端整合使用，無須當作生成參數提交。附件欄位為 `image_urls`, `video_urls`, `audio_urls`。請保留使用者指定的檔案順序。模型參數由 API 驗證。

## 相關連結

* [生成 API 總覽](https://apixo.ai/docs/zh-hant/models.md)
* [影片模型](https://apixo.ai/docs/zh-hant/models/video)
* [送出生成任務](https://apixo.ai/docs/zh-hant/api-reference/generate-task.md)
* [查詢任務狀態](https://apixo.ai/docs/zh-hant/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md)
* [錯誤碼](https://apixo.ai/docs/zh-hant/api-reference/errors.md)
* [參數規範](https://apixo.ai/docs/zh-hant/api-reference/parameters.md)
* [路由策略](https://apixo.ai/docs/zh-hant/concepts/routing-strategies.md)
* [在 APIXO Playground 嘗試 Seedance 2.0](https://apixo.ai/models/seedance-2-0)
* [API定價](https://apixo.ai/pricing/api)


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