Image Editing

Edit existing images using GPT Image series models based on text prompts.

Endpoint

POST /v1/images/edits

Authentication

All requests require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY

Request Parameters

ParameterTypeRequiredDescription
modelstringYesModel ID, e.g., gpt-image-1
imagefile/stringYesImage to edit, can be a file or URL
promptstringYesText describing how to edit the image
maskfile/stringNoMask image specifying the area to edit
nintegerNoNumber of images to generate, default 1
sizestringNoImage size, default 1024x1024
response_formatstringNoResponse format, options: url, b64_json, default url

Request Example

curl -X POST "https://api.example.com/v1/images/edits" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-1",
    "image": "https://example.com/original-image.png",
    "prompt": "Change the background to a beach",
    "n": 1,
    "size": "1024x1024"
  }'

Response Example

{
  "created": 1700000000,
  "data": [
    {
      "url": "https://example.com/edited-image.png",
      "revised_prompt": "Change the image background to a beautiful tropical beach"
    }
  ]
}

Response Fields

FieldTypeDescription
createdintegerCreation timestamp
dataarrayList of edited images
data[].urlstringImage URL
data[].b64_jsonstringBase64 encoded image
data[].revised_promptstringModel’s revised prompt