← All docs

POST /v1/images/edits

Image editing (inpainting and outpainting). Supports both multipart and JSON (base64).

Image editing. Both the official OpenAI SDK's multipart/form-data upload and a JSON body (base64 string) are accepted.

Parameters

ParameterTypeRequiredDescription
modelstringYesID of a model that supports editing
promptstringYes1–4000 characters
imagestring | fileYesSource image — a base64 string in JSON, a file part in multipart
maskstring | fileNoMask for the region to edit
nintegerNoNumber of images to generate, 1–4 (default 1)
sizestringNo256x256 · 512x512 · 1024x1024 (default)
response_formatstringNourl (default) · b64_json
userstringNoEnd-user identifier

A request body larger than 5MB returns 413. Resize the image to 1024px or smaller before sending.

Request (JSON)

{
  "model": "<ID of a model that supports editing>",
  "prompt": "change the sky to sunset",
  "image": "<base64-encoded-image>",
  "n": 1
}

Response

{
  "created": 1709884800,
  "data": [
    { "url": "https://..." }
  ]
}