POST /v1/images/generations accepts OpenAI’s Images API shape and returns
base64-encoded image bytes — the model never returns URLs.
Use
GET /v1/models for current availability and rates. Image generators have
output_modality: "image" and output_modalities: ["image"].
Generate an image
Response (abridged)
data[0].b64_json to get the image file. A revised_prompt field
accompanies an image when the provider rewrote your prompt before generating.
For Gemini, replace model with a Google model above. The response includes
data[0].mime_type, either image/png or image/jpeg, identifying the actual
encoded bytes. Use that MIME type when displaying or saving the image.
OpenAI options
Gemini options
Gemini supports one image per request (n: 1). Omit size or set it to auto
for a square 1K image; supported explicit square sizes are listed above.
quality and background can be omitted or set to auto.
Omit output_format: Gemini selects PNG or JPEG natively, and returns the
format in data[].mime_type. Explicit output_format, output_compression,
and user values are unsupported. Unsupported settings return 400 before a
provider request is sent. This endpoint currently accepts text prompts;
reference-image editing is not exposed.
Billing
Image output is billed per token like any other model — text input tokens plus image output tokens, at the rates in Models & pricing. Gemini additionally reports text and thinking output tokens, which use its separatetext_output_per_mtok_usd rate instead of the image output rate.
usage.output_tokens_details separates image_tokens and text_tokens
(including thinking); their sum is usage.output_tokens. Internal thinking
does not make an image generator a text-output model.
The cost is settled when
generation finishes and appears in GET /v1/usage and the
request log.
Two guardrails to know:
- Model and endpoint must match: sending an image model to a text endpoint
(
/v1/chat/completions, etc.) fails with400 invalid_request_error, as does sending a text model to the images endpoint. - Image generation always draws on the prepaid balance — there is no
BYOK path for it, so an empty balance returns
402even with a provider credential configured.

