Edit images

Upload one or more source images, optionally include a mask, and request an edited result with a text instruction.

post/v1/images/edits

Request

Request body multipart/form-data

imagestring binary required

Source image file. Start with one PNG or JPG input for the simplest flow.

promptstring required

Edit instruction describing the change you want.

modelstring

The image editing model to use. Choose a supported model from the Models page.

maskstring binary

Optional PNG mask. Transparent areas indicate regions that should be edited.

nstring

Number of edited images to return.

quality'high' | 'medium' | 'low'

Quality setting for models that support it.

response_format'url' | 'b64_json'

Requested response container when supported by the selected model. GPT image edit models return data[].b64_json; use output_format to choose the encoded image type.

output_formatstring

Encoded image type for GPT image edit results returned in data[].b64_json. For example, use jpeg for a JPEG payload.

sizestring

Requested output size when supported by the selected model.

Example request

{
  "prompt": "Add a small red ribbon to the paper boat.",
  "output_format": "jpeg"
}

Response

Edited image result.

createdinteger required

Example response

{
  "created": 1776836647,
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 981,
    "prompt_tokens_details": {
      "cached_tokens_details": {}
    },
    "completion_tokens_details": {},
    "input_tokens": 785,
    "output_tokens": 196,
    "input_tokens_details": {
      "image_tokens": 768,
      "text_tokens": 17,
      "cached_tokens_details": {}
    },
    "claude_cache_creation_5_m_tokens": 0,
    "claude_cache_creation_1_h_tokens": 0
  },
  "data": [
    {
      "b64_json": "<base64-image-data>"
    }
  ]
}

Changes

No recorded changes to this operation across all 1 revision of this API.