Skip to main content
POST
OpenAI image edits
Use this endpoint for image edits, inpainting, and source-image transformations.
  • Authenticate with Authorization: Bearer {API_KEY}
  • This endpoint commonly uses multipart/form-data
  • The required inputs are typically image and prompt, while mask narrows the editable region
  • gpt-image-1 and dall-e-2 differ materially on file-size limits, multi-image support, and input_fidelity
  • If the response contains temporary url values, mirror them quickly. If it contains b64_json, avoid decoding too many large images on the main thread

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

Input image or images to edit.

prompt
string
required

Text instruction describing the desired edit.

Example:

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

background
enum<string>

Only supported by gpt-image-1.

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

Only supported by gpt-image-1.

Available options:
high,
low
mask
file

Optional PNG mask file. Usually must match the image dimensions.

model
enum<string>

Image editing model.

Available options:
gpt-image-1,
dall-e-2
n
integer
default:1

Number of edited images to generate.

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

Compression level for gpt-image-1 jpeg/webp output.

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

Only supported by gpt-image-1.

Available options:
png,
jpeg,
webp
partial_images
integer
default:0

Number of partial images for streaming previews.

Required range: 0 <= x <= 3
quality
enum<string>

Supported values vary by model.

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

Only applies to dall-e-2.

Available options:
url,
b64_json
size
enum<string>

Allowed values depend on the selected model.

Available options:
1024x1024,
1536x1024,
1024x1536,
auto,
256x256,
512x512
stream
boolean
default:false

Streams edited image output when supported.

user
string

Unique identifier for the end user.

Response

Successful image edit response

created
integer<int64>
required

Unix timestamp in seconds.

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