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

# GPT-Image-2.6 图片生成

> - 异步处理模式，返回任务 ID 用于后续查询
- OpenAI GPT-Image 2.6 家族：Flare（出图更快）与 Sunburst（更重细节和编辑保真）
- 支持文生图 / 图生图 / 参考图编辑，参考图最多 10 张
- 支持 14 种比例（含 auto），通过 aspect_ratio 传入
- 支持 resolution 档位 1K / 2K / 4K，以及 API 专用 size 自定义像素
- 支持 GIF 动图输出：output_format 传 gif，可设帧数（2–9）与每帧时长
- 每次请求返回 1 张图片（PNG 或 GIF）
- 提交的 prompt 会经过平台敏感词 / 安全审核，违规内容会被直接拒绝


> [!NOTE]
>
> GPT-Image 2.6 在 AIReiter 中有两个模型名称：`gpt_image_2_6_flare` 和 `gpt_image_2_6_sunburst`，没有单独的 `gpt_image_2_6`。两个模型的参数完全相同。
>
> `output_format` 可选 `png`（默认）或 `gif`。本接口不开放 `quality`、`output_n`、`background`，也不支持 SVG 矢量图和蒙版 / 圈选局部编辑。

## Authorizations

**Authorization** `string` *required*

所有接口均需要使用 Bearer Token 进行认证

获取 API Key：

访问 [API Key 管理页面](https://aireiter.com/keys) 获取您的 API Key

使用时在请求头中添加：

```
Authorization: Bearer YOUR_API_KEY
```

## Body

**model** `string` *required*

模型名称，二选一：

* `"gpt_image_2_6_flare"` — Flare，出图更快，适合草稿和批量
* `"gpt_image_2_6_sunburst"` — Sunburst，更重细节，适合要保住人物、商品或版式的编辑

对比两个模型时请保持 prompt、参考图、比例和分辨率不变。

**params** `object` *required*

模型参数对象

**params 对象属性**

**prompt** `string` *required*

图像生成的文本描述

* 支持中英文，建议详细描述
* 改图时写清要改什么、哪些必须保持不变
* 需要透明背景时，请直接在提示词中说明（如 "transparent background"），是否透明由模型决定
* 提交前会经过平台敏感词 / 安全审核，命中违规内容会直接返回错误

**output\_format** `string` (default: png)

输出格式，默认 `png`

* `png` - 静态图片
* `gif` - 循环动图，配合 `frame_count`、`frame_duration_ms` 使用

> [!WARNING]
>
> `gif` 时不支持 `image_url` 参考图（传入会导致任务失败），不使用 `resolution`，`aspect_ratio` 仅支持 `auto`、`1:1`、`16:9`、`9:16`、`4:3`、`3:4`、`3:2`、`2:3`，传入其他比例返回 400。

**image\_url** `string[]`

参考图数组，传入后走图生图 / 编辑模式（仅 `output_format` 为 `png` 时可用）

* 最多 10 张参考图
* 不传则走纯文生图
* 支持以下两种格式：
  1. 公开可访问的 URL
  2. Base64 编码格式
     * 必须使用完整的 Data URI 格式：`data:image/{格式};base64,{base64数据}`
     * 支持的图片格式：jpeg、png、webp
     * 示例：`data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABg...`
     * ⚠️ 注意：必须包含 `data:image/jpeg;base64,` 前缀部分

**aspect\_ratio** `string` (default: auto)

图像生成的比例，默认 `auto`

支持以下取值：

* `auto` - 自动选择最合适的比例
* `1:1` - 正方形
* `16:9` / `9:16` - 宽屏横 / 竖
* `4:3` / `3:4` - 标屏横 / 竖
* `3:2` / `2:3` - 经典横 / 竖
* `5:4` / `4:5` - 近方横 / 竖
* `2:1` / `1:2` - 宽横 / 长竖
* `21:9` / `9:21` - 超宽横 / 超长竖

> [!WARNING]
>
> 仅支持比例字符串或 `auto`；传像素尺寸（如 `1024x1024`）会直接报错。需要精确像素请用 `size`。

**resolution** `string` (default: 1K)

分辨率档位，默认 `1K`

* `1K` - 约 1024 基准
* `2K` - 约 2048 基准
* `4K` - 约 3840 基准

> [!WARNING]
>
> 传入 `size` 时不要再传 `resolution` / `aspect_ratio`，否则返回 400。

**frame\_count** `integer` (default: 9)

GIF 帧数，仅 `output_format` 为 `gif` 时生效，默认 `9`

* 取值范围 `2` \~ `9`，超出范围返回 400

**frame\_duration\_ms** `integer` (default: 200)

GIF 每帧时长（毫秒），仅 `output_format` 为 `gif` 时生效，默认 `200`

* 取值范围 `100` \~ `500`，按 10 毫秒取整，超出范围返回 400
* 例如 9 帧 × 200 毫秒，循环一圈 1.8 秒

**size** `string`

自定义像素尺寸（仅 API，与 `aspect_ratio` / `resolution` **互斥**）

格式为 `宽x高`，例如 `2048x1536`、`3840x2160`。

**使用限制：**

* 格式必须为 `^\d+x\d+$`
* 宽、高均为 16 的倍数
* 每边不超过 3840
* 长边 / 短边不超过 3:1
* 总像素（宽 × 高）在 **655,360 \~ 8,294,400**
* 与 `aspect_ratio`、`resolution` 互斥，同时传入返回 400
* `gif` 时会按比例换成最接近的 GIF 帧尺寸（见下方 GIF 帧尺寸表）

**out\_task\_id** `string` *required*

发起方任务 ID

用户自定义的任务标识，必填。查询结果时用同一个值调用 `POST /api/openapi/query`。

## 尺寸 × 分辨率映射表

`aspect_ratio × resolution` → 实际像素（`auto` 由模型自选，不在表内）：

| aspect\_ratio | `1K` | `2K` | `4K` |
| - | - | - | - |
| `1:1` | 1024×1024 | 2048×2048 | 2880×2880 |
| `3:2` | 1536×1024 | 2048×1360 | 3520×2336 |
| `2:3` | 1024×1536 | 1360×2048 | 2336×3520 |
| `4:3` | 1024×768 | 2048×1536 | 3312×2480 |
| `3:4` | 768×1024 | 1536×2048 | 2480×3312 |
| `5:4` | 1280×1024 | 2560×2048 | 3216×2576 |
| `4:5` | 1024×1280 | 2048×2560 | 2576×3216 |
| `16:9` | 1536×864 | 2048×1152 | 3840×2160 |
| `9:16` | 864×1536 | 1152×2048 | 2160×3840 |
| `2:1` | 1760×880 | 2688×1344 | 3840×1920 |
| `1:2` | 880×1760 | 1344×2688 | 1920×3840 |
| `21:9` | 1904×816 | 2688×1152 | 3840×1648 |
| `9:21` | 816×1904 | 1152×2688 | 1648×3840 |

> `3:2` / `2:3` @ 2K 实际是 2048×1360（近似比例）。需要表外比例请用 `size`。

## GIF 帧尺寸

`output_format` 为 `gif` 时，每一帧的尺寸由 `aspect_ratio` 决定（`auto` 按 `1:1`）：

| aspect\_ratio | 每帧尺寸 |
| - | - |
| `1:1` | 896×896 |
| `16:9` | 1088×608 |
| `9:16` | 608×1088 |
| `4:3` | 960×720 |
| `3:4` | 720×960 |
| `3:2` | 1008×672 |
| `2:3` | 672×1008 |

## Response

**out\_task\_id** `string`

发起方任务 ID，可用于查询结果

**status** `string`

初始状态，通常为 `"pending"`

**created\_at** `string`

创建时间（ISO 格式）

## Query Task

GPT-Image 2.6 是异步图片生成模型。提交任务后，请使用 `out_task_id` 查询任务状态。也可参见 [获取任务状态](https://docs.aireiter.com/zh/api-reference/tasks/status.md)。

**out\_task\_id** `string` *required*

提交任务时传入的发起方任务 ID。

```bash theme={null}
curl --request POST \
  --url https://aireiter.com/api/openapi/query \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "out_task_id": "my_task_123456"
  }'
```

查询成功并完成后，响应中的 `output` 数组会包含生成的图片（PNG 或 GIF）。

实测单张 1K 图片约 25～45 秒完成，GIF 约 25～70 秒，Sunburst 通常比 Flare 稍慢；分辨率越高、参考图越多耗时越久，请持续轮询，不要重复提交。

## 使用说明

* 只传 `prompt` 时是文生图；传了 `image_url` 后按参考图编辑处理，未在提示词中提到的部分会尽量保持不变。
* 每次请求只返回 1 张图片，需要多张请分别提交。
* 默认输出 PNG；传 `output_format: "gif"` 输出循环 GIF 动图。
* GIF 只根据 `prompt` 生成，请在提示词里写清主体、动作和循环方式（例如"挥手后回到初始姿势"）；动作越简单，帧间越连贯。
* 4K 档位适合需要大尺寸交付的场景；对细节要求高的写实画面，建议先用 1K / 2K 确认构图再出 4K。

## Request Examples

```bash cURL（Flare + aspect_ratio） theme={null}
curl --request POST \
  --url https://aireiter.com/api/openapi/submit \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt_image_2_6_flare",
    "params": {
      "prompt": "一张扁平矢量风格的海报：月牙下坐着一只狐狸，标题文字 \"NIGHT SHIFT\"，纯色块，白色背景",
      "aspect_ratio": "16:9",
      "resolution": "1K"
    },
    "out_task_id": "my_task_123456"
  }'
```

```bash cURL（Sunburst + 参考图） theme={null}
curl --request POST \
  --url https://aireiter.com/api/openapi/submit \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt_image_2_6_sunburst",
    "params": {
      "prompt": "把橙色方块改成一个纸箱，其余画面保持不变",
      "image_url": ["https://example.com/product.png"],
      "aspect_ratio": "1:1",
      "resolution": "2K"
    },
    "out_task_id": "my_task_edit_001"
  }'
```

```bash cURL（size 自定义尺寸） theme={null}
curl --request POST \
  --url https://aireiter.com/api/openapi/submit \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt_image_2_6_flare",
    "params": {
      "prompt": "一张扁平矢量风格的海报：月牙下坐着一只狐狸，标题文字 \"NIGHT SHIFT\"，纯色块，白色背景",
      "size": "2048x1152"
    },
    "out_task_id": "my_task_size_001"
  }'
```

```bash cURL（GIF 动图） theme={null}
curl --request POST \
  --url https://aireiter.com/api/openapi/submit \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt_image_2_6_flare",
    "params": {
      "prompt": "一只戴红色爪印领巾的小猫站起来挥爪，温馨客厅，挥完回到初始姿势，无缝循环",
      "output_format": "gif",
      "aspect_ratio": "1:1",
      "frame_count": 9,
      "frame_duration_ms": 200
    },
    "out_task_id": "my_task_gif_001"
  }'
```

```python Python theme={null}
import requests

url = "https://aireiter.com/api/openapi/submit"

payload = {
    "model": "gpt_image_2_6_flare",
    "params": {
        "prompt": "一张扁平矢量风格的海报：月牙下坐着一只狐狸，标题文字 \"NIGHT SHIFT\"，纯色块，白色背景",
        "aspect_ratio": "16:9",
        "resolution": "1K"
    },
    "out_task_id": "my_task_123456"
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

```javascript JavaScript theme={null}
const url = "https://aireiter.com/api/openapi/submit";

const payload = {
  model: "gpt_image_2_6_flare",
  params: {
    prompt: "一张扁平矢量风格的海报：月牙下坐着一只狐狸，标题文字 \"NIGHT SHIFT\"，纯色块，白色背景",
    aspect_ratio: "16:9",
    resolution: "1K"
  },
  out_task_id: "my_task_123456"
};

fetch(url, {
  method: "POST",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
})
  .then((response) => response.json())
  .then((data) => console.log(data));
```

```go Go theme={null}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    url := "https://aireiter.com/api/openapi/submit"
    payload := map[string]interface{}{
        "model": "gpt_image_2_6_flare",
        "params": map[string]interface{}{
            "prompt":       "一张扁平矢量风格的海报：月牙下坐着一只狐狸，标题文字 \"NIGHT SHIFT\"，纯色块，白色背景",
            "aspect_ratio": "16:9",
            "resolution":   "1K",
        },
        "out_task_id": "my_task_123456",
    }
    jsonData, _ := json.Marshal(payload)
    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Authorization", "Bearer <token>")
    req.Header.Set("Content-Type", "application/json")
    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```json 200 theme={null}
{
    "statusCode": 200,
    "message": "",
    "data": {
        "out_task_id": "my_task_123456",
        "status": "pending",
        "created_at": "2026-11-06T06:00:00.000Z"
    }
}
```

```json 400 theme={null}
{
    "statusCode": 400,
    "message": "请求参数无效",
    "ok": false
}
```

```json 401 theme={null}
{
  "error": {
    "code": 401,
    "message": "身份验证失败，请检查您的API密钥"
  }
}
```

```json 500 theme={null}
{
  "error": {
    "code": 500,
    "message": "服务器内部错误，请稍后重试"
  }
}
```


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