> ## 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 個字元 |
| 參考圖片 | 僅支援 1 個 URL 用於 `image-to-image` |
| 每個任務的影像數量 | `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-hant/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-hant/api-reference/webhooks.md)。

## 計費

新提交的非 LLM 請求按 **1 點 = `$0.001`** 計費。先依用量和加購項目計算總額，再套用帳戶折扣，最後將請求總額無條件進位至整數點數。若已約定固定單價，則保留該單價的精度，不再使用標準價或另行打折；最終點數仍須進位。詳見[積分換算與進位](https://apixo.ai/docs/zh-hant/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-hant/api-reference/system.md)。

## 錯誤與排查

### HTTP 錯誤

| 代碼 | 含義 | 處理方式 |
| - | - | - |
| `400` | 請求主體、模式、參數或影像 URL 形狀無效 | 修正請求後再試 |
| `401` | 缺少 API 金鑰，或金鑰無效 | 檢查 `Authorization` 請求標頭 |
| `402` | 餘額或配額不足 | 充值或更換帳號或金鑰 |
| `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-hant/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-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)
* [路由策略](https://apixo.ai/docs/zh-hant/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.