> ## 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.

# Wan 2.6 Video API：使用文字、圖片或參考素材生成影片

> 選擇 Wan 2.6 Video API 模式，用於提示、單張來源影像，或影像與影片參考的組合。包含支援音訊控制的標準請求與 Flash 請求。

## 概覽

為一張影像設定動畫 `wan-2-6-video`，送進去 `image_urls` 使用 [圖生影片](#image-to-video)；若要由多個主體組成一個鏡頭，請將每個主體發送一張影像或剪輯 `reference_urls` 使用 [參考影片](#reference-to-video)；對於一個 [僅提示影片](#copy-paste-async-quickstart)，省略兩個陣列。

兩種 Flash 模式亦支援 `sound`。使用 [圖生影片快閃記憶體](#image-to-video-flash) 可為肖像加入音軌生成動畫，或使用 [參考到影片快閃記憶體](#reference-to-video-flash) 從參考資料合成無聲鏡頭。

| 功能 | 值 |
| - | - |
| 模型 ID | `wan-2-6-video` |
| 模式 | `text-to-video`, `image-to-video-flash`, `image-to-video`, `reference-to-video-flash`, `reference-to-video` |
| 提示詞 | 所有模式皆需提供，且不得為空，最多 `1500` 個字元。 |
| 負面提示 | 可選，最多 `500` 個字元。 |
| 解析度級距 | `720p`, `1080p` |
| 長度 | `text/image`：`2-15` 秒（預設 `5` 秒）；`reference`：`2-10` 秒（預設 `5` 秒） |
| 提示重寫 | `prompt_extend` 可選布林值；`true`（預設）啟用重寫，`false` 停用重寫 |
| 影像輸入 | 確切地 `1` URL 為了 `image-to-video-flash` 和 `image-to-video`; `JPEG/JPG/PNG(no alpha)/BMP/WEBP`, `240-8000` 像素, `<=20MB` |
| 參考輸入 | `1-5` 個 `reference-to-video-flash` 與 `reference-to-video` 的 URL；支援最多 `images<=5`、`videos<=3`、`images+videos<=5` 的混合影像與影片 |
| 音訊輸入（`audio_urls`） | 選填的 `1` 個 URL 用於文字轉影片與影像轉影片模式。支援 `wav/mp3` 格式，長度為 `3-30s`，大小不超過 `<=15MB` |
| 閃光音訊開關 | `sound` 僅支援閃光模式，預設為 `true` |

## 端點與身分驗證

API 基底網址：

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

| 方法 | 端點 | 用途 |
| - | - | - |
| `POST` | `/generateTask/wan-2-6-video` | 送出生成任務 |
| `GET` | `/statusTask/wan-2-6-video?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/wan-2-6-video" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video",
      "prompt": "a cinematic fox walking through neon rain",
      "resolution": "720p",
      "duration": 5,
      "prompt_extend": true
    }
  }'
```

成功回應：

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

從您提交的內容中儲存 `data.taskId` 並在狀態請求中使用它。

## 輪詢結果

```bash theme={null}
TASK_ID="paste-your-returned-task-id"
curl -X GET "https://api.apixo.ai/api/v1/statusTask/wan-2-6-video?taskId=$TASK_ID" \
  -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": 1767965752317,
    "costTime": 141388
  }
}
```

任務失敗時的回應範例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "PromptInvalid",
    "failMsg": "Prompt is invalid or rejected",
    "createTime": 1767965610929,
    "completeTime": 1767965620132
  }
}
```

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

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

## 請求體

在送出請求之前，請將範例媒體 URL 替換為可公開存取的檔案

### 文生影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "text-to-video",
    "prompt": "a cinematic fox walking through neon rain",
    "audio_urls": [
      "https://example.com/background.mp3"
    ],
    "negative_prompt": "blurry, low quality",
    "resolution": "1080p",
    "duration": 8,
    "prompt_extend": true,
    "shot_type": "multi",
    "seed": 42,
    "watermark": false
  }
}
```

### 圖生影片

將一張影像動畫化，最長 15 秒。請使用 `image_urls` 並設定一個條目，同時省略僅限閃光模式的 `sound` 欄位

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "prompt": "Move the camera slowly toward the cyclist as she looks up from the map.",
    "image_urls": ["https://example.com/cyclist.png"],
    "duration": 12
  }
}
```

### 圖生影片 Flash

對於帶有音軌的肖像，請將肖像傳入 `image_urls`，並提供一個公眾的 MP3 或 WAV 檔案至 `audio_urls`；啟用 `sound` 可使用音訊。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video-flash",
    "prompt": "make the character speak with subtle camera motion",
    "image_urls": [
      "https://example.com/hero.png"
    ],
    "audio_urls": [
      "https://example.com/voice.mp3"
    ],
    "resolution": "1080p",
    "duration": 5,
    "sound": true
  }
}
```

### 參考生成影片

為每個主題使用單獨的參考文件。陣列順序決定提示中角色名稱的對應關係。這裡，`character1` 指第一張影像中的騎自行車者，`character2` 指第二張影像中的跑步者。參考模式最多支援五個文件（含最多三個影片），並產生 2–10 秒的輸出。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "reference-to-video",
    "prompt": "character1 rolls her bicycle up to character2. They greet each other at the finish line.",
    "reference_urls": [
      "https://example.com/cyclist.png",
      "https://example.com/runner.mp4"
    ],
    "resolution": "720p",
    "duration": 6
  }
}
```

### 參考影片 Flash

若為靜音鏡頭，請將 `sound` 設為 `false`；若為有聲鏡頭，請啟用 `sound` 並使用參考影片剪輯提供角色聲音。兩種參考影片模式均不需提供 `audio_urls`。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "reference-to-video-flash",
    "prompt": "character1 hands the race map to character2 at the finish line.",
    "reference_urls": ["https://example.com/cyclist.png", "https://example.com/runner.mp4"],
    "duration": 6,
    "sound": false
  }
}
```

## 參數

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

取得結果的方式。選擇 `async` 時，透過 `statusTask` 輪詢結果；選擇 `callback` 時，透過 Webhook 接收結果。

**callback\_url** `string`

當 `request_type` 為 `callback` 時必須提供。必須是可接收最終任務載荷的公開回呼 URL。請參閱 [Webhooks](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md)。

**input** `object` *required*

Wan 2.6 Video 的輸入參數。

**屬性**

**mode** `string` *required*

生成模式。可用值為 `text-to-video`、`image-to-video-flash`、`image-to-video`、`reference-to-video-flash`、`reference-to-video`。

**prompt** `string` *required*

提示文字。所有模式都需要，修剪後不能為空。支援中文、英文；最大長度為 `1500` 個字元，多餘的內容將由模型服務截斷。

**negative\_prompt** `string`

選填的否定提示。支援中文、英文；最大長度為 `500` 個字元，多餘的內容將由模型服務截斷。

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

對於 `image-to-video-flash` 與 `image-to-video` 是必需的。必須恰好包含一個 URL。影像約束：格式 `JPEG/JPG/PNG`（無alpha）、`BMP`、`WEBP`；寬度和高度 `240-8000` px；檔案大小 `<= 20MB`。

**reference\_urls** `string[]`

對於 `reference-to-video-flash` 和 `reference-to-video` 是必需的。必須包含 `1-5` 個 URL。支援混合影像/影片，但有限制：影像 `0-5`、影片 `0-3` 且總數 `images + videos <= 5`。每個檔案使用一個主要主題。參考順序對應到角色順序（`character1`、`character2`、...）。啟用音訊時，參考影片還可以提供角色的聲音。參考影片限制：`mp4/mov`、`1-30s`、檔案大小 `<= 100MB`。參考影像限制：`JPEG/JPG/PNG`（無 Alpha）、`BMP`、`WEBP`、寬度/高度 `240-8000` px、檔案大小 `<= 20MB`。

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

選用公共音訊輸入，適用於 `text-to-video`、`image-to-video` 和 `image-to-video-flash`。在兩種參考影片模式中省略此欄位。`reference_urls` 中的參考影片可提供角色的聲音。若提供，須僅傳送一個 URL。音訊限制：格式 `wav/mp3`、持續時間 `3-30s`、檔案大小 `<= 15MB`。若音訊長度超過 `duration`，則使用前 `duration` 秒。若音訊短於輸出影片，則剩餘段落為靜音。在 `image-to-video-flash` 中，將 `sound` 設為 `true` 以使用此音訊。

**resolution** `string`

輸出分辨率層。支援的值：`720p`、`1080p`。預設值：`text-to-video` -> `720p`；`image-to-video` 與 `image-to-video-flash` -> `720p`；`reference-to-video` 與 `reference-to-video-flash` -> `1080p`。

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

接受整數或數字字串輸入。`text-to-video`、`image-to-video-flash` 和 `image-to-video`：`2-15`。`reference-to-video-flash` 和 `reference-to-video`：`2-10`。

**prompt\_extend** `boolean` (default: true)

是否在生成前啟用提示重寫。`true`（預設）啟用重寫，並可改善簡短提示，但可能增加延遲；`false` 停用重寫。

**shot\_type** `string`

可選拍攝模式。支援的值：`single`、`multi`。當 `shot_type` 與快速射擊指令同時存在時，`shot_type` 優先。

**seed** `integer`

從 `0` 到 `2147483647`（含）的可選整數。比較運轉時重複使用種子。結果仍然可能有所不同。

**watermark** `boolean`

可選浮水印開關。`false`（預設）表示無浮水印；`true` 新增固定文字 `AI 生成`（AI 產生）的右下浮水印。

**sound** `boolean` (default: true (flash modes only))

音訊產生開關，適用於 `image-to-video-flash` 與 `reference-to-video-flash`。`true`（預設）啟用音訊產生。`false` 產生無聲影片。若請求為靜音的 `image-to-video-flash`，則忽略 `audio_urls`。

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

設為 `true` 可在支援的生成路由上啟用上游內容審核。API 預設值為 `false`。

## 回應格式

### 送出任務時的回應

任務受理後，`POST /generateTask/wan-2-6-video` 會傳回任務 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`

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

## Webhook 回呼模式

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

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/wan-2-6-video" \
  -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": "image-to-video-flash",
      "prompt": "make the character speak with subtle camera motion",
      "image_urls": [
        "https://example.com/hero.png"
      ],
      "resolution": "720p",
      "duration": 5,
      "sound": false
    }
  }'
```

Webhook 的接收條件與重試規則請見 [Webhook 文件](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)。

Wan 2.6 Video 按秒計費。總成本為 `duration * unitPrice`。

標準（非閃光）模式：

| 模式 | 解析度 | APIXO 官方價格 |
| - | - | - |
| `text-to-video` | `720p` | `$0.10 / second` |
| `text-to-video` | `1080p` | `$0.15 / second` |
| `image-to-video` | `720p` | `$0.10 / second` |
| `image-to-video` | `1080p` | `$0.15 / second` |
| `reference-to-video` | `720p` | `$0.20 / second` |
| `reference-to-video` | `1080p` | `$0.30 / second` |

閃光模式：

| 模式 | 解析度 | `sound=false` | `sound=true` |
| - | - | - | - |
| `image-to-video-flash` | `720p` | `$0.025 / second` | `$0.05 / second` |
| `image-to-video-flash` | `1080p` | `$0.038 / second` | `$0.075 / second` |
| `reference-to-video-flash` | `720p` | `$0.05 / second` | `$0.10 / second` |
| `reference-to-video-flash` | `1080p` | `$0.08 / second` | `$0.16 / second` |

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

## 耗時與輪詢

Wan 2.6 Video 任務是異步的。後端不提供固定的公共延遲SLA；實際延遲因模式、持續時間、解析度、提示複雜性、媒體取得速度和佇列負載而異。

| 工作流程 | 建議首次查詢時間 | 輪詢間隔 |
| - | - | - |
| `text-to-video` | 任務建立 30 秒後 | 10s |
| `image-to-video` / `image-to-video-flash` | 任務建立 30 秒後 | 10s |
| `reference-to-video` / `reference-to-video-flash` | 任務建立 45 秒後 | 10s-15s |

> [!TIP]
>
> 對於生產工作負載，請使用回呼模式以避免對長時間運行的影片作業進行頻繁輪詢。

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

## 錯誤與排查

### HTTP 錯誤

| 代碼 | 含義 | 處理方式 |
| - | - | - |
| `400` | 請求主體、模式、參數或媒體 URL 形狀無效 | 修正請求後再試 |
| `401` | 缺少 API 金鑰，或金鑰無效 | 檢查 `Authorization` 請求標頭 |
| `402` | 餘額或配額不足 | 充值或更換帳號或金鑰 |
| `403` | 金鑰或路由無權訪問該模型 | 檢查權限和路由策略 |
| `429` | 已達到速率或並行限制 | 以指數退避方式重試 |
| `500` | 伺服器錯誤 | 逐步拉長間隔後重試 |
| `502` | 服務錯誤 | 逐步拉長間隔後重試 |
| `504` | 服務超時 | 重試或使用回呼模式 |

### 任務失敗代碼

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

| 錯誤碼 | 含義 | 處理方式 |
| - | - | - |
| `PromptInvalid` | 提示無效或被模型服務拒絕 | 修改提示詞後再試一次 |
| `MissingParameter` / `BadRequest` | 必填欄位缺失或格式錯誤 | 檢視各模式所需的必填欄位 |
| `SensitiveContent` / `SensitiveContentDetected` | 提示或媒體未通過安全檢查 | 更動提示或媒體 |
| `RateLimitExceeded` | 已達到模型服務或路線速率限制 | 以指數退避方式重試 |
| `Task TimeOut` / `Timeout` | 模型生成超時 | 重試或使用回呼模式 |

### 參數排查

* `prompt` 是必需的，並且對於所有模式都必須非空。
* `image-to-video-flash` 與 `image-to-video` 必須 exactly 一個 `image_urls` 項目。
* `reference-to-video-flash` 和 `reference-to-video` 需要 `reference_urls` 和 `1-5` 項目。
* `sound` 僅對閃光模式有效。
* `duration` 預設為 `5`，但 `reference` 模式最多只允許 `10`。
* 對於自訂音軌，請在啟用聲音的情況下將 `audio_urls` 與 `text-to-video`、`image-to-video` 或 `image-to-video-flash` 結合使用。對於參考模式，請使用角色聲音的參考影片剪輯。

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

## MCP 整合

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/wan-2-6-video.json) 中的 `mcp.result` 指定結果的解析方式，`mcp.attachments` 列出可繫結檔案的欄位。這些中繼資料供用戶端整合使用，無須當作生成參數提交。附件欄位為 `image_urls`, `reference_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 試用 Wan 2.6 Video](https://apixo.ai/models/wan-2-6-video)
* [API定價](https://apixo.ai/pricing/api)


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