> ## 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 Image API：阿里巴巴的文字生成圖片模型

> Wan 2.6 Image API 用於文生圖和圖生圖生成，最多具有三個輸出和固定 2K 圖生圖結果

## 概覽

Wan 2.6 Image 是阿里巴巴的影像模型，支援文字生成圖片和以圖生圖。在 APIXO Playground 試用後，可依本頁範例呼叫 API。

| 功能 | 值 |
| - | - |
| 模型 ID | `wan-2-6-image` |
| 模式 | `text-to-image`, `image-to-image` |
| 提示詞 | 兩種模式都需要，非空；支援中文/英文；最大 `2000` 個字元（模型端截斷） |
| 負面提示 | 選項；支援中文或英文；最多 `500` 個字元（模型端截斷） |
| 輸出計數 (`num_images`) | `1-3`（預設`1`） |
| 文字與影像的比例 | `1:1`, `3:4`, `4:3`, `9:16`, `16:9` |
| 圖生圖輸入 | 需提供 `image_urls`，且包含 `1-3` 個影像 URL |
| 輸入圖片限制（`image_urls`） | `JPEG/JPG/PNG(no alpha)/BMP/WEBP`、寬度/高度 `240-8000` px、檔案大小 `<=10MB` |
| 圖生圖的輸出尺寸 | 固定 `2K` |

## 端點與身分驗證

API 基底網址：

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

| 方法 | 端點 | 用途 |
| - | - | - |
| `POST` | `/generateTask/wan-2-6-image` | 送出生成任務 |
| `GET` | `/statusTask/wan-2-6-image?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-image" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-image",
      "prompt": "a cinematic panda walking through snow",
      "aspect_ratio": "1:1",
      "num_images": 1
    }
  }'
```

成功回應：

```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-6-image?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/image.png\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
```

任務失敗時的回應範例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "InvalidParameter",
    "failMsg": "The parameter is invalid",
    "createTime": 1767965610929,
    "completeTime": 1767965620132
  }
}
```

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

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

## 請求體

### 文生圖

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "text-to-image",
    "prompt": "a cinematic panda walking through snow",
    "negative_prompt": "low quality, blurry",
    "aspect_ratio": "16:9",
    "num_images": 1,
    "seed": 42
  }
}
```

### 圖生圖

```json theme={null}
{
  "request_type": "callback",
  "callback_url": "https://your-server.com/webhooks/apixo",
  "input": {
    "mode": "image-to-image",
    "image_urls": [
      "https://example.com/base.png",
      "https://example.com/style.png"
    ],
    "prompt": "make the scene look like a cinematic watercolor illustration",
    "negative_prompt": "overexposed, noisy",
    "num_images": 1,
    "seed": 42
  }
}
```

## 參數

**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 Image 的輸入參數。

**屬性**

**mode** `string` *required*

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

**prompt** `string` *required*

提示文字。兩種模式皆需提供，修剪後不得為空。支援中文與英文，最大長度為`2000`個字元，超出內容將由模型服務截斷。

**negative\_prompt** `string`

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

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

僅支援文生圖。支援的值：`1:1`、`3:4`、`4:3`、`9:16`、`16:9`。在 `image-to-image` 情況下，此欄位將被忽略。

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

僅圖生圖。必需且必須包含 `1-3` 影像 URL。影像約束：格式 `JPEG/JPG/PNG`（無alpha）、`BMP`、`WEBP`；寬度和高度 `240-8000` px；檔案大小 `<=10MB`。

**num\_images** `integer` (default: 1)

輸出影像的數量。支援 `1-3`。接受整數輸入（亦可接受數值字串）。

**seed** `integer`

可選的隨機種子。支援範圍：`0-2147483647`。使用固定種子可提升輸出的可重現性，但相同種子並不能保證輸出完全一致。

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

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

## 回應格式

### 送出任務時的回應

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

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

若至少一張圖像成功，該任務仍可回傳 `success`，且 `resultJson.resultUrls` 中僅包含成功的圖像。

## Webhook 回呼模式

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

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/wan-2-6-image" \
  -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-image",
      "image_urls": [
        "https://example.com/source-1.png"
      ],
      "prompt": "turn this into a cinematic movie still",
      "num_images": 1
    }
  }'
```

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)。

以下價格與主要價格相符 [API 定價](https://apixo.ai/pricing/api) 十月檢視目錄的公共基本價格表 22, 2026。在製定預算之前，請檢查該頁面的當前費率和任何帳戶折扣。

Wan 2.6 Image 依產生的影像計費。

| 模式 | APIXO 價格 |
| - | - |
| `fixed` | `$0.04 / image` |

計費行為：

```text theme={null}
precharge = requested_num_images * 0.04
final_charge = successful_images * 0.04
refund = precharge - final_charge (if partial failure)
```

有關當前公開定價的信息，請參閱 [API 定價](https://apixo.ai/pricing/api)。如果未列出價格，請在送出任務之前聯絡 APIXO 支援人員進行確認。

## 耗時與輪詢

Wan 2.6 Image 任務是異步的。後端不提供固定的公共延遲SLA；實際延遲會因提示複雜性、請求的影像數量、影像輸入取得速度及佇列負載而異。

| 工作流程 | 建議首次查詢時間 | 輪詢間隔 |
| - | - | - |
| `text-to-image` | 任務建立 10 秒後 | 5s-10s |
| `image-to-image` | 任務建立 10 至 15 秒後 | 5s-10s |

> [!TIP]
>
> 正式環境中請使用回呼模式，避免頻繁輪詢。

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

## 錯誤與排查

### HTTP 錯誤

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

### 任務失敗代碼

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

| 錯誤碼 | 含義 | 處理方式 |
| - | - | - |
| `PromptInvalid` | 提示無效或被模型服務拒絕 | 修改提示詞後再試一次 |
| `MissingParameter` / `BadRequest` | 必填欄位缺失或格式錯誤 | 檢查必填欄位和類型 |
| `SensitiveContentDetected` / `ProhibitedContentDetected` | 提示或影像輸入未通過安全性檢查 | 重寫提示或變更輸入影像 |
| `RateLimitExceeded` | 已達到模型服務或路線速率限制 | 逐步拉長間隔後重試 |
| `Task TimeOut` / `Timeout` | 生成任務逾時 | 重試或使用回呼模式 |

### 參數排查

* `mode` 必須是 `text-to-image` 或 `image-to-image`。
* 兩種模式都需要 `prompt`，且不能為空。
* `num_images`僅支援 `1-3`，預設為 `1`。
* `aspect_ratio`僅對 `text-to-image` 有效。
* `image_urls` 是 `image-to-image` 所必需的，並且必須包含 `1-3` 影像 URL。
* 在`image-to-image`中，輸出尺寸固定為`2K`。

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

## MCP 整合

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

## 相關連結

* [生成 API 總覽](https://apixo.ai/docs/zh-hant/models.md)
* [影像模型](https://apixo.ai/docs/zh-hant/models/image)
* [送出生成任務](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.6 Image](https://apixo.ai/models/wan-2-6-image)
* [API定價](https://apixo.ai/pricing/api)


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