> ## 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.7 Image API：全能图像生成

> 使用阿里巴巴 Wan 2.7 Image API 生成视觉资产，支持全图像和全图像专业生成模式，提供丰富的风格化控制。

## 概览

Wan 2.7 Image 是阿里巴巴的图像模型，可根据文字生成图像、编辑图片或生成系列图。在 APIXO Playground 试用后，可以按本页示例调用 API。

| 功能 | 值 |
| - | - |
| 模型 ID | `wan-2-7-image` |
| 模式 | `omni-image`, `omni-image-pro` |
| 提示词 | 必填，非空；支持中文和英文；最大 `5000` 个字符（模型端截断） |
| 输入图像 | 可选的 `image_urls`，最多支持 `1-9` 个 URL（若提供） |
| 图像数量限制（`image_urls`） | `JPEG/JPG/PNG(no alpha)/BMP/WEBP`、宽度/高度 `240-8000` 像素、比例 `1:8-8:1`、文件大小 `<=20MB` |
| 分辨率档位 | `1k`, `2k`, `4k` |
| 4K 支持 | 仅当`mode=omni-image-pro`、无`image_urls`和`enable_sequential=false`时 |
| 输出数量 (`num_images`) | `1-4` 什么时候 `enable_sequential=false` （默认 `1`); `1-12` 什么时候 `enable_sequential=true` |
| 交互式编辑框 | `bbox_list`需要`image_urls`；列表长度必须与图像数量匹配；每个图像最多支持 `2` 个框 |
| 调色板控制 | `color_palette`仅当`enable_sequential=false`时可用； `3-10` 颜色；比率总和必须为 `100.00%` |

## 接口与身份验证

API 基础地址：

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

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/wan-2-7-image` | 提交生成任务 |
| `GET` | `/statusTask/wan-2-7-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-7-image" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "omni-image-pro",
      "prompt": "a cinematic panda walking through snow",
      "resolution": "2k",
      "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-7-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": "omni-image-pro",
    "prompt": "a cinematic panda walking through snow",
    "resolution": "4k",
    "num_images": 2,
    "enable_sequential": false,
    "watermark": false,
    "seed": 42
  }
}
```

### 图像编辑

```json theme={null}
{
  "request_type": "callback",
  "callback_url": "https://your-server.com/webhooks/apixo",
  "input": {
    "mode": "omni-image",
    "image_urls": [
      "https://example.com/base.png",
      "https://example.com/style.png"
    ],
    "prompt": "blend the style naturally and keep lighting consistent",
    "resolution": "2k",
    "num_images": 1,
    "bbox_list": [
      [[120, 180, 360, 420]],
      []
    ]
  }
}
```

## 参数

**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.7 Image 的输入参数。

**属性**

**mode** `string` *required*

生成模式。可选值为 `omni-image`、`omni-image-pro`。

**prompt** `string` *required*

提示文字。对于所有请求都是必需的，并且修剪后不能为空。支持中/英文，最大长度为`5000`个字符，超出的内容将被模型服务截断。

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

可选的图像输入列表。如果提供，必须包含 `1-9` 图像 URL。图像约束：格式`JPEG/JPG/PNG`（无alpha）、`BMP`、`WEBP`；宽度/高度 `240-8000` 像素；长宽比 `1:8-8:1`；文件大小 `<=20MB`。

**resolution** `string` (default: 2k)

输出分辨率层级。支持的值：`1k`、`2k`、`4k`。当 `mode=omni-image` 时，不支持 `4k`；仅当 `mode=omni-image-pro`、`image_urls` 为空且 `enable_sequential=false` 时，才支持 `4k`。

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

请求的输出数量。支持整数或数字字符串输入。当 `enable_sequential=false` 时，范围为 `1-4`；当 `enable_sequential=true` 时，范围为 `1-12`。

**enable\_sequential** `boolean` (default: false)

顺序/组生成切换。`false`（默认）表示正常生成；`true` 表示启用顺序生成模式。

**bbox\_list** `array[array[array[integer]]]`

可选的交互式编辑框。需要 `image_urls`。结构为 `bbox_list[image_index][box_index] = [x1,y1,x2,y2]`。外部列表长度必须等于 `image_urls` 的长度。每个图像最多支持 `2` 个框。每个框必须恰好包含 `4` 个整数，并满足 `0<=x1<x2` 且 `0<=y1<y2`。示例：`[[[120,180,360,420]], []]`。

**color\_palette** `array`

可选的自定义颜色主题。仅当 `enable_sequential=false` 时可用。必须包含 `3-10` 种颜色。每个颜色对象必须包含 `hex`（`#RRGGBB`）和 `ratio`（`xx.xx%`）。所有比率值之和必须为 `100.00%`。

**negative\_prompt** `string`

可选的负面提示，用于减少不需要的视觉元素。最大长度为 5000 个字符。

**watermark** `boolean` (default: false)

是否添加水印。`false`（默认）表示不添加水印；`true` 时将在右下角添加固定文本 `AI 生成`（AI 生成）的水印。

**thinking\_mode** `boolean` (default: true (model-side))

思维模式开关。仅在 `enable_sequential=false` 且未提供输入图像时有效。启用后，模型可提升对复杂提示的理解能力，但会带来额外延迟。

**seed** `integer`

可选的随机种子。支持范围：`0-2147483647`。固定种子可提高输出可重现性，但相同种子不能保证输出完全一致。

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

设为 `true` 可在支持的生成路由上启用上游内容审核。API 默认值为 `false`。

## 响应格式

### 提交任务时的响应

任务受理后，`POST /generateTask/wan-2-7-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-7-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": "omni-image-pro",
      "prompt": "a premium product poster with soft studio light",
      "resolution": "2k",
      "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)。

Wan 2.7 Image 按生成的图像计费。

| 模式 | APIXO 价格 |
| - | - |
| `omni-image` | `$0.03 / image` |
| `omni-image-pro` | `$0.075 / image` |

计费行为：

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

有关当前公开定价的信息，请参阅 [API 定价](https://apixo.ai/pricing/api)。如果未列出价格，请在提交任务之前联系 APIXO 支持人员进行确认。

## 延迟与轮询

Wan 2.7 Image 任务是异步的。后端不提供固定的公共延迟SLA；实际延迟因提示复杂性、请求的图像计数、图像输入获取速度和队列负载而异。

| 工作流程 | 建议首次查询时间 | 轮询间隔 |
| - | - | - |
| 纯文本生成 | 任务创建 10 秒后 | 5s-10s |
| 图像编辑/多图像输入 | 任务创建 10 至 15 秒后 | 5s-10s |
| 顺序生成 (`enable_sequential=true`) | 任务创建 15 秒后 | 8s-12s |

> [!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` 必须是`omni-image` 或`omni-image-pro`。
* `prompt` 为必填项，不能为空。
* `resolution` 仅支持 `1k`、`2k`、`4k`。
* `4k` 在 `mode=omni-image`、`enable_sequential=true` 或提供 `image_urls` 时无效。
* `num_images` 的范围取决于 `enable_sequential`：为假时为 `1-4`，为真时为 `1-12`。
* `image_urls` 支持最多 `1-9` 个图像 URL（如果提供）。
* `bbox_list` 需要 `image_urls`，其长度必须与 `image_urls` 匹配，且每个图像最多支持 `2` 个框。
* `color_palette` 仅在 `enable_sequential=false` 时可用，包含 `3-10` 种颜色，总比例为 `100.00%`。

完整列表见[错误码](https://apixo.ai/docs/zh/api-reference/errors.md)。

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/image/wan-2-7-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.7 Image](https://apixo.ai/models/wan-2-7-image)
* [API定价](https://apixo.ai/pricing/api)


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