Skip to main content
POST
OpenAI images.generate 兼容(含 JSON 形态图编辑分流)
Aligned with POST https://api.openai.com/v1/images/generations. Synchronous — image in the response.
Private extension (official SDK never sends this): a non-empty image (URL / data URL / raw base64, string or array) sync-routes to edit. Optional mask only applies with image.
Models: gpt-image-2 (default), gpt-image-2.5-flare, gpt-image-2.5-sunburst. response_format defaults to url (our S3). b64_json returns base64 only — never both. See Compat overview for SDK samples, size rules, and quality.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
prompt
string
required

提示词(prompt)

model
enum<string>
default:gpt-image-2

模型。默认 gpt-image-2;2.5 官方名为 gpt-image-2.5-flare / gpt-image-2.5-sunburst。

Available options:
gpt-image-2,
gpt-image-2.5-flare,
gpt-image-2.5-sunburst
size
default:1024x1024

尺寸 / 分辨率。可传 ImageResolution 枚举值,或自定义 WxH(如 1280x960)。自定义尺寸须满足以下约束:① 单边 ≤ 3840 px;② 宽、高均为 16 的倍数;③ 长边 : 短边 ≤ 3:1;④ 总像素 ∈ [655 360, 8 294 400]。不满足约束或渠道不支持自定义尺寸时请求将被拒绝。

Available options:
auto,
1024x1024,
1536x1024,
1024x1536,
2048x2048,
2048x1152,
3840x2160,
2160x3840
n
number
default:1

生成数量(当前仅支持 1)

Required range: 1 <= x <= 1
quality
enum<string>

质量等级。gpt-image-2:low/medium/high/auto;gpt-image-2.5 额外支持 xhigh/max(Firefly 渠道会落到 high)。

Available options:
auto,
low,
medium,
high,
xhigh,
max,
standard
background
enum<string>

背景透明度

Available options:
transparent,
opaque,
auto
output_format
enum<string>

输出文件格式

Available options:
png,
jpeg,
webp
output_compression
number

JPEG / WebP 的压缩等级 0-100

Required range: 0 <= x <= 100
moderation
enum<string>

审核强度

Available options:
auto,
low
response_format
enum<string>
default:url

响应格式:url 返回图片自家 S3 URL;b64_json 返回 base64。本服务对所有渠道(含 OpenAI gpt-image-* 这种上游强制返 b64 的模型)都会按本字段严格输出,不会两个字段都返回。不传时按 url 处理。

Available options:
url,
b64_json
input_fidelity
enum<string>

输入图保真度(gpt-image-2 新增,仅 edit 场景生效;generate 可忽略)

Available options:
high,
low
user
string

终端用户标识(透传给上游供滥用监控)

image

【本服务私有扩展,官方 SDK 不会传】输入图片(URL / data URL / 纯 base64)。提供则同步触发图编辑(image_edit),不提供则保持原文生图行为。支持单张字符串或字符串数组。

mask
string

【本服务私有扩展,官方 SDK 不会传】mask 图片(URL / data URL / 纯 base64);仅在同时提供 image 时生效,透明区域将被重绘。

Response

200 - application/json
created
number
required

创建时间(unix 秒)

data
object[]
required

图片列表

background
enum<string>
Available options:
transparent,
opaque
output_format
enum<string>
Available options:
png,
webp,
jpeg
quality
enum<string>
Available options:
low,
medium,
high
size
string
usage
object