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

# GPT Image 2.6

> OpenAI 最新一代生图模型。

Flare 与 Sunburst 同代同价、能力相同，任选其一即可；画质分低、中、高三档，按张计费。

* 模型 ID：`gpt-image-2.6-flare`、`gpt-image-2.6-sunburst`（参数与用法相同）
* 接口：`POST https://token.poryf.com/v1/images/generations`（文生图）、`POST https://token.poryf.com/v1/images/edits`（图片编辑），同步返回
* [查看价格](https://token.poryf.com/pricing/gpt-image-2.6-flare) · [在线试用](https://token.poryf.com/model-guide/gpt-image-2.6-flare)（登录后，按自己的余额扣费）

## 请求参数

**Authorization** `string` *required*

`Bearer YOUR_API_KEY`，在 [控制台的 API 密钥页](https://token.poryf.com/keys) 创建。

**model** `string` *required*

`gpt-image-2.6-flare`、`gpt-image-2.6-sunburst`

**prompt** `string` *required*

画面描述。

**size** `string`

输出尺寸，格式为 `宽x高`，如 `1024x1024`、`1536x1024`、`1024x1536`，最大边长 3840 px（4K）；也可以不传 `size`，改用 `resolution`（`1K`、`2K`、`4K`）加 `aspect_ratio`（如 `16:9`）。按实际出图像素归入 1K / 2K / 4K 档计价。

**quality** `string`

画质：`low`、`medium`、`high`。画质越高越贵、越慢。

**output\_format** `string`

`png` 或 `jpeg`。

**images** `array`

参考图，最多 16 张。使用 JSON 传 URL 或 PNG、JPEG、WebP 的 Base64 data URL 数组，如 `images: [{"image_url": "https://example.com/shiba.png"}]`；也支持 `image: "https://example.com/shiba.png"`。两个图片接口均可传参考图，图片编辑推荐使用 `/v1/images/edits`。

## 示例：文生图

```bash theme={null}
curl https://token.poryf.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2.6-flare",
    "prompt": "秋日咖啡店的拿铁海报，暖色调，留出标题位置",
    "size": "1024x1024",
    "quality": "low"
  }'
```

## 示例：图片编辑

图片编辑推荐走 `/v1/images/edits`，使用 JSON 传参考图 URL；本地文件先转成 Base64 data URL。

```bash 传图片 URL（JSON） theme={null}
curl https://token.poryf.com/v1/images/edits \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2.6-flare",
    "prompt": "给这只柴犬戴上一条红色围巾，其余保持不变",
    "images": [{ "image_url": "https://example.com/shiba.png" }],
    "quality": "low",
    "size": "1024x1024"
  }'
```

```python Python theme={null}
import base64
import json
import os
from pathlib import Path
from urllib.request import Request, urlopen

image = "data:image/png;base64," + base64.b64encode(Path("shiba.png").read_bytes()).decode("ascii")
payload = {
    "model": "gpt-image-2.6-flare",
    "prompt": "给这只柴犬戴上一条红色围巾，其余保持不变",
    "images": [image],
    "quality": "low",
    "size": "1024x1024",
}
request = Request(
    "https://token.poryf.com/v1/images/edits",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": "Bearer " + os.environ["TOKENDISCOUNT_API_KEY"],
        "Content-Type": "application/json",
    },
)
with urlopen(request, timeout=600) as response:
    result = json.load(response)
print(result["data"][0]["b64_json"][:32])
```

> [!WARNING]
>
> 当前不支持 multipart 文件上传。参考图请使用 `image` 或 `images` 字段；顶层 `image_url`、`reference_images`、`input_image` 等未支持的参数，以及为空或格式有误的参考图，会返回 HTTP 400，不会提交生成或扣费。纯文生图请省略参考图字段。

## 响应

示例结构：

```json theme={null}
{
  "data": [
    { "b64_json": "iVBORw0KGgo..." }
  ]
}
```

GPT Image 默认在 `b64_json` 中返回 Base64 图片；请求里传 `"response_format": "url"` 则改为返回 `url` 链接，同一请求的返回格式固定，不随线路变化。

## 计费

按张计费：按分辨率档（1K / 2K / 4K，按实际出图像素判定）和画质计价，每张参考图另计。参考：1K 低画质约 ¥0.17 / 张，中画质约 ¥0.31 / 张，高画质约 ¥0.37 / 张；4K 高画质约 ¥1.25 / 张；图片编辑每张参考图另加约 ¥0.09。实时单价见模型广场。

> [!WARNING]
>
> * Nano Banana 与可灵的参考图只接受公网可访问的 `http(s)` URL，不支持上传文件或 Base64。
> * 生成结果是临时链接：GPT Image 约 24 小时失效，Nano Banana 与可灵约 7 天失效。请及时下载转存。
> * 接口同步返回，出图可能需要 1–2 分钟，请把客户端超时设为 5 分钟以上，避免重复提交导致重复扣费。

实时单价见 [模型广场](https://token.poryf.com/pricing)。通用字段、响应格式和常见错误见 [图片通用说明](https://docs.token.poryf.com/api/images/overview.md)。


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