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

# MiniMax Image 01 API：根据文字生成图像

> 使用 MiniMax Image 01 API 生成高分辨率、成本高效的视觉内容，支持异步生成、状态轮询和 Webhook 交付。

## 概览

MiniMax Image 01 是用于文生图生成和单参考图像编辑的图像生成模型。它支持按图像计费、每个任务最多生成 9 张图像、灵活的 `size` 输入，以及通过 `resolution + aspect_ratio` 配置预设输出尺寸。

| 功能 | 值 |
| - | - |
| 模型 ID | `minimax-image-01` |
| 模式 | `text-to-image`, `image-to-image` |
| 提示词长度 | 1 至 1500 个字符 |
| 参考图片 | `image-to-image` 仅支持 1 个 URL |
| 每个任务的图像数量 | `num_images` 支持 1-9 |
| 分辨率档位 | `1K`, `2K` |
| 纵横比 | `1:1`, `16:9`, `4:3`, `3:2`, `2:3`, `3:4`, `9:16`, `21:9` |
| 尺寸输入 | `1024*1024`, `1024x1024`, `1024X1024` |
| 种子范围 | `-1`至`2147483647` |
| 提示优化器 | `true`, `false` |

## 接口与身份验证

API 基础地址：

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

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/minimax-image-01` | 提交生成任务 |
| `GET` | `/statusTask/minimax-image-01?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/minimax-image-01" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": {
      "mode": "text-to-image",
      "prompt": "a cinematic panda standing in a rainy neon alley",
      "resolution": "2K",
      "aspect_ratio": "16:9",
      "num_images": 3,
      "prompt_optimizer": false,
      "seed": -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/minimax-image-01?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-1.png\",\"https://file.apixo.ai/image-2.png\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
```

任务失败时的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "UPSTREAM_ERROR",
    "failMsg": "Generation failed",
    "createTime": 1767965610929,
    "completeTime": 1767965620132
  }
}
```

## 请求体

### 文生图

```json theme={null}
{
  "input": {
    "mode": "text-to-image",
    "prompt": "a fashion editorial portrait with dramatic side lighting",
    "resolution": "2K",
    "aspect_ratio": "3:4",
    "num_images": 2,
    "prompt_optimizer": false
  }
}
```

### 图生图

```json theme={null}
{
  "input": {
    "mode": "image-to-image",
    "prompt": "transform this image into a watercolor illustration",
    "image_urls": [
      "https://example.com/reference.png"
    ],
    "size": "1280x720",
    "num_images": 3,
    "prompt_optimizer": true,
    "seed": 42
  }
}
```

## 参数

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

结果获取方式。选择 `async` 时，通过 `statusTask` 轮询结果；选择 `callback` 时，通过 Webhook 接收结果。

**callback\_url** `string`

当 `request_type` 为 `callback` 时必填。请提供公网可访问的 HTTPS 地址，用于接收任务的最终结果。详见 [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

**input** `object` *required*

MiniMax Image 01 的输入参数。

**属性**

**mode** `string` *required*

生成模式。可选值为 `text-to-image`、`image-to-image`。

**prompt** `string` *required*

用文字描述要生成的图像或要做的修改。去除首尾空白后，长度须为 1 至 1500 个字符。

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

参考图像 URL。`image-to-image` 所需。支持 1 个公共图像 URL。图像必须为 JPG、JPEG 或 PNG，且不大于 10 MB。

**size** `string` (default: 1024\*1024)

可选的显式输出大小。支持 `WIDTH*HEIGHT`、`WIDTHxHEIGHT` 和 `WIDTHXHEIGHT`，例如 `1024*1024`、`1024x1024` 或 `1024X1024`。宽度和高度必须分别在 `512` 和 `2048` 之间。如果尺寸不能被 `8` 整除，APIXO 会自动将其标准化为 `8` 的最接近有效倍数。

**resolution** `string`

可选的输出分辨率预设。支持的值：`1K`、`2K`。当 `resolution + aspect_ratio` 和 `size` 同时提供时，`resolution + aspect_ratio` 优先。

**aspect\_ratio** `string`

可选的输出纵横比。支持的值：`1:1`、`16:9`、`4:3`、`3:2`、`2:3`、`3:4`、`9:16`、`21:9`。

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

请求的图像数量。支持范围：`1-9`。

**prompt\_optimizer** `boolean` (default: false)

是否启用生成前提示优化。

**seed** `integer` (default: -1)

随机种子。支持的范围：`-1` 至 `2147483647`。使用 `-1` 表示非确定性输出。

### 尺寸预设基于 `resolution + aspect_ratio`

当提供 `resolution + aspect_ratio` 时，APIXO 将根据这些预设确定最终输出尺寸：

| 纵横比 | `1K` 尺寸 | `2K` 尺寸 |
| - | - | - |
| `1:1` | `1024x1024` | `2048x2048` |
| `16:9` | `1280x720` | `2048x1152` |
| `4:3` | `1152x864` | `2048x1536` |
| `3:2` | `1248x832` | `2048x1368` |
| `2:3` | `832x1248` | `1368x2048` |
| `3:4` | `864x1152` | `1536x2048` |
| `9:16` | `720x1280` | `1152x2048` |
| `21:9` | `1344x576` | `2048x880` |

## 响应格式

### 提交任务时的响应

任务受理后，`POST /generateTask/minimax-image-01` 会返回任务 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/minimax-image-01" \
  -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-image",
      "prompt": "a clean product photo of wireless earbuds on soft stone",
      "resolution": "1K",
      "aspect_ratio": "1:1",
      "num_images": 2
    }
  }'
```

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

MiniMax Image 01 按每张生成的图像计费，采用统一的公共 APIXO 价格。

| 单位 | APIXO 价格 |
| - | - |
| 每张生成的图像 | `$0.004 / image` |

计费行为：

```text theme={null}
precharge = requested num_images * unit price
final charge = successful images * unit price
```

如果成功输出的图像数量少于要求的数量，APIXO 会自动将最终费用调整为成功输出的实际数量。

## 延迟与轮询

实际延迟可能因提示复杂性、提供商路由和当前队列负载而异。

| 分辨率 | 通常生成耗时 | 建议首次查询时间 | 轮询间隔 |
| - | - | - | - |
| `1K` | 15s-30s | 任务创建 15 秒后 | 3s-5s |
| `2K` | 20s-40s | 任务创建 20 秒后 | 3s-5s |

> [!TIP]
>
> 生产环境并发量较高时，建议使用回调，以免频繁轮询。

## 尺寸规则

* `size`支持`*`、`x`和`X`作为分隔符。
* 显式 `size` 要求宽度和高度每次都保持在 `512-2048` 范围内。
* 如果 `size` 尺寸不能被 `8` 整除，则 APIXO 将其舍入为 `8` 最接近的有效倍数。
* 当同时提供`size`和`resolution + aspect_ratio`时，`resolution + aspect_ratio`优先。
* 如果 `size` 和 `resolution + aspect_ratio` 均未提供，则默认输出尺寸为 `1024*1024`。

请求频率和并发上限因账号、API 密钥和路由而异。收到 `429` 时，请降低请求频率，逐步延长重试间隔。账号级限制见[系统 API](https://apixo.ai/docs/zh/api-reference/system.md)。

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 请求体、模式、参数或图像 URL 形状无效 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `403` | 密钥或路由无权访问该模型 | 检查权限和路由策略 |
| `429` | 已达到速率或并发限制 | 按指数退避策略重试 |
| `500` | 服务器错误 | 逐步延长间隔后重试 |
| `502` | 服务错误 | 逐步延长间隔后重试 |
| `504` | 服务超时 | 重试；耗时较长的任务可改用回调模式 |

### 任务失败错误码

| 错误码 | 含义 | 处理方式 |
| - | - | - |
| `INVALID_PARAMETER` | 模型参数不受支持、超出范围或格式错误 | 检查`mode`、`size`、`resolution`、`aspect_ratio`和`image_urls` |
| `INVALID_IMAGE_URL` | 无法获取或解码参考图像 URL | 使用公开的直接图像 URL |
| `INSUFFICIENT_BALANCE` | 该账户没有足够的余额来执行任务 | 重试前需添加余额 |
| `UPSTREAM_ERROR` | 服务无法完成任务 | 使用退避重试或尝试其他路径 |
| `TIMEOUT` | 生成任务超时 | 重试、降低输入复杂度或使用回调模式 |

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

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/image/minimax-image-01.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)
* [路由策略](https://apixo.ai/docs/zh/concepts/routing-strategies.md)
* [在 APIXO Playground 中尝试 MiniMax Image 01](https://apixo.ai/models/minimax-image-01)
* [API定价](https://apixo.ai/pricing/api)


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