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

# GPT-Image-2.6 · 文生图

> GPT-Image-2.6 Flare / Sunburst · POST /v1/images/generations

## 简介

GPT-Image-2.6 是 OpenAI 的图像模型系列，包含面向快速迭代的 **Flare** 和面向精细视觉任务的 **Sunburst**。通过本页的 `POST /v1/images/generations` 端点，可以将文本描述转化为图片，适用于海报设计、商品展示、品牌插画、图标和信息图等场景。

除了 PNG、JPEG、WebP 静态图片，两个模型还支持 **GIF 动图**和 **SVG 矢量图**输出，具体可用性取决于项目权限及渠道支持。GIF 适合表达循环动作；SVG 适合需要缩放、调整路径或修改颜色的图标与插画。

生成时可分别通过 `quality` 控制渲染质量、通过 `complexity` 调整出图前的规划量，并设置尺寸与背景。两项参数相互独立，建议从满足需求的设置开始，再根据文字、布局和细节效果调整。优先考虑响应速度时可选择 Flare，注重复杂构图和细节表现时可选择 Sunburst。

### 模型选择

| 模型 ID | 适用场景 |
| - | - |
| `gpt-image-2.6-flare` | 快速迭代、交互式生成 |
| `gpt-image-2.6-sunburst` | 复杂布局与细节表现 |

两个模型共用本页的端点、参数和响应结构。示例默认使用 Flare；切换为 Sunburst 时只需替换请求中的 `model`，其他字段按实际需求设置。

## 认证

**Authorization** `string` *required*

Bearer \$GRAVITEX\_API\_KEY

**Content-Type** `string` *required*

application/json

## 请求参数

| 参数 | 类型 | 说明 |
| - | - | - |
| `model` | string | 必填，gpt-image-2.6-flare 或 gpt-image-2.6-sunburst |
| `prompt` | string | 必填，描述要生成的图片内容，最长 32,000 字符 |
| `quality` | string | auto / low / medium / high / xhigh / max；默认 auto |
| `complexity` | string | low / medium / high；默认 high。独立于 quality，控制渲染前的规划量 |
| `size` | string | auto 或 WxH，宽高为 16 的倍数；受模型尺寸和总像素预算约束 |
| `n` | integer | 1–10；SVG 必须为 1 |
| `background` | string | auto / opaque / transparent；透明栅格输出使用 png 或 webp |
| `output_format` | string | png / jpeg / webp / gif；生成端点另支持 svg |
| `output_compression` | integer | 0–100，仅 jpeg/webp；GIF/SVG 不支持自定义压缩 |
| `moderation` | string | auto / low；默认 auto |
| `safety_identifier` | string | 稳定的终端用户标识，建议哈希化，最长 128 字符；替代 user |
| `stream` | boolean | 默认 false；开启后返回 SSE 事件，不能按普通 JSON 响应解析。GIF 不支持；SVG 不支持 |
| `partial_images` | integer | 仅栅格流式输出，0–3，默认 0；表示期望的中间预览数，实际可能更少。GIF 不支持；SVG 不支持 |
| `frame_count` | integer | 仅 GIF，2–16，默认 9 |
| `frame_duration_ms` | integer | 仅 GIF，默认 200；指南建议 20–2000ms，按 10ms 取整 |
| `svg` | object | 生成 SVG 时必填，包含编写模型 model 和可选的 reasoning |

## 请求示例

示例从环境变量 `GRAVITEX_API_KEY` 读取平台令牌，请先在当前终端设置该变量。文件上传使用 curl 的 `-F` 自动生成 Content-Type 和 boundary，不要手动把 Content-Type 固定成 multipart/form-data。

### 基础生成

```bash theme={null}
curl https://api.gravitex.ai/v1/images/generations \
  -H "Authorization: Bearer $GRAVITEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-image-2.6-flare",
  "prompt": "A clean botanical poster with precise typography",
  "quality": "medium",
  "complexity": "high",
  "size": "1024x1024"
}'
```

### GIF 动图

```bash theme={null}
curl https://api.gravitex.ai/v1/images/generations \
  -H "Authorization: Bearer $GRAVITEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-image-2.6-flare",
  "prompt": "A fox mascot waving, seamless looping animation",
  "output_format": "gif",
  "frame_count": 9,
  "frame_duration_ms": 200,
  "size": "auto"
}'
```

### SVG 矢量图

> [!NOTE]
>
> 当前渠道生成 SVG 需要提供 `svg.model`，省略会返回 missing\_required\_parameter。`gpt-6.1-sol` 与 `reasoning.effort: "low"` 已于 2026-11-09 实测成功；其他编写模型需确认当前渠道是否支持。

#### 指定 SVG 编写模型

示例使用 2026-11-09 本渠道实测成功的 SVG 编写模型 `gpt-6.1-sol`。其他渠道或项目请替换为其可用的编写模型 ID。

```bash theme={null}
curl https://api.gravitex.ai/v1/images/generations \
  -H "Authorization: Bearer $GRAVITEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-image-2.6-flare",
  "prompt": "A simple botanical logo with editable paths",
  "output_format": "svg",
  "n": 1,
  "quality": "medium",
  "complexity": "high",
  "svg": {
    "model": "gpt-6.1-sol",
    "reasoning": {
      "effort": "low"
    }
  }
}'
```

#### 字段说明

| 字段 | 作用与填写方法 |
| - | - |
| `model` | 图片模型，负责生成参考图；使用本页的 2.6 模型 ID |
| `prompt` | 描述最终 SVG 的图形、文字、布局与风格 |
| `output_format` | 固定为 `svg`，表示返回 SVG 文件内容 |
| `n` | SVG 固定为 `1`，一次生成一个结果 |
| `quality` | 控制参考图的渲染质量；示例为 `medium` |
| `complexity` | 控制图片模型生成参考图前的规划量；示例为 `high` |
| `svg.model` | 编写 SVG 的模型，负责把参考图转换为矢量内容；生成 SVG 时必填 |
| `svg.reasoning.effort` | SVG 编写模型的推理强度，与 complexity 独立。示例 low 仅在所选编写模型支持时使用；不确定可省略整个 reasoning，使用模型默认值 |

> [!NOTE]
>
> 不要把 `svg.model` 填成 `gpt-image-2.6-flare` 或 `gpt-image-2.6-sunburst` 来代替编写模型。支持的编写模型及 effort 取值取决于当前项目和所选模型，请先确认可用性。

返回 `data[0].b64_json` 后，Base64 解码并保存为 `.svg`。费用包括参考图的 usage 和 SVG 编写模型的 svg\_usage；两部分使用各自的费率。

`user` 为兼容旧请求保留，已废弃；新请求使用 safety\_identifier。非空 safety\_identifier 优先，未提供、null 或空字符串时才回退 user。

### 流式输出

```bash theme={null}
curl --no-buffer https://api.gravitex.ai/v1/images/generations \
  -H "Authorization: Bearer $GRAVITEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-image-2.6-flare",
  "prompt": "A simple green botanical illustration",
  "quality": "medium",
  "size": "1024x1024",
  "stream": true,
  "partial_images": 1
}'
```

## 限制与注意事项

GIF 的 size 表示每帧尺寸，受帧数、n 和模型像素预算共同约束；优先使用 auto，超过预算时减少帧数或尺寸。

GIF 可用于本端点，需要相应预览权限。不可使用 mask、stream、partial\_images 或自定义 output\_compression。帧数、单帧尺寸和 n 共用请求像素预算，超限时减少这些值或使用 size=auto。

SVG 仅用于本生成端点，要求项目具备相应权限、n=1，不支持 stream、partial\_images、output\_compression、prompt\_rewriter。当前渠道须提供 svg.model。

complexity 没有独立附加费，但可能影响延迟和输出结果。不要把低复杂度视为固定速度或固定单张价格保证。

## 响应示例

下面是非流式响应的结构示意，图片数据和 token 数仅为示例，并非实际生成结果。将 b64\_json 解码为对应格式的文件；不要将 Base64 字符串直接保存为图片。

```json theme={null}
{
  "created": 1794268800,
  "data": [
    {
      "b64_json": "<BASE64_IMAGE_DATA>"
    }
  ],
  "usage": {
    "input_tokens": 100,
    "output_tokens": 824,
    "total_tokens": 924
  }
}
```

若设置 `stream: true`，响应为 SSE 事件流；按事件读取中间预览和最终图片，不能对整个响应直接调用 JSON 解析。

## 响应与计费

本页示例为非流式调用时，图片通过 b64\_json 返回；不要传 response\_format=url 期待图片链接。输入图片和输出图片均有 token 用量；相同 token 单价不代表相同单张费用，需结合实际 usage。

返回 `data[].b64_json`，按所选格式解码保存；`usage` 为 token 用量。SVG 另可能返回 `svg_usage`，包含编写模型的用量，按该模型费率另计。下表为 OpenAI 官方标准价，不是 GravitexAI 的报价；平台结算以控制台为准。

| 类型 | 美元 / 1M tokens |
| - | - |
| 文本输入 | \$5.00 |
| 缓存文本输入 | \$1.25 |
| 图片输入 | \$8.00 |
| 缓存图片输入 | \$2.00 |
| 图片输出 | \$30.00 |

## 官方参考

* [Image generation guide](https://developers.openai.com/api/docs/guides/image-generation)
* [API Reference](https://developers.openai.com/api/reference/resources/images/methods/generate)
* [Flare](https://developers.openai.com/api/docs/models/gpt-image-2.6-flare)
* [Sunburst](https://developers.openai.com/api/docs/models/gpt-image-2.6-sunburst)
* [Pricing](https://developers.openai.com/api/docs/pricing)


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