Skip to main content
The gateway also generates images: an OpenAI-compatible endpoint sits alongside chat completions, authenticated with the same API key (as Authorization: Bearer or x-api-key) and governed by the same per-client rate limits as every other /v1 route. Requests are synchronous — multi-image or high-quality generations can take tens of seconds, so set client timeouts accordingly.

Request parameters

Response

The response follows the OpenAI images shape — created (unix seconds), a data array with one entry per generated image, and an optional usage object on token-priced models:
  • With response_format: "url" (the default), each image is stored by the gateway and returned as a signed download URL valid for ~24 hours — download promptly and persist on your side.
  • With response_format: "b64_json", each entry carries the base64-encoded PNG bytes inline instead.
  • revised_prompt appears when the provider rewrites your prompt before generating.

Models & pricing

Token-based models report token counts in the response usage object. Every request’s cost is metered against your key exactly like chat traffic and counts toward the same spend caps.
Imagen retirement. Google is shutting down the entire Imagen family on August 17, 2026, and the whole line is now delisted from the gateway: imagen-4, imagen-4-fast, and imagen-4-ultra IDs all return errors. The migration target is gemini-2.5-flash-image (GA, token-based, ≈ $0.039 / image); gpt-image-1 also remains available.
Reliability. Upstream image backends occasionally stall with a 503 for a few minutes. There is deliberately no automatic fallback to a different image model — silently swapping models would change output style and quality — so callers should retry instead. The SDKs already retry 503s with jittered backoff up to their configured retry budget.

Using the SDKs

All five SDKs ship an image-generation helper as of SDK v0.4.0, with the same auth, error mapping (401 → AccessDeniedException, 402 → ServiceQuotaExceededException, 429 → ThrottlingException), and retry policy as Converse:
Errors reuse the chat-completions codes: 400 invalid_request_error for a malformed body, 401 invalid_api_key, 402 usage_cap_exceeded when a spend cap is reached (never retried), and 429 rate_limit_exceeded with a Retry-After header. See Errors & retries for the full exception mapping in each SDK.