> ## 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/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。响应中的 `usage` 是参考图像用量，`svg_usage` 是编写模型用量，两部分都要计入成本。
* `svg_usage.reasoning_tokens` 已包含在 `svg_usage.output_tokens` 中，不要重复相加。
* 仅限 `/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/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/api-capabilities/gpt-image-2/overview.md)
* [普通文生图 Playground](https://docs.apiyi.com/api-capabilities/gpt-image-2/text-to-image.md)
* [图片编辑 Playground](https://docs.apiyi.com/api-capabilities/gpt-image-2/image-edit.md)
* [图片 API 调用须知与最佳实践](https://docs.apiyi.com/api-capabilities/image-api-best-practices.md)
* [模型价格总表](https://docs.apiyi.com/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
              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 输出时出现的编写模型用量；reasoning_tokens 已包含在 output_tokens 中，不重复相加
      properties:
        model:
          type: string
          example: gpt-5.6-sol
        input_tokens:
          type: integer
          example: 1572
        output_tokens:
          type: integer
          example: 1437
        reasoning_tokens:
          type: integer
          example: 994
        total_tokens:
          type: integer
          example: 3009
  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.