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

# Qwen Image 3.0 Pro API：高保真影像生成

> Qwen Image 3.0 Pro 影像生成和編輯 API 實現更高保真度的文生圖和圖生圖工作流程

## 概覽

Qwen Image 3.0 Pro 是一個非同步影像產生和編輯 API，用於提供更高保真度的輸出。使用 `text-to-image` 進行僅依提示生成，或使用 `image-to-image` 時，可透過一至三張參考影像指導輸出。

| 功能 | 值 |
| - | - |
| 模型 ID | `qwen-image-3-0-pro` |
| 模式 | `text-to-image`, `image-to-image` |
| 輸出數量 | `num_images` 支援 `1-6`；預設為 `1` |
| 提示詞 | 必填，且必須是非空字串 |
| 圖生圖提示長度限制 | 最多 `800` 個字元 |
| 參考圖片 | `image-to-image` 模式下必須提供；需為 `1-3` 個公開影像的 URL |
| 縱橫比 | `WIDTH:HEIGHT` 比例範圍為 `1:8` 至 `8:1`；常見值包含 `1:1`、`4:3`、`3:4`、`16:9`、`9:16` |
| 預設寬高比 | `1:1` 為 `text-to-image`；省略 `image-to-image` 比例將遵循第一張輸入影像 |
| 解析度級距 | `1k`, `2k` |
| 客製尺寸 | 選填 `size` 在 `WIDTHxHEIGHT` 或 `WIDTH*HEIGHT`；優先於 `resolution` 和 `aspect_ratio` |
| 提示詞擴寫 | `enable_prompt_expansion`，預設 `true` |
| 種子 | `-1` 為隨機，或 `0-2147483647` |

## 端點與身分驗證

API 基底網址：

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

| 方法 | 端點 | 用途 |
| - | - | - |
| `POST` | `/generateTask/qwen-image-3-0-pro` | 提交影像生成或編輯任務 |
| `GET` | `/statusTask/qwen-image-3-0-pro?taskId={taskId}` | 查詢任務狀態並取得結果 |

每個請求都必須附上 APIXO API 金鑰：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

送出任務時，還需設定以下請求標頭：

```http theme={null}
Content-Type: application/json
```

## 非同步請求範例

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/qwen-image-3-0-pro" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-image",
      "prompt": "a premium product launch poster with crisp readable typography, realistic studio lighting, refined layout",
      "aspect_ratio": "16:9",
      "resolution": "2k",
      "num_images": 1,
      "enable_prompt_expansion": true,
      "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/qwen-image-3-0-pro?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 high-end editorial key visual for a fashion campaign, crisp typography, elegant lighting",
    "aspect_ratio": "9:16",
    "resolution": "2k",
    "num_images": 2,
    "negative_prompt": "blur, low quality",
    "watermark": false,
    "enable_prompt_expansion": true,
    "prompt_extend_mode": "agent",
    "seed": -1
  }
}
```

### 圖生圖

```json theme={null}
{
  "request_type": "callback",
  "callback_url": "https://your-server.com/webhooks/apixo",
  "input": {
    "mode": "image-to-image",
    "prompt": "upgrade this product photo into a high-end catalog image, preserve the product shape, improve lighting and background",
    "image_urls": [
      "https://example.com/product-front.png",
      "https://example.com/product-reference.png"
    ],
    "size": "2048x2048",
    "num_images": 3,
    "negative_prompt": "blur, low quality",
    "watermark": false,
    "enable_prompt_expansion": true,
    "prompt_extend_mode": "direct",
    "seed": 123456
  }
}
```

> [!NOTE]
>
> `size` 優先於 `resolution` 和 `aspect_ratio`。當 `image-to-image` 模式中省略 `size` 時，若希望輸出遵循第一張輸入影像的比例，則應省略 `aspect_ratio`

## 參數

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

結果交付方式。支援的值：`async`、`callback`。使用 `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*

Qwen Image 3.0 Pro 的輸入參數。

**屬性**

**mode** `string` *required*

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

**prompt** `string` *required*

描述所需影像或編輯的文字提示。驗證時將忽略前導和尾隨空格。對於 `image-to-image`，提示不能超過 `800` 個字元。最大長度：文字轉影像為 1800 個字元；圖生圖則限制為 800 個字元。

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

參考影像 URL。`image-to-image` 時必需；提供 `1-3` 可公開存取且可直接取得的影像 URL。每個影像的寬度最多為 8000 像素，高度最多為 8000 像素。`text-to-image` 時將被忽略。

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

以 `WIDTH:HEIGHT` 格式輸出寬高比。此比率必須在 `1:8` 到 `8:1` 之間；常見值包括 `1:1`、`4:3`、`3:4`、`16:9` 與 `9:16`。對於 `text-to-image`，空白或省略值預設為 `1:1`；對於 `image-to-image`，空白或省略值則遵循第一個輸入影像的寬高比。

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

輸出分辨率層。支援的值：`1k`、`2k`。API 接受小寫或大寫值，並對它們進行標準化以進行計費和處理。

**size** `string`

選填的明確輸出大小，採用 `WIDTHxHEIGHT` 或 `WIDTH*HEIGHT` 格式，例如 `1024x1024` 或 `2048*1152`。如果提供，`size` 優先於 `resolution` 和 `aspect_ratio`。自訂尺寸標準化為支援的 16 像素網格、比率範圍 `1:8` 到 `8:1` 以及從 `512x512` 到 `2048x2048` 的總像素面積。

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

請求的輸出影像數量。支援從 `1` 到 `6` 的整數。

**negative\_prompt** `string`

選填的負面提示，描述要避免的視覺元素。最大長度：500 個字元。

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

是否加上浮水印。

**enable\_prompt\_expansion** `boolean` (default: true)

是否在生成前啟用提示擴充功能。支援的值：`true`、`false`。

**prompt\_extend\_mode** `string` (default: direct)

提示擴展模式。支援的值：`direct`、`agent`。`agent` 可用於 `text-to-image`；在 `image-to-image` 中，按 `direct` 處理。

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

隨機種子。使用 `-1` 進行隨機輸出，或發送從 `0` 到 `2147483647` 的整數以獲得更多可重複的實驗。

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

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

## 回應格式

### 送出任務時的回應

任務受理後，`POST /generateTask/qwen-image-3-0-pro` 會傳回任務 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`

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

狀態回應僅包括上面列出的欄位。

## Webhook 回呼模式

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

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/qwen-image-3-0-pro" \
  -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",
      "prompt": "preserve the product design, refine the materials, and place it in a premium studio scene",
      "image_urls": [
        "https://example.com/product-front.png",
        "https://example.com/product-reference.png"
      ],
      "resolution": "2k"
    }
  }'
```

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

Qwen Image 3.0 Pro 依產生的影像計費。`num_images` 控制請求的影像數量，`image-to-image` 定價也取決於輸入影像 URL 的數量。

| 模式 | 解析度 | 輸入影像 | APIXO 價格 |
| - | - | -: | -: |
| `text-to-image` | `1k` | `0` | `$0.040 / image` |
| `text-to-image` | `2k` | `0` | `$0.075 / image` |
| `image-to-image` | `1k` | `1` | `$0.043 / image` |
| `image-to-image` | `1k` | `2` | `$0.046 / image` |
| `image-to-image` | `1k` | `3` | `$0.049 / image` |
| `image-to-image` | `2k` | `1` | `$0.078 / image` |
| `image-to-image` | `2k` | `2` | `$0.081 / image` |
| `image-to-image` | `2k` | `3` | `$0.084 / image` |

計費行為：

```text theme={null}
precharge = requested_num_images * unit_price_for_mode_resolution_and_input_image_count
final_charge = successful_images * unit_price_for_mode_resolution_and_input_image_count
refund = precharge - final_charge
```

如果提供 `size`，則計費將使用標準化輸出大小層。超過 `2,250,000` 像素的歸一化尺寸以 `2k` 計費；其他支援的尺寸以 `1k` 計費。

有關當前折扣和市場比較定價，請參閱[API定價](https://apixo.ai/pricing/api)。

## 耗時與輪詢

Qwen Image 3.0 Pro 任務是異步的。實際延遲會因提示複雜性、參考影像可存取性、所選解析度和目前佇列負載而異。

| 工作流程 | 建議首次查詢時間 | 輪詢間隔 |
| - | - | - |
| 文生圖 | 任務建立 10 至 15 秒後 | 5s-10s |
| 圖生圖 | 任務建立 15 秒後 | 5s-10s |

> [!TIP]
>
> 對於生產佇列或批次，使用回呼模式以避免頻繁輪詢。

速率限制和並發性可能因帳戶、API 金鑰和型號而異。若收到 `429`，請減慢請求並透過退避重試。有關帳戶層級的詳細信息，請參閱 [系統 API](https://apixo.ai/docs/zh-hant/api-reference/system.md)。

## 錯誤與排查

### HTTP 錯誤

| 代碼 | 含義 | 處理方式 |
| - | - | - |
| `400` | 請求主體、參數類型或值無效 | 修正請求後再試 |
| `401` | 缺少 API 金鑰，或金鑰無效 | 檢查 `Authorization` 請求標頭 |
| `402` | 餘額或配額不足 | 充值或更換帳號或金鑰 |
| `403` | 金鑰或帳戶無法存取模型 | 檢查權限和帳戶狀態 |
| `404` | 未找到任務 | 驗證 `taskId` 和模型 ID |
| `429` | 已達到速率或並行限制 | 以指數退避方式重試 |
| `500` | 伺服器錯誤或未知任務失敗 | 逐步拉長間隔後重試 |
| `502` | 模型服務錯誤 | 逐步拉長間隔後重試 |
| `504` | 模型服務逾時 | 重新嘗試；耗時較長的任務可改用回呼模式 |

### 請求驗證

| 條件 | 後端行為 |
| - | - |
| 缺少 `input` | 傳回缺少參數的錯誤 |
| 缺失或無效 `mode` | 傳回`Invalid mode type. Supported: text-to-image, image-to-image` |
| 缺失、非字串或空 `prompt` | 傳回提示驗證錯誤 |
| `image-to-image`提示超過`800`個字元 | 傳回提示長度錯誤 |
| `image-to-image` 沒有提供 `image_urls` | 傳回缺少參數的錯誤 |
| `image_urls` 不是陣列、包含空值或包含多於 `3` 個項目 | 傳回影像 URL 驗證錯誤 |
| `aspect_ratio` 無效 | 傳回縱橫比驗證錯誤 |
| `resolution` 無效 | 傳回`The parameter {{resolution}} is invalid. Supported: 1k, 2k.` |
| `size` 無效 | 傳回尺寸驗證錯誤 |
| `num_images` 無效 | 傳回`The parameter {{num_images}} must be between 1 and 6.` |
| `negative_prompt` 無效 | 傳回字串類型錯誤 |
| `watermark` 無效 | 傳回布林類型錯誤 |
| `enable_prompt_expansion` 無效 | 傳回布林類型錯誤 |
| `prompt_extend_mode` 無效 | 傳回`The parameter {{prompt_extend_mode}} must be direct or agent.` |
| `seed` 無效 | 傳回支援的種子範圍 |

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

## MCP 整合

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

## 相關連結

* [Qwen Image 3.0](https://apixo.ai/docs/zh-hant/models/image/qwen-image-3-0.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)
* [API定價](https://apixo.ai/pricing/api)


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