Image edit
/v1/images/editsAn edit is a generation with references: the same handler, a JSON body only.
Request
modelstringbodyrequiredpromptstringbodyrequiredEMPTY_PROMPT)imagestring|arraybodyResponses
200
{
"created": 0,
"cost_usd": "0.027",
"data": [ { "b64_json": "iVBORw0KGgoAAAANSUhEUgAA…" } ]
}Details
Needs a key in Authorization: Bearer or x-api-key.
There is no separate code behind this route: it delegates to POST /v1/images/generations, because an edit is a generation with references attached. Every parameter, reply, error code and billing rule is the same.
⚠️ The body is parsed **as JSON only**, so references must arrive in JSON fields (image / images / image_url), with the bytes themselves as a data-URL or a base64 string in the value. A real multipart upload — which is exactly what images.edit sends from the OpenAI SDK — fails with 400 "Invalid JSON". That is a gateway limitation, not a provider one: until multipart is parsed here, SDK compatibility cannot be claimed for this route. From requests/curl, send JSON with the image as a data-URL or a base64 string.
Reference images (image-to-image, same character or style) go in the body as image — a string or an array; images, image_url, image_urls, input_image, init_image and ref_images are accepted too. A value may be a public URL, a data-URL or bare base64, and mixing the forms in one request is fine: a URL is not fetched by us and reaches the provider as a link, while base64 is decoded and sent as bytes. The gateway recognises bytes by their signature (PNG, JPEG, GIF, WebP) and caps each input at 80 MB — anything larger is a 400 before the provider is called. An input that passed our cap may still be refused by the model under its own rules: its code then arrives in error.code — FILE_TOO_LARGE for size, FILE_TYPE_NOT_ALLOWED for type. The gateway puts no limit on the number of references; how many the model actually uses is up to it. A value that parses neither as a URL nor as base64 is dropped silently: the request goes out without that reference and without an error.