> ## Documentation Index
> Fetch the complete documentation index at: https://docs.toapis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GPT-Image-2.6 官方渠道 圖像生成

> Sunburst 和 Flare 官方渠道的非同步圖片任務, 支援標註編輯, GIF 和 SVG 輸出, R2 結果和 token 計費

透過官方渠道調用兩個 GPT-Image-2.6 型號. 提交後立即返回非同步任務 ID, 後台生成圖片並將結果轉存到 R2.

| 型號 | model |
| - | - |
| Sunburst Official | `gpt-image-2.6-sunburst-official` |
| Flare Official | `gpt-image-2.6-flare-official` |

調用時必須使用表中的完整模型名. `gpt-image-2.6-official` 只是系列名稱, 不能作為請求的 model.

中國大陸用戶可將範例中的 `https://api.toapis.com` 替換為 `https://api.toapis.cn`. 在 [控制台](https://toapis.com/console/token) 建立 API Key, 並設定環境變數 `TOAPIS_API_KEY`.

## 提交和查詢

提交一張 Flare 圖片. 調用 Sunburst 時替換 model 即可:

```bash theme={null}
curl --fail-with-body --request POST \
  --url https://api.toapis.com/v1/images/generations \
  --header "Authorization: Bearer $TOAPIS_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-image-2.6-flare-official",
    "prompt": "A small blue circle on a plain white background",
    "size": "1:1",
    "resolution": "1k",
    "quality": "medium",
    "n": 1
  }'
```

```json theme={null}
{
  "id": "tsk_img_example",
  "object": "generation.task",
  "model": "gpt-image-2.6-flare-official",
  "status": "pending",
  "progress": 0,
  "created_at": 1789099098,
  "metadata": {}
}
```

保存提交回應的 `id`, 將下方 `TASK_ID` 替換為該值:

```bash theme={null}
curl --fail-with-body \
  --url https://api.toapis.com/v1/images/generations/TASK_ID \
  --header "Authorization: Bearer $TOAPIS_API_KEY"
```

提交回應為 `pending`. 查詢時可能看到 `queued` 或 `in_progress`, 最終為 `completed` 或 `failed`. `completed` 時從 `result.data[].url` 取得已轉存 R2 的結果 URL, `failed` 時讀取 `error`. 建議每隔數秒查詢同一個任務 ID; 高品質生成可能需要數分鐘, 等待期間不要重複提交. 完整欄位見 [圖片任務狀態介面](https://docs.toapis.com/docs/zh-Hant/api-reference/tasks/image-status.md).

## 請求參數

**Authorization** `string` *required*

使用 ToAPIs API Key, 格式為 `Bearer YOUR_API_KEY`.

**model** `string` *required*

`gpt-image-2.6-sunburst-official` / `gpt-image-2.6-flare-official`.

**prompt** `string` *required*

圖片描述. 使用參考圖或標註圖時描述希望保留和修改的內容.

**size** `string` (default: auto)

支援比例名 (如 `1:1`, `3:2`, `2:3`, `16:9`, `9:16`) 或像素尺寸 (如 `1024x1024`, `1536x1024`). GIF 輸出時 size 語義以 GIF 節為準. 像素尺寸兩邊須為 16 的倍數且不小於 16, 單邊不超過 3840, 長短邊比不超過 3:1; 超過 2560x1440 屬於實驗尺寸.

**resolution** `string`

解析度檔位 `1k` / `2k` / `4k`. 明確傳入時優先於按 size 推斷的檔位. 檔位影響實際 token 用量與耗時.

**quality** `string` (default: medium)

支援 `auto`, `low`, `medium`, `high`, `xhigh`, `max` 六檔. `auto` 表示由模型為每個請求自動選擇品質檔位. 品質影響實際 token 用量與耗時.

**n** `integer` (default: 1)

每次請求生成 1 到 4 張. `output_format` 為 `svg` 時僅支援 `1`.

**output\_format** `string`

輸出格式 `png` / `jpeg` / `webp` / `gif` / `svg`. 省略時使用上游預設格式. `gif` 和 `svg` 的附加參數與約束見下方對應小節.

**output\_compression** `integer`

0-100 的壓縮率, 僅 `jpeg` 和 `webp` 輸出有效.

**background** `string`

`transparent` / `opaque` / `auto`. 明確透明僅適用 `png` / `webp` 輸出; `svg` 預設透明.

**moderation** `string`

內容審核級別 `auto` / `low`.

**complexity** `string`

生成複雜度 `low` / `medium` / `high`, 省略時預設 `high`. 不單獨收費.

## 參考圖與遮罩

需要圖生圖時在同一個 JSON 請求中新增 `image_urls`, 最多 16 張, URL 必須可由伺服器存取. 可先使用 [圖片上傳介面](https://docs.toapis.com/docs/zh-Hant/api-reference/uploads/images.md) 取得 URL. 參考圖產生圖片輸入 token 費用.

`mask_url` 指向一張 PNG alpha 遮罩圖, 尺寸需與第一張參考圖一致, 必須配合 `image_urls` 使用.

```bash theme={null}
curl --fail-with-body --request POST \
  --url https://api.toapis.com/v1/images/generations \
  --header "Authorization: Bearer $TOAPIS_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-image-2.6-sunburst-official",
    "prompt": "Keep the subject and replace the masked area with a snowy forest",
    "image_urls": ["https://example.com/reference.png"],
    "mask_url": "https://example.com/mask.png",
    "quality": "high",
    "size": "1024x1024",
    "n": 1
  }'
```

## 標註編輯

`markup_url` 指向一張帶標註的參考圖 (或直接用 `markup` 傳內嵌標註物件), 配合 `image_urls` 提供原圖, 模型按標註語義編輯. `markup_url` 與 `mask_url` 互斥, 一次請求只能用一種.

```bash theme={null}
curl --fail-with-body --request POST \
  --url https://api.toapis.com/v1/images/generations \
  --header "Authorization: Bearer $TOAPIS_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-image-2.6-sunburst-official",
    "prompt": "Follow the markup annotations to adjust the layout",
    "image_urls": ["https://example.com/reference.png"],
    "markup_url": "https://example.com/markup.png",
    "quality": "high",
    "n": 1
  }'
```

## GIF 輸出

`output_format` 傳 `gif` 生成動圖, 用 `frame_count` 指定幀數 (2-16), `frame_duration_ms` 指定每幀時長. GIF 僅支援文生圖, 不能同時使用 `image_urls`, `mask_url`, `markup_url`, `markup` 或 `output_compression`. `size` 須傳精確像素尺寸 (如 `512x512`) 或省略以使用上游預設幀尺寸; `1:1` 等比例值在 GIF 下會被上游拒絕.

```bash theme={null}
curl --fail-with-body --request POST \
  --url https://api.toapis.com/v1/images/generations \
  --header "Authorization: Bearer $TOAPIS_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-image-2.6-flare-official",
    "prompt": "A paper airplane looping across a blue sky, flat illustration",
    "output_format": "gif",
    "frame_count": 8,
    "frame_duration_ms": 200,
    "size": "512x512",
    "n": 1
  }'
```

## SVG 輸出

`output_format` 傳 `svg` 生成向量圖, 需同時提供 `svg` 物件並在其中指定 `svg.model`. SVG 僅支援文生圖, `n` 只能為 `1`, 不能同時使用 `image_urls`, `mask_url`, `markup_url`, `markup` 或 `output_compression`. SVG 生成額外產生一次文本模型調用, 按對應文本模型用量計費.

```bash theme={null}
curl --fail-with-body --request POST \
  --url https://api.toapis.com/v1/images/generations \
  --header "Authorization: Bearer $TOAPIS_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-image-2.6-flare-official",
    "prompt": "A minimalist mountain logo, flat vector style",
    "output_format": "svg",
    "svg": { "model": "gpt-5" },
    "n": 1
  }'
```

## token 價格

兩個 official 型號按 token 分項計費: 文本輸入, 快取文本輸入, 圖片輸入, 快取圖片輸入和圖片輸出分別計價. 提交時先預扣額度, 成功後按實際 token 用量多退少補.

費用公式, 單位為 USD:

```text theme={null}
USD = (
  uncached_text_input_tokens * text_input_price
  + cached_text_input_tokens * cached_text_input_price
  + uncached_image_input_tokens * image_input_price
  + cached_image_input_tokens * cached_image_input_price
  + image_output_tokens * image_output_price
) / 1,000,000
```

GIF 按整段動畫的輸出 token 計費. SVG 輸出除圖片 token 外, 還會按 `svg.model` 指定的文本模型產生一次文本輸入/輸出 token 費用.

賬戶專屬定價或折扣繼續適用. 最終扣費可在使用日誌中核對, 最新售價以 [定價頁](https://toapis.com/pricing) 和賬戶配置為準.

## 相關型號

[GPT-Image-2.5 官方渠道](https://docs.toapis.com/docs/zh-Hant/api-reference/images/gpt-image-2.5-official/generation.md), [普通版](https://docs.toapis.com/docs/zh-Hant/api-reference/images/gpt-image-2.5/generation.md) 和 [VIP 版](../gpt-image-2.5-vip/generation) 使用各自的完整模型名. 調用本頁官方渠道時請使用 `-official` 後綴.


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