OpenAI GPT Image 2.5
GPT Image 2.5 Sunburst 与 Flare 的生成、编辑、透明背景、涂鸦、请求参数与流式输出说明,并链接独立的 2.6 对接文档。
GPT Image 2.5 包含 gpt-image-2.5-sunburst 和 gpt-image-2.5-flare。Sunburst 适合注重细节和编辑精度的任务,Flare 适合快速迭代。本文按 2026-11-06 的 OpenAI 官方说明整理。
接入 2.6 请阅读独立的 GPT Image 2.6 对接说明,其中包含 complexity、GIF 帧参数、SVG 作者配置和完整示例。两代模型 ID 分开使用,不能只根据共用接口的字段枚举推断所有能力相同。
模型与接口
| 模型 | 固定快照 |
|---|---|
gpt-image-2.5-sunburst | gpt-image-2.5-sunburst-2026-09-08 |
gpt-image-2.5-flare | gpt-image-2.5-flare-2026-09-08 |
| 操作 | 地址与请求格式 |
|---|---|
| 生成图片 | POST https://api.modelsell.com/v1/images/generations,JSON |
| 编辑图片 | POST https://api.modelsell.com/v1/images/edits,multipart 或 JSON |
使用 Authorization: Bearer $MODELSELL_API_KEY。显式传入模型名称,普通请求返回 data[].b64_json,不传旧版 response_format。
参数
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
model | string | 显式指定 | 上表中的模型或固定快照。 |
prompt | string | 必填 | 生成或编辑要求,最多 32,000 个字符。 |
n | integer | 1 | 生成数量,1–10。 |
size | string | auto | auto 或符合下述约束的 宽x高。 |
quality | string | auto | low、medium、high、xhigh、max、auto。 |
background | string | auto | auto、opaque、transparent;透明背景使用 PNG/WebP。 |
output_format | string | png | 静态输出使用 png、jpeg 或 webp。 |
output_compression | integer | 100 | JPEG/WebP 专用,0–100。 |
moderation | string | auto | auto 或 low。 |
stream | boolean | false | 开启 SSE 流式输出。 |
partial_images | integer | 0 | 流式预览数量,0–3;0 只返回最终图片,实际预览数可能少于请求数。 |
safety_identifier | string | 省略 | 最多 128 个字符的稳定用户标识,建议使用哈希值。 |
user | string | 省略 | 已弃用;仅在 safety_identifier 省略、为 null 或空字符串时作为回退值。 |
image | 文件 / 文件数组 | 编辑必填 | multipart 底图字段;多图使用 image[]。 |
images | 引用对象数组 | 编辑必填 | JSON 底图字段,每个对象使用 image_url 或 file_id。与 multipart 的 image 选择对应请求格式使用。 |
mask | 文件 / 引用对象 | 省略 | 带透明通道的 PNG 遮罩,匹配第一张底图尺寸;透明区域用于指定编辑区域。 |
markup | 文件 / 引用对象 | 省略 | 在第一张底图上叠加的独立透明 PNG 涂鸦层;与 mask 互斥。 |
2.6 的 complexity、frame_count、frame_duration_ms、svg 等字段和格式约束在 2.6 参数表 中单独说明。
尺寸与透明背景
常用尺寸为 1024x1024、1536x1024、1024x1536。2.5 自定义尺寸满足:两边均为 16 的倍数、宽高比在 1:3 到 3:1 之间、任一边不超过 3840 像素、总像素在 655,360 到 8,294,400 之间。高于 2560x1440 像素量的分辨率属于实验性范围。
background: "transparent" 搭配 output_format: "png" 或 "webp",保存结果时保留 Alpha 通道。JPEG 不支持透明背景;PNG 请求省略 output_compression。
生成示例
curl --fail-with-body -sS https://api.modelsell.com/v1/images/generations \
-H "Authorization: Bearer $MODELSELL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.5-flare",
"prompt": "一个深蓝色陶瓷杯,独立主体,完全透明背景,没有阴影",
"size": "1024x1024",
"quality": "high",
"background": "transparent",
"output_format": "png",
"n": 1
}' > result.json编辑与涂鸦示例
底图支持 PNG、JPEG/JPG、WebP,每张小于 50 MB,最多 16 张。底图无需全部转换为 PNG。使用 markup 时,覆盖层必须含透明像素,且与第一张底图方向校正后的宽高一致;第一张底图和涂鸦层各不超过 16,777,216 像素,涂鸦层文件不超过 50 MB。不要同时发送 mask 或 prompt_rewriter。
curl --fail-with-body -sS https://api.modelsell.com/v1/images/edits \
-H "Authorization: Bearer $MODELSELL_API_KEY" \
-F 'model=gpt-image-2.5-sunburst' \
-F '[email protected];type=image/webp' \
-F '[email protected];type=image/png' \
-F 'prompt=把红圈中的椅子改为绿色,移除标记,保持其他内容不变' \
-F 'quality=high' \
-F 'output_format=png' > result.json不需要涂鸦引导时省略 markup。JSON 编辑使用下面的对象结构,发送到 /v1/images/edits:
{
"model": "gpt-image-2.5-flare",
"prompt": "保留产品外观,将背景换成柔和的浅灰色",
"images": [
{ "image_url": "https://example.com/product.jpg" }
],
"output_format": "png"
}引用对象支持 HTTPS URL、Base64 data URL 或 Files API 的 file_id。每个对象仅提供 image_url 和 file_id 中的一个;mask、markup 的 JSON 形式也各使用一个引用对象。
结果与流式输出
import base64
import json
from pathlib import Path
result = json.loads(Path("result.json").read_text())
Path("result.png").write_bytes(base64.b64decode(result["data"][0]["b64_json"]))非流式响应还可包含 created、size、quality、background、output_format、usage 和有效的 safety_identifier。
设置 stream: true 后按 SSE 读取:生成事件为 image_generation.partial_image / image_generation.completed,编辑事件为 image_edit.partial_image / image_edit.completed。每个事件直接携带 b64_json;最终结果以 completed 事件为准。partial_images: 0–3 控制预览数量,记录最终返回的 usage。