Skip to main content
POST
编辑图片

Authorizations

Authorization
string
header
required

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

Body

multipart/form-data
model
enum<string>
required

模型 ID。gpt-image-2 为官方模型,gpt-image-2-c 为高性价比版本(支持 response_format)。

Available options:
gpt-image-2,
gpt-image-2-c
Example:

"gpt-image-2"

prompt
string
required

编辑指令文本。

Example:

"将图片背景替换为海上日落"

image
file

单张源图片文件(PNG 或 JPEG)。多图时请改用 image[]

image[]
file[]

多张源图片文件(PNG 或 JPEG),每次请求最多 16 张。多图时用此参数替代 image

mask
file

蒙版图片文件(含 Alpha 通道),用于指定源图片中要编辑的区域。必须与源图片格式和尺寸一致(< 50MB)。需在控制台选择 Direct 分组。

output_format
enum<string>
default:png

输出图片格式,默认 png

Available options:
png,
jpeg
output_compression
integer

jpeg 格式的压缩级别(0–100)。

Required range: 0 <= x <= 100
n
integer
default:1

返回图片数量,支持 1–10,默认 1需在控制台选择 Direct 分组。

Required range: 1 <= x <= 10
Example:

1

size
string
default:1024x1024

输出图片尺寸,格式 {宽}x{高},约束与图片生成接口一致(灵活分辨率)。

Example:

"1024x1024"

response_format
enum<string>
default:url

响应格式。gpt-image-2-c(高性价比版本)支持该参数,当前仅 url

Available options:
url
Example:

"url"

Response

图片编辑成功。

data
object[]

编辑后的图片数组。