> ## 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.5 Video API：文字生成影片與圖片生成影片

> 用於文字轉影片和影像到影片工作流程的阿里巴巴式影片生成 API

## 概覽

Wan 2.5 根據文字提示或一張參考影像加提示產生短影片。

| 功能 | 值 |
| - | - |
| 模型 ID | `wan-2-5-video` |
| 模式 | `text-to-video`, `image-to-video` |
| 提示詞 | 最多 `1500` 個字元（`text-to-video` 必需且非空，`image-to-video` 可選） |
| 負面提示 | 可選，最多 `500` 個字元 |
| 參考圖片 | `image-to-video` 剛好需要 1 URL；`JPEG/JPG/PNG(no alpha)/BMP/WEBP`，寬度和高度 `240-8000` px，檔案大小 `<=20MB` |
| 音訊輸入 | `audio_urls` 可選，與 1 URL 完全相同； `wav/mp3`、`3-30s`、檔案大小 `<=15MB` |
| 可用解析度 | `480p`, `720p`, `1080p` |
| 長度 | `5` 或 `10` 秒 |
| 提示重寫 | `prompt_extend` 可選布林值；`true`（預設）啟用重寫，`false` 停用重寫 |
| 文字與影片的寬高比 | `16:9`, `9:16`, `1:1`（所有解析度），加上 `4:3`, `3:4` 用於 `720p`/`1080p` |

## 端點與身分驗證

API 基底網址：

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

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

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

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

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

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

## 非同步請求範例

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/wan-2-5-video" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video",
      "prompt": "a cinematic shot of clouds drifting over a quiet mountain lake",
      "audio_urls": [
        "https://example.com/music.mp3"
      ],
      "resolution": "720p",
      "duration": 5,
      "aspect_ratio": "16:9",
      "prompt_extend": true
    }
  }'
```

成功回應：

```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/wan-2-5-video?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": 1767965752317,
    "costTime": 141388
  }
}
```

任務失敗時的回應範例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "INVALID_PARAMETER",
    "failMsg": "The parameter {{resolution}} is invalid",
    "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 serene mountain landscape with moving clouds and gentle breeze",
    "audio_urls": [
      "https://example.com/music.mp3"
    ],
    "resolution": "480p",
    "duration": 5,
    "aspect_ratio": "1:1",
    "prompt_extend": true,
    "negative_prompt": "low quality, blurry",
    "watermark": false,
    "seed": 20260413
  }
}
```

### 圖生影片

```json theme={null}
{
  "request_type": "callback",
  "callback_url": "https://your-server.com/webhooks/apixo",
  "input": {
    "mode": "image-to-video",
    "image_urls": [
      "https://example.com/reference.png"
    ],
    "prompt": "turn this photo into a smooth cinematic shot with a slow push-in camera move",
    "audio_urls": [
      "https://example.com/music.mp3"
    ],
    "resolution": "1080p",
    "duration": 10
  }
}
```

## 參數

**request\_type** `string` *required* (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*

Wan 2.5 的輸入參數。

**屬性**

**mode** `string` *required*

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

**prompt** `string`

提示文字。`text-to-video` 必需；`image-to-video` 可選。支援中文、英文；最大長度為 `1500` 個字元

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

參考影像URL列表。 `image-to-video` 所需。必須恰好包含 1 URL。影像限制：格式`JPEG/JPG/PNG`（無alpha）、`BMP`、`WEBP`；寬度與高度 `240-8000` px；檔案大小 `<= 20MB`。

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

可選音訊 URL 清單。完全支援 1 URL。音訊限制：格式 `wav/mp3`、持續時間 `3-30s`、檔案大小 `<= 15MB`。如果音訊長於 `duration`，則僅使用前 `duration` 秒；如果音訊短於輸出影片持續時間，則剩餘片段將保持靜音。

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

輸出解析度。可用值為 `480p`、`720p`、`1080p`。

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

輸出長度，以秒為單位。可用值為 `5`、`10`。

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

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

**aspect\_ratio** `string` (default: 16:9)

限文字轉影片。`480p` 支援 `16:9`、`9:16`、`1:1`；`720p` 與 `1080p` 支援 `16:9`、`9:16`、`1:1`、`4:3`、`3:4`。

**negative\_prompt** `string`

選填的負面提示，描述要避免的內容。支援中文、英文；最大長度為 `500` 個字元。

**watermark** `boolean`

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

**seed** `integer`

`[0, 2147483647]` 中選填的隨機種子。固定種子可以提高再現性，但相同的種子並不能保證相同的產出。

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

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

## 回應格式

### 送出任務時的回應

任務受理後，`POST /generateTask/wan-2-5-video` 會傳回任務 ID：

**code** `integer`

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

**message** `string`

狀態說明。

**data.taskId** `string`

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

### 狀態回應欄位

**taskId** `string`

任務的唯一識別碼。

**state** `string`

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

**resultJson** `string`

內含生成影片 URL 的 JSON 字串。`state` 為 `success` 時傳回。

**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-5-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": "text-to-video",
      "prompt": "a polished product demo video with gentle camera movement",
      "resolution": "720p",
      "duration": 5,
      "aspect_ratio": "16:9"
    }
  }'
```

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.5 依生成的秒數計費。

| 模式 | 解析度 | 單價 |
| - | - | - |
| `text-to-video` | `480p` | `$0.05 / second` |
| `text-to-video` | `720p` | `$0.10 / second` |
| `text-to-video` | `1080p` | `$0.15 / second` |
| `image-to-video` | `480p` | `$0.05 / second` |
| `image-to-video` | `720p` | `$0.10 / second` |
| `image-to-video` | `1080p` | `$0.15 / second` |

最終成本公式：

```text theme={null}
total_cost = duration_seconds * resolution_unit_price
```

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

## 耗時與輪詢

影片生成是長期運行的。實際延遲可能會因提示複雜度、模式、所選解析度和目前佇列負載而異。

| 請求結構 | 一般生成時間 | 建議首次查詢時間 | 輪詢間隔 |
| - | - | - | - |
| `480p` | 40s-120s | 任務建立 40 秒後 | 10s |
| `720p` | 60s-180s | 任務建立 60 秒後 | 10s |
| `1080p` | 90s-250s | 任務建立 90 秒後 | 10s |

> [!TIP]
>
> 正式環境的並行請求較多時，建議使用回呼，以免頻繁輪詢。

實用注意事項：

* `aspect_ratio` 僅與 `text-to-video` 一起使用。
* `audio_urls` 支援 1 個 MP3/WAV URL，最大支援 15 MB；建議的持續時間範圍是 3-30 秒。
* 對於 `image-to-video`，`image_urls` 必須恰好包含一張影像 URL，且影像檔案最多應為 20 MB。
* 結果 URL 是臨時的。及時下載重要輸出。

請求頻率與並行數上限會依帳戶、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` | 第三方模型逾時 | 重新嘗試；耗時較長的任務可改用回呼模式 |

### 任務失敗代碼

| 錯誤碼 | 含義 | 處理方式 |
| - | - | - |
| `CONTENT_VIOLATION` | 提示或參考影像未通過安全性檢查 | 更改提示或輸入影像 |
| `INVALID_IMAGE_URL` | 無法取得或解碼參考影像 URL | 使用公共、直接媒體 URL |
| `INVALID_PARAMETER` | 模型參數不受支援或格式錯誤 | 檢查`mode`、`resolution`、`duration`、`aspect_ratio`、`image_urls`和`audio_urls` |
| `INSUFFICIENT_BALANCE` | 該帳戶沒有足夠的餘額來執行任務 | 重試前加結餘額 |
| `TIMEOUT` | 生成任務逾時 | 重試、降低輸入複雜度或使用回呼模式 |

### 參數排查

* `prompt`對於`text-to-video`是必需的，對於`image-to-video`是選填的。
* `image_urls` 僅對於 `image-to-video` 是必需的，並且必須恰好包含一個 URL。
* `audio_urls` 在提供時僅支援一個 MP3/WAV URL；檔案大小應≤ 15 MB，建議的持續時間範圍為 3-30 秒。
* 省略時，`resolution` 預設為 `1080p`。
* 省略時，`duration` 預設為 `5`，且僅接受 `5` 或 `10`。
* `aspect_ratio`僅適用於`text-to-video`。

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

## MCP 整合

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


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