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

# GPT Image 2.6

> GPT Image 2.6：OpenAI 新一代图像模型，提供 Sunburst（精细视觉创作）和 Flare（快速迭代）两个规格，新增规划程度控制、GIF 动图和 SVG 矢量输出。

GPT Image 2.6 是 OpenAI 的新一代图像生成与编辑模型，提供两个规格：`gpt-image-2.6-sunburst`（Sunburst）适合精细的视觉创作，`gpt-image-2.6-flare`（Flare）适合快速迭代。两个规格的接口和参数相同，把 `model` 换成对应的模型名即可。在 [GPT Image 2.5](https://docs.dreamto.ai/image/models/gpt-image-2-5.md) 的基础上新增：`complexity` 控制出图前的规划程度；`output_format: gif` 直接生成 GIF 动图；`output_format: svg` 生成包含可编辑路径、形状和颜色的 SVG 矢量图。`quality` 同样支持 `xhigh` 和 `max`。可以直接使用 OpenAI 官方 SDK。

## 接入

| | OpenAI 官方 | DreamTo |
| - | - | - |
| 服务地址 | `https://api.openai.com/v1` | `https://api.dreamto.ai/v1` |
| API Key | OpenAI API Key | DreamTo 控制台的 API Key，放在 `Authorization: Bearer` 请求头 |

## 接口

| 接口 | 用途 |
| - | - |
| [`POST /v1/images/generations`](https://docs.dreamto.ai/api-reference/gpt-image-2-6/create-image) | 生成图片 |
| [`POST /v1/images/edits`](https://docs.dreamto.ai/api-reference/gpt-image-2-6/edit-image) | 编辑图片 |

## 参数范围

| 字段 | 取值 |
| - | - |
| `prompt` | 必填，最多 32000 个字符 |
| `size` | `auto`（默认）或 `宽x高`：宽高都是 16 的倍数，最长边 ≤ 3840，长短边比 ≤ 3:1，总像素 655,360 \~ 8,294,400。常用 `1024x1024`、`1536x1024`、`1024x1536` |
| `quality` | `auto`（默认）/ `low` / `medium` / `high` / `xhigh` / `max` |
| `n` | 1 \~ 10，默认 1 |
| `background` | `auto`（默认）/ `opaque` / `transparent`；透明背景需配合 `png` 或 `webp` |
| `output_format` | `png`（默认）/ `jpeg` / `webp` / `gif`（动图）/ `svg`（矢量图，仅生成接口） |
| `output_compression` | 0 \~ 100，默认 100，仅 `jpeg` / `webp` 生效 |
| `stream` | `true` 时以 SSE 流式返回；`partial_images` 为 0 \~ 3 张预览图 |
| `complexity` | `low` / `medium` / `high`（默认）：出图前的规划程度，与 `quality` 相互独立 |
| `svg.model` | `output_format: svg` 时必填：编写 SVG 的文本模型，如 `gpt-6.1-terra` |

### 暂不支持的官方参数

传入后返回 400，不调用模型、不扣费。

| 参数 | 说明 |
| - | - |
| `images` | JSON 方式的编辑输入暂不支持，请用 `multipart/form-data` 上传 `image[]` |
| `frame_count` | GIF 帧数（官方 2 \~ 16，默认 9）暂不支持，GIF 按默认 9 帧输出 |
| `frame_duration_ms` | GIF 每帧时长（官方 20 \~ 2000 毫秒，默认 200）暂不支持 |

## 计费

按模型价格计费，以控制台显示的价格为准。参数错误和生成失败不扣费。

同一模型也有按次计费、价格更低的 经济型线路（`gpt-image-2.6-sunburst-economy` / `gpt-image-2.6-flare-economy`），见 [GPT Image 2.6 经济型](https://docs.dreamto.ai/image/models/gpt-image-2-6-economy.md)。

## 快速开始

示例中的 `$DREAMTO_API_KEY` 为你的 API Key。

```bash cURL theme={null}
curl -X POST "https://api.dreamto.ai/v1/images/generations" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2.6-sunburst",
    "prompt": "一只戴着宇航员头盔的橘猫漂浮在太空中，背景是地球，写实摄影风格",
    "size": "1024x1024",
    "quality": "medium"
  }'
```

```python Python theme={null}
import base64
import os

from openai import OpenAI

client = OpenAI(base_url="https://api.dreamto.ai/v1", api_key=os.environ["DREAMTO_API_KEY"])

result = client.images.generate(
    model="gpt-image-2.6-sunburst",
    prompt="一只戴着宇航员头盔的橘猫漂浮在太空中，背景是地球，写实摄影风格",
    size="1024x1024",
    quality="medium",
)
with open("output.png", "wb") as f:
    f.write(base64.b64decode(result.data[0].b64_json))
```

### 图片编辑

`/v1/images/edits` 使用 `multipart/form-data` 上传图片文件，可重复 `image[]` 传多张参考图：

```bash cURL theme={null}
curl -X POST "https://api.dreamto.ai/v1/images/edits" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -F "model=gpt-image-2.6-sunburst" \
  -F "prompt=把第二张图的标志印在第一张图的帆布袋上，保持商品摄影风格" \
  -F "image[]=@product.png" \
  -F "image[]=@logo.png" \
  -F "size=1024x1024" \
  -F "quality=medium"
```

## 使用说明

* `model` 使用 DreamTo 模型名 `gpt-image-2.6-sunburst` / `gpt-image-2.6-flare`。
* `output_format: svg` 时必须同时传 `svg.model`（编写 SVG 的文本模型），否则返回 400 `missing_required_parameter`。SVG 仅生成接口支持，`n` 须为 1，不支持流式、预览图和 `output_compression`；`b64_json` 解码后为 UTF-8 编码的 SVG（XML）。
* `output_format: gif` 按官方默认输出 9 帧动图，暂不支持官方的 `frame_count` / `frame_duration_ms`；GIF 不支持流式、预览图和 `output_compression`。
* 图片编辑使用 `multipart/form-data` 上传文件（`image[]`、`mask`）；暂不支持官方新增的 JSON `images` / `file_id` 写法，也暂不支持标注图编辑参数 `markup`。
* 与官方一样以 Base64（`data[].b64_json`）返回图片。
* `xhigh` / `max` 质量档耗时更长、输出 Token 更多；官方建议只在较低档位不能满足质量要求、且可以接受延迟时使用。
* 传入网关未声明的参数会返回 400，不调用模型、不扣费。
* 错误响应使用 DreamTo 的错误结构（见各接口的错误示例）。


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