Skip to main content
POST
/
v1
/
images
/
edits
OpenAI image edits
curl --request POST \
  --url http://sandbox.mintlify.com/v1/images/edits \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form 'image=<string>' \
  --form 'prompt=在图片中添加一朵红色的玫瑰花' \
  --form background=transparent \
  --form input_fidelity=high \
  --form mask='@example-file' \
  --form model=gpt-image-1 \
  --form n=1 \
  --form output_compression=100 \
  --form output_format=png \
  --form partial_images=0 \
  --form quality=auto \
  --form response_format=url \
  --form size=1024x1024 \
  --form stream=false \
  --form 'user=<string>' \
  --form image.0='@example-file' \
  --form image.1.items='@example-file'
{
  "created": 1589478378,
  "background": "auto",
  "output_format": "png",
  "quality": "high",
  "size": "1024x1024",
  "data": [
    {
      "url": "https://example.com/edited-image.png"
    }
  ],
  "usage": {
    "input_tokens": 18,
    "input_tokens_details": {
      "image_tokens": 5,
      "text_tokens": 13
    },
    "output_tokens": 1,
    "total_tokens": 19
  }
}
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