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

# GPT Image 2.6 新能力

> GPT Image 2.6 Flare / Sunburst 模型選型、complexity 複雜度控制、SVG 向量輸出、GIF 動畫與標記引導編輯，附線上 Playground 和真實結果。

> [!NOTE]
>
> 右側 Playground 提供 **普通 PNG + complexity、SVG、2 幀 GIF** 三組示例。請在 **Authorization** 中填入 `Bearer sk-xxx`，選擇示例後修改提示詞併發送。

> [!WARNING]
>
> 返回的 `data[0].b64_json` 不含 `data:` 字首，SVG 和 GIF 也都是 base64。瀏覽器 Playground 可能無法展示較長的 base64 響應；此時請求可能已經成功，請改用下方 Python 程式碼在本地解碼儲存。

## 模型選型

GPT Image 2.6 於 2026-11-04 釋出，沿用 `/v1/images/generations` 和 `/v1/images/edits`，增加複雜度控制、SVG、GIF 與標記引導編輯。

| 模型 | 定位 | 適用場景 |
| - | - | - |
| `gpt-image-2.6-flare` | 快速迭代 | 草稿、批量出圖、社交內容、需要快速比較多個提示詞的場景 |
| `gpt-image-2.6-sunburst` | 精細視覺工作 | 複雜佈局、精細文字、成品物料、需要精確編輯的場景 |

兩款的 token 單價可在 [模型價格總表](https://docs.apiyi.com/zh-Hant/models/index.md) 中查詢。實際費用取決於尺寸、畫質、輸出格式和 token 用量；SVG 還會產生編寫模型費用，不能按普通 PNG 的單張成本估算。

## 新能力一覽

> [card] [complexity 規劃控制](#complexity-控制規劃量)
>
> 控制模型渲染前的規劃量，與 quality 畫質設定相互獨立。

> [card] [SVG 向量輸出](#svg-生成可編輯向量檔案)
>
> 返回可編輯的路徑、形狀和顏色，適合圖示、插畫和 UI 素材。

> [card] [GIF 迴圈動畫](#gif-生成迴圈動畫)
>
> 一次請求生成完整 GIF，可控制幀數和每幀時長。

> [card] [標記引導編輯](#標記引導編輯)
>
> 用透明標記圖層圈出編輯區域，再通過 prompt 描述修改內容。

## complexity：控制規劃量

`complexity` 控制模型在渲染前投入多少規劃。它適合密集文字、複雜佈局、多個物件關係等任務；`quality` 則控制最終渲染畫質，兩者不要混用。

| 官方檔位 | 建議用途 |
| - | - |
| `low` | 聚焦修改、簡單構圖、快速草稿 |
| `medium` | 常規佈局與多個約束的均衡選擇 |
| `high` | 密集文字、複雜佈局、物件關係較多的場景；省略 `complexity` 時預設使用 |

`complexity` 不單獨收費，但較高檔位可能增加耗時，也可能引入不希望的改動。先用同一提示詞比較結果，再決定生產檔位，不要預設越高越好。

> [accordion] 上游實測補充：還會返回哪些檔位？
>
> 本次上游錯誤資訊還列出 `none`、`xhigh`、`max`，這些值在當前鏈路可被接受。OpenAI 公開指南穩定承諾的是 `low / medium / high`，因此生產請求建議只使用官方三檔，不把額外檔位作為長期相容保證。

## SVG：生成可編輯向量檔案

設定 `output_format: "svg"`。當前上游還要求提供巢狀的 `svg.model`，用於指定編寫向量程式碼的文本模型：

```json theme={null}
{
  "model": "gpt-image-2.6-sunburst",
  "prompt": "A minimal flat vector icon of a rocket, exactly three solid colors, geometric editable shapes, no text, no raster texture, transparent background.",
  "output_format": "svg",
  "svg": {
    "model": "gpt-5.6-terra"
  },
  "quality": "low",
  "size": "1024x1024",
  "n": 1
}
```

![紅色尾翼、藍色舷窗和白色機身的向量火箭圖示](https://mintcdn.com/apiyillc/I9X_C01jz8OkWw6c/images/gpt-image-2-6/rocket.svg?fit=max\&auto=format\&n=I9X_C01jz8OkWw6c\&q=85\&s=c2dc54229ae6495d2926adcc44513fa4)

APIYI 透傳鏈路生成的真實 SVG：由 path 和 circle 組成，可繼續在向量編輯器中修改

### 文本模型選擇與計費

`svg.model` 由請求方指定，不是平臺隨機選擇。可選範圍取決於上游和當前分組，不代表所有 OpenAI 文本模型都自動支援；本頁已實測 `gpt-5.6-terra`、`gpt-6-luna` 和 `gpt-4.1-mini`，其他模型需在實際分組中驗證。編寫模型按所選文本模型的輸入、輸出 token 單價計費：

* 編寫模型費用 = `svg_usage.input_tokens` × 輸入單價 + `svg_usage.output_tokens` × 輸出單價。
* SVG 總費用 = 參考影像費用 + 編寫模型費用。影像模型先生成參考圖，文本模型再編寫 SVG。
* 成功響應會同時返回 `usage` 和 `svg_usage`：前者是參考影像用量，後者是編寫模型用量，兩部分都要計入成本。
* `svg_usage.reasoning_tokens` 已包含在 `svg_usage.output_tokens` 中，不要重複相加。

2026-11-05 APIYI 透傳鏈路實測，使用 `gpt-image-2.6-sunburst` 和 `gpt-5.6-terra`，返回了以下用量欄位：

```json theme={null}
{
  "output_format": "svg",
  "usage": {
    "input_tokens": 100,
    "output_tokens": 824,
    "total_tokens": 924
  },
  "svg_usage": {
    "model": "gpt-5.6-terra",
    "input_tokens": 1572,
    "output_tokens": 850,
    "reasoning_tokens": 350,
    "total_tokens": 2422
  }
}
```

按模型總表當前列出的 `gpt-5.6-terra` 單價（輸入每百萬 tokens \$2、輸出每百萬 tokens \$12）估算，本次文本編寫部分為 `1572 ÷ 1000000 × 2 + 850 ÷ 1000000 × 12 = \$0.013344`，參考影像費用另計。

同一提示詞下的三款編寫模型實測對比如下，均返回無指令碼、嵌入點陣圖或外鏈的真實 SVG：

| `svg.model` | 結果 | 輸入 / 輸出 tokens | reasoning tokens | 耗時 | 文本費用估算 |
| - | - | -: | -: | -: | -: |
| `gpt-5.6-terra` | PASS | 1,572 / 850 | 350 | 29.196s | \$0.013344 |
| `gpt-6-luna` | PASS | 1,572 / 1,618 | 1,110 | 53.436s | \$0.0009662 |
| `gpt-4.1-mini` | PASS | 2,005 / 513 | 0 | 23.777s | \$0.0016228 |

三次請求的參考影像用量均為輸入 100、輸出 824、總計 924 tokens，參考影像費用另計。`gpt-4.1-mini` 的響應模型名回顯為 `gpt-4.1-mini-2025-04-14`。價格可能調整，不同分組也可能有階梯價格；實際以 [模型價格總表](https://docs.apiyi.com/zh-Hant/models/index.md) 和賬單為準。單張結果不用於畫質排名。

### 使用限制

* 僅限 `/v1/images/generations`，`n=1`；編輯介面不支援 SVG 輸出，也不能把 SVG 作為編輯輸入點陣圖。
* 不支援 streaming、partial images、`output_compression` 或 `prompt_rewriter`。
* 返回靜態向量 XML，不包含指令碼、外部資源或嵌入點陣圖。解碼後儲存為 `.svg`，不要按 PNG 渲染。

## GIF：生成迴圈動畫

設定 `output_format: "gif"`，並在提示詞中描述主體、運動和迴圈方式。下面的低成本示例預期得到 **2 幀、每幀 100ms、總時長 0.2 秒**：

```json theme={null}
{
  "model": "gpt-image-2.6-sunburst",
  "prompt": "A minimal two-frame looping animation of a yellow circle moving slightly right and returning to its starting position on a plain white background, no text, seamless loop.",
  "output_format": "gif",
  "quality": "low",
  "size": "512x512",
  "frame_count": 2,
  "frame_duration_ms": 100,
  "n": 1
}
```

![黃色圓形向右移動並回到起點的兩幀迴圈動畫](https://mintcdn.com/apiyillc/I9X_C01jz8OkWw6c/images/gpt-image-2-6/two-frame-loop.gif?s=d010bf9dbb9b5c3a3e9b915bb2164a3d)

APIYI 透傳鏈路生成的真實 GIF：2 幀、0.2 秒，圓形位置發生變化

| 引數 | 官方範圍與預設值 | 說明 |
| - | - | - |
| `frame_count` | 2–64，預設 9 | 幀數越多，耗時和費用通常越高 |
| `frame_duration_ms` | 20–2000ms，預設 200ms，按 10ms 取整 | 總時長約為幀數 × 每幀時長 |
| `size` | `auto` 或合法 WIDTHxHEIGHT | 表示每幀尺寸；幀數、單幀尺寸和總畫素預算必須同時滿足限制 |

GIF 僅限 generations，不支援 streaming、partial images、自定義 `output_compression` 或 `prompt_rewriter`。`frame_count` 和 `frame_duration_ms` 也不要用於 PNG、JPEG、WebP 或 SVG。

### 驗證真實幀數

不要只看 HTTP 200 或響應中的 `output_format`。欄位被路由丟棄時，仍可能返回預設 9 幀、1.8 秒的 GIF。可用 `ffprobe` 檢查實際檔案：

```bash theme={null}
ffprobe -v error -select_streams v:0 -count_frames \
  -show_entries stream=codec_name,width,height,nb_read_frames,duration \
  -of json result.gif
```

本例應返回 `nb_read_frames=2`、`duration=0.200000`。

## 標記引導編輯

GPT Image 2.6 還支援通過 `/v1/images/edits` 的 `markup` 欄位進行標記引導編輯：

1. 第一張輸入圖保持為原圖。
2. 另做一張與原圖同尺寸的透明 PNG，用圓圈、箭頭或草圖標出修改區域。
3. 將該透明圖層作為 `markup` 上傳，並在 `prompt` 中說明修改內容和需要保留的細節。
4. `markup` 作用於第一張輸入圖，不能與 `mask` 或 `prompt_rewriter` 同時使用。

普通單圖編輯、多圖融合和 mask 用法見 [圖片編輯 API](https://docs.apiyi.com/zh-Hant/api-capabilities/gpt-image-2/image-edit.md)。不同路由對 `markup` 的透傳情況需單獨驗證，本頁不將其作為已實測的線上演示。

## 客戶端解碼

三種輸出都讀取 `data[0].b64_json`，只是儲存副檔名不同：

```python theme={null}
import base64
from pathlib import Path

payload = response.json()
fmt = payload["output_format"]
raw = base64.b64decode(payload["data"][0]["b64_json"])
Path(f"result.{fmt}").write_bytes(raw)
```

SVG 解碼後是 UTF-8 XML；GIF 和 PNG/JPEG/WebP 解碼後是二進位制檔案。生產程式碼還應檢查 HTTP 狀態、`error` 欄位和實際檔案簽名，不要只根據副檔名判斷成功。

## 路由相容性與排障

> [!WARNING]
>
> 2.6 新欄位要求鏈路按原生 JSON 透傳。不同上游路由的相容進度可能不同，公開示例不代表每個分組都已具備相同行為。接入時請在實際使用的分組中驗證。

| 現象 | 優先檢查 |
| - | - |
| 已傳 `svg.model`，仍返回 `SVG generation requires 'svg.model'` | 巢狀 `svg` 物件是否被路由過濾或改寫 |
| 請求 2 幀、100ms，實際卻是 9 幀、1.8 秒 | `frame_count` 和 `frame_duration_ms` 是否被丟棄並回退預設值 |
| complexity 非法字串仍返回 200 | 不同上游的校驗策略可能不同，不能僅憑這一點判定未透傳；結合合法檔位的耗時、結果和上游日誌排查 |
| Playground 顯示 `unable to complete request` | 先檢查是否實際返回 200；長 base64 可能超出瀏覽器展示能力，改用原生代碼解碼 |
| 擔心 SVG 賬單偏高 | 同時核對 `usage` 與 `svg_usage`，不要只統計參考影像 tokens |

## 相關文件

* [GPT-Image-2.5 / 2 概覽](https://docs.apiyi.com/zh-Hant/api-capabilities/gpt-image-2/overview.md)
* [普通文生圖 Playground](https://docs.apiyi.com/zh-Hant/api-capabilities/gpt-image-2/text-to-image.md)
* [圖片編輯 Playground](https://docs.apiyi.com/zh-Hant/api-capabilities/gpt-image-2/image-edit.md)
* [圖片 API 呼叫須知與最佳實踐](https://docs.apiyi.com/zh-Hant/api-capabilities/image-api-best-practices.md)
* [模型價格總表](https://docs.apiyi.com/zh-Hant/models/index.md)


## OpenAPI

````yaml api-reference/gpt-image-2-6-generate-openapi.yaml POST /v1/images/generations
openapi: 3.1.0
info:
  title: GPT Image 2.6 文生图与新能力 API
  description: >
    OpenAI `gpt-image-2.6-flare` / `gpt-image-2.6-sunburst`
    文生图接口，支持普通位图、复杂度控制、SVG 矢量输出与 GIF 动画输出。


    - complexity：官方档位 low / medium / high，默认 high，不单独收费

    - SVG：output_format=svg，并传 svg.model；仅 generations，n=1

    - GIF：output_format=gif，可设 frame_count 与 frame_duration_ms

    - 返回 data[0].b64_json，客户端需自行 base64 解码


    **认证方式**：在请求头中添加 `Authorization: Bearer YOUR_API_KEY`


    **获取 API Key**：访问 [API易控制台](https://api.apiyi.com/token) 创建令牌
  version: 1.0.0
servers:
  - url: https://api.apiyi.com
    description: 主要端点
security:
  - bearerAuth: []
paths:
  /v1/images/generations:
    post:
      tags:
        - GPT Image 2.6
      summary: GPT Image 2.6：生成 PNG、SVG 或 GIF
      description: >
        使用 GPT Image 2.6 根据文本提示词生成图片。三组请求示例分别演示 complexity、SVG 和 GIF。


        complexity 控制渲染前的规划量，与 quality 的画质控制相互独立。SVG 需要嵌套的 svg.model；GIF
        的帧数和帧时长只在 output_format=gif 时使用。SVG 与 GIF 均不支持 streaming、partial images
        或 output_compression。
      operationId: generateGptImage26
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Image26Request'
            examples:
              complexityPng:
                summary: 普通 PNG + low complexity
                description: 用四象限信息图观察 complexity；quality=low 控制成本
                value:
                  model: gpt-image-2.6-sunburst
                  prompt: >-
                    A clean 2x2 technical infographic on a white background.
                    Top-left: a red circle labeled 'A'. Top-right: a blue square
                    labeled 'B'. Bottom-left: a green triangle labeled 'C'.
                    Bottom-right: a yellow hexagon labeled 'D'. A black arrow
                    connects A to B to C to D in that order. Exactly four
                    labels, balanced grid, no other text.
                  output_format: png
                  complexity: low
                  quality: low
                  size: 1024x1024
                  'n': 1
              svgVector:
                summary: SVG 矢量图标
                description: 必须保留嵌套 svg.model；响应另有 svg_usage
                value:
                  model: gpt-image-2.6-sunburst
                  prompt: >-
                    A minimal flat vector icon of a rocket, exactly three solid
                    colors, geometric editable shapes, no text, no raster
                    texture, transparent background.
                  output_format: svg
                  svg:
                    model: gpt-5.6-terra
                  quality: low
                  size: 1024x1024
                  'n': 1
              gifAnimation:
                summary: 2 帧 GIF 循环动画
                description: 预期真实文件为 2 帧、0.2 秒；不要用默认 9 帧判断参数透传
                value:
                  model: gpt-image-2.6-sunburst
                  prompt: >-
                    A minimal two-frame looping animation of a yellow circle
                    moving slightly right and returning to its starting position
                    on a plain white background, no text, seamless loop.
                  output_format: gif
                  quality: low
                  size: 512x512
                  frame_count: 2
                  frame_duration_ms: 100
                  'n': 1
      responses:
        '200':
          description: 生成成功，结果为 base64 编码的 PNG、JPEG、WebP、SVG 或 GIF
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Image26Response'
        '400':
          description: 参数非法，或实际路由未透传 svg.model 等新字段
        '401':
          description: 未授权 - API Key 无效
        '403':
          description: 内容审核拦截
        '429':
          description: 请求频率超限或额度不足
        '500':
          description: 服务器内部错误
      security:
        - bearerAuth: []
components:
  schemas:
    Image26Request:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          description: Flare 适合快速迭代，Sunburst 适合精细视觉工作
          enum:
            - gpt-image-2.6-flare
            - gpt-image-2.6-sunburst
          default: gpt-image-2.6-sunburst
        prompt:
          type: string
          maxLength: 32000
          description: 提示词，支持中英文。GIF 应在提示词中描述主体、运动和循环方式
          example: A minimal flat vector icon of a rocket, three solid colors, no text
        complexity:
          type: string
          description: 渲染前的规划复杂度，与 quality 独立。官方文档档位为 low / medium / high，省略时默认 high；不单独收费
          enum:
            - low
            - medium
            - high
          default: high
        size:
          type: string
          description: 输出尺寸，预设值或满足模型约束的 WIDTHxHEIGHT。GIF 示例使用 512x512；帧数、单帧尺寸与总像素预算必须同时满足限制
          example: 1024x1024
          default: auto
        quality:
          type: string
          description: 渲染画质，与 complexity 独立。SVG 中控制参考图像质量
          enum:
            - auto
            - low
            - medium
            - high
            - xhigh
            - max
          default: auto
        output_format:
          type: string
          description: >-
            输出格式。SVG 与 GIF 只支持 generations，不支持编辑、streaming、partial images 或
            output_compression
          enum:
            - png
            - jpeg
            - webp
            - svg
            - gif
          default: png
        output_compression:
          type: integer
          description: 输出压缩率，仅 jpeg / webp 生效；不要用于 SVG 或 GIF
          minimum: 0
          maximum: 100
          example: 85
        background:
          type: string
          description: 背景模式。transparent 需与输出格式兼容；JPEG 不支持透明
          enum:
            - auto
            - opaque
            - transparent
          default: auto
        moderation:
          type: string
          description: 审核强度
          enum:
            - auto
            - low
          default: auto
        'n':
          type: integer
          description: 生成数量。本页示例及 SVG 输出固定为 1
          enum:
            - 1
          default: 1
        svg:
          type: object
          description: SVG 专用配置。当前上游要求 output_format=svg 时提供 svg.model
          properties:
            model:
              type: string
              description: >-
                生成 SVG 矢量代码的文本模型。已实测
                gpt-5.6-terra、gpt-6-luna、gpt-4.1-mini，其他模型需在实际分组中验证；示例使用
                gpt-5.6-terra
              example: gpt-5.6-terra
              default: gpt-5.6-terra
          required:
            - model
        frame_count:
          type: integer
          description: GIF 帧数。官方文档范围 2–64，默认 9；仅 output_format=gif 时使用
          minimum: 2
          maximum: 64
          default: 9
          example: 2
        frame_duration_ms:
          type: integer
          description: GIF 每帧时长，20–2000ms，默认 200ms，按 10ms 取整；仅 output_format=gif 时使用
          minimum: 20
          maximum: 2000
          default: 200
          example: 100
    Image26Response:
      type: object
      properties:
        created:
          type: integer
          description: Unix 时间戳
        background:
          type: string
          description: 实际背景模式
          example: opaque
        data:
          type: array
          description: 生成结果数组
          items:
            type: object
            properties:
              b64_json:
                type: string
                description: >-
                  纯 base64，不含 data: 前缀。按 output_format 保存为对应扩展名；SVG 解码为 UTF-8
                  XML
              generation_id:
                type: string
                description: 本次生成 ID，部分响应提供
        output_format:
          type: string
          example: gif
        quality:
          type: string
          example: low
        size:
          type: string
          example: 512x512
        usage:
          $ref: '#/components/schemas/ImageUsage'
        svg_usage:
          $ref: '#/components/schemas/SvgUsage'
    ImageUsage:
      type: object
      description: 图像模型的 token 用量
      properties:
        input_tokens:
          type: integer
          example: 59
        output_tokens:
          type: integer
          example: 555
        total_tokens:
          type: integer
          example: 614
        input_tokens_details:
          type: object
          properties:
            text_tokens:
              type: integer
              example: 59
            image_tokens:
              type: integer
              example: 0
        output_tokens_details:
          type: object
          properties:
            text_tokens:
              type: integer
              example: 0
            image_tokens:
              type: integer
              example: 555
    SvgUsage:
      type: object
      description: >-
        仅 SVG 输出时出现的编写模型用量。模型由请求的 svg.model 指定，按该文本模型的输入、输出 token
        单价计费；reasoning_tokens 已包含在 output_tokens 中，不重复相加
      properties:
        model:
          type: string
          example: gpt-5.6-terra
        input_tokens:
          type: integer
          example: 1572
        output_tokens:
          type: integer
          example: 850
        reasoning_tokens:
          type: integer
          example: 350
        total_tokens:
          type: integer
          example: 2422
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 在 API易控制台获取的 API Key

````

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