Skip to main content
POST
OpenAI image edits
Use multipart/form-data to create an edited image from one or more input images.

GPT Image 2

  • image and prompt are required; use image for one file or repeat image[] for multiple files
  • Set model=gpt-image-2 explicitly to use GPT Image 2; when model is omitted, ApiGo defaults to dall-e-2
  • Additional multipart fields and files supported by the target model may also be sent; image[] may be repeated, while model, prompt, n, size, quality, and stream may each appear at most once
  • When n, size, or quality is omitted, ApiGo uses 1, 1024x1024, and medium
  • Common edit controls also include background, moderation, output_format, and output_compression; output_compression applies to JPEG/WebP and accepts 0–100
  • gpt-image-2 always processes image inputs at high fidelity, so omit input_fidelity
  • stream=true is not currently supported; the JSON response contains image data in data[].b64_json

Mask

The mask must use the same format and dimensions as the first input image and must contain an alpha channel. Transparent areas identify the region to edit. GPT Image interprets the mask together with the prompt, so the result may not follow the mask boundary exactly. With multiple input images, the mask applies only to the first image.

Authorizations

Authorization
string
header
required

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

Body

multipart/form-data
image
required

一张或多张待编辑的输入图片。

prompt
string
required

描述编辑目标的文本提示词。

Example:

"在图片中添加一朵红色的玫瑰花"

mask
file

可选蒙版。需与第一张输入图片同格式、同尺寸并包含 Alpha 通道;透明区域表示需要编辑的位置。

model
enum<string>
default:dall-e-2

图片编辑模型;未传时 ApiGo 使用 dall-e-2。

Available options:
gpt-image-2,
gpt-image-1,
dall-e-2
background
enum<string>

GPT Image 模型的输出背景。gpt-image-2 仅支持 opaque 和 auto。

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

控制输入图片细节的保留程度。gpt-image-2 始终使用高保真处理,请勿为该模型传入此参数。

Available options:
high,
low
moderation
enum<string>

GPT Image 模型的内容审核级别。

Available options:
auto,
low
n
integer
default:1

生成的编辑后图片数量。

Required range: 1 <= x <= 10
output_compression
integer
default:100

GPT Image 输出 JPEG/WebP 时的压缩率。

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

GPT Image 输出格式。

Available options:
png,
jpeg,
webp
quality
enum<string>

不同模型支持的值不同。GPT Image 未传时,ApiGo 使用 medium。

Available options:
auto,
high,
medium,
low,
standard
response_format
enum<string>

仅适用于 dall-e-2。

Available options:
url,
b64_json
size
string

允许值取决于模型。gpt-image-2 支持 auto 或符合尺寸约束的自定义分辨率;未传时 ApiGo 使用 1024x1024。

Example:

"1024x1024"

user
string

终端用户的唯一标识。

Response

Successful image edit response

created
integer<int64>
required

Unix 时间戳,单位为秒。

data
object[]
required
background
enum<string>
Available options:
transparent,
opaque,
auto
output_format
enum<string>
Available options:
png,
jpeg,
webp
quality
enum<string>
Available options:
auto,
high,
medium,
low,
hd,
standard
size
string
usage
object