Generate a new image
Send a JSON request toPOST /images/generations.
Request fields
Unsupported fields include
response_format, quality, style, background, output_format, mask, and any other extra keys.
Python
Edit an image
Send multipart form data toPOST /images/edits. This endpoint supports instruction-based editing and inpainting from one or more reference images.
The gateway contract does not support an explicit mask field. Send the source image as image and describe the desired edit in prompt.
Request fields
Current model metadata controls reference-image limits. For
gpt-image-2, the gateway supports up to 3 reference images, with each image up to 8 MB.
Unsupported form fields include mask, response_format, quality, style, background, output_format, and any other extra fields. Unsupported file field names are rejected; files must be sent as image.
Multiple reference images
Python
Success response
Generation and edit responses use the same normalized JSON shape:datais always a list with exactly one item.data[0].b64_jsonis the generated or edited image encoded as base64.usage.cost_usdis a decimal USD string for the billed request when cost is available.- URL image output is not supported.
- Extra upstream fields such as
url,created,revised_prompt, or provider metadata are not returned.
Error responses
Gateway errors follow an OpenAI-style error object:
The gateway does not expose raw upstream error bodies to clients.
