> ## 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/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/api-reference/webhooks.md)。

## 计费

新提交的非 LLM 请求按 **1 积分 = `$0.001`** 计费。先按用量和附加项目计算总额，再应用账号折扣，最后将请求总额向上取整到整数积分。如果约定了固定单价，则按该单价的原始精度计算，不再使用标准价或另行打折；最终积分仍向上取整。详见[积分换算与取整](https://apixo.ai/docs/zh/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/api-reference/system.md)。

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 请求体、参数类型或值无效 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `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/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/models.md)
* [图像模型](https://apixo.ai/docs/zh/models/image)
* [提交生成任务](https://apixo.ai/docs/zh/api-reference/generate-task.md)
* [查询任务状态](https://apixo.ai/docs/zh/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)
* [错误码](https://apixo.ai/docs/zh/api-reference/errors.md)
* [参数规范](https://apixo.ai/docs/zh/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.