Skip to navigation

Edit images

Changes one or more images following a prompt, optionally only where a mask is transparent.

Authentication

AuthorizationBearer

Your API key, sk-..., from Console → API keys.

Request

This endpoint expects a multipart form with multiple files.
modelstringRequired
promptstringRequired
imagefileRequired
The image to edit.
maskfileOptional
A PNG whose transparent areas mark what to change.
nintegerOptional>=1
sizestringOptional
qualitystringOptional
backgroundenumOptional
Allowed values:
output_formatenumOptional
Allowed values:
userstringOptional
metadatamap from strings to stringsOptional

Response

The edited images, inline as base64 in data[].b64_json.

createdintegerOptional
datalist of objectsOptional
usageobjectOptional
Token usage, for models billed by tokens.

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
404
Not Found Error
422
Unprocessable Entity Error
429
Too Many Requests Error
502
Bad Gateway Error
503
Service Unavailable Error