Skip to main content
Use the Image API to generate new images from text prompts or edit one or more reference images. The image endpoints use the same base URL and Bearer token authentication as the rest of the LLM7 API.
The Image API is intentionally strict. Unsupported fields are rejected on input, and successful responses are normalized so provider-only fields are not exposed.

Generate a new image

Send a JSON request to POST /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 to POST /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:
Response contract:
  • data is always a list with exactly one item.
  • data[0].b64_json is the generated or edited image encoded as base64.
  • usage.cost_usd is 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.
Decode the image:

Error responses

Gateway errors follow an OpenAI-style error object:
Common cases: The gateway does not expose raw upstream error bodies to clients.