Gemini
How to connect a Gemini Provider, which image generation models it supports, their prices, and how thinking usage is charged.
This guide covers only what differs for the Gemini type. For adding the Provider, reviewing models, and allowing them in projects, follow Connect model Providers.
Supported request types
Section titled “Supported request types”| Request type | Support | Setting to turn on |
|---|---|---|
| Chat | Supported | None |
| Embeddings | Not supported | Not applicable |
| Image generation | gemini-3.1-flash-image and gemini-3-pro-image only | None |
Connection settings
Section titled “Connection settings”- Choose Gemini as the Provider type. Base URL is filled with
https://generativelanguage.googleapis.com. - Enter a Google API key in Credential.
AI Gateway provides built-in prices for Gemini models, and administrators cannot change them. See Model pricing and costs.
Image generation
Section titled “Image generation”gemini-3.1-flash-image and gemini-3-pro-image generate images from text prompts. Image input, editing, and multi-turn requests are unsupported. Imagen predict, the Interactions API, Vertex AI, and Custom Providers in Gemini format are outside this image generation API.
- In Model Providers, open the Gemini Provider and check its Google API key and base URL,
https://generativelanguage.googleapis.com. No image-specific toggle or endpoint setting is needed. - Check that the model you want to use is registered in Models, then allow it in the project’s model policy. Your Google account also needs access to the model and sufficient quota.
- Call the OpenAI SDK’s
images.generatewith a Gateway Key from that project. See the SDK examples.
AI Gateway sends one generateContent request and returns images as b64_json. It does not create URLs when you request response_format="url". It omits n from the Gemini request and does not repeat the call to fill the requested count. The generated count comes from the images actually returned. Blocked, incomplete, image-free results and responses containing intermediate thinking images fail with 502. Confirmed token usage and any calculable cost are still recorded on failure.
Prices and thinking usage
Section titled “Prices and thinking usage”Both models have read-only Google Standard token rates. Under Pricing → Image pricing, check the text and image rates, source link, review date, and version. AI Gateway does not substitute per-image prices or text-model prices.
| Model | Input (text and image) | Text and thinking output | Image output |
|---|---|---|---|
gemini-3.1-flash-image | $0.50 | $3 | $60 |
gemini-3-pro-image | $2 | $12 | $120 |
Rates are USD per million tokens, reviewed against Google’s official pricing on 2026-11-12. Listing an image input rate does not enable image input through this API.
Reported text and thinking usage is billed even though generated text is not returned to the client. In Model Logs, total output includes candidate output plus thinking; Reasoning tokens is a subset of that total. Text output in the image details also includes thinking, so do not add it again. The SDK response’s usage.output_tokens may show only candidate output and differ from the log total.
If a Gemini response reports only image tokens in the output breakdown and omits the text entry, the output tokens minus the image tokens are priced at the text and thinking rate. Otherwise, if the output breakdown is incomplete or cache, tool, or non-Standard billing conditions cannot be priced, confirmed tokens are preserved and cost remains Unavailable. Missing thinking is not arbitrarily treated as zero, and image counts do not substitute for token usage.