Gemini API: Pricing, Keys & How to Call It
Google's Gemini API is the value play among the big three: Gemini 3.1 Pro at $2/$12 per million tokens undercuts OpenAI and Anthropic while staying competitive on agentic benchmarks, and the Flash tiers go far cheaper. It also has a genuinely usable free tier. This guide covers the full price table by tier, the free-tier limits, how to get a Google AI Studio key, and how to call it — directly or through a gateway with 300+ other models.
What the Gemini API is
The Gemini API is Google's programmatic access to its model family — Pro (top reasoning), Flash (the fast, cheap workhorse), and Flash-Lite (the budget tier) — all natively multimodal and long-context. Its pitch is value: comparable agentic and coding quality to the US frontier at a noticeably lower price, plus a usable free tier for getting started.
Gemini API pricing
| Model | Input | Output | Context |
|---|---|---|---|
| Gemini 3.1 Pro | $2 | $12 | 1M |
| Gemini 3.5 Flash | $1.50 | $9 | 1M |
| Gemini 3.1 Flash | $0.50 | $3 | 1M |
| Gemini 3.1 Flash-Lite | $0.25 | $1.50 | 1M |
Per 1M tokens, USD, June 2026. Gemini 3.1 Pro prompts over 200K tokens bill at a higher tier (~$4/$18). Cached input is heavily discounted.
The Gemini tier ladder
Gemini's range spans an 8× output-price gap from Flash-Lite to Pro — and the Flash tiers are where most of the value sits:
The free tier & limits
Unlike the Claude and OpenAI APIs, Gemini has a genuinely usable free tier through Google AI Studio — rate-limited, but enough for prototyping and low-volume apps. The caveats: rate limits are tight, there's no uptime guarantee, and free-tier data-use terms differ from the paid tier, so don't send sensitive data on free. When you outgrow it, the paid tier raises limits and changes the data terms — a one-line change if you're already on the API.
How to get a Gemini API key
- Go to Google AI Studio (aistudio.google.com) and sign in with a Google account.
- Click Get API key and create one — the basic flow needs no Cloud project setup.
- Store it as an env var:
export GEMINI_API_KEY=...
How to call the Gemini API
Gemini offers an OpenAI-compatible endpoint, so the OpenAI SDK works directly:
from openai import OpenAI
client = OpenAI(
base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
api_key="$GEMINI_API_KEY",
)
resp = client.chat.completions.create(
model="gemini-3.1-pro", # or gemini-3.5-flash, gemini-3.1-flash
messages=[{"role": "user", "content": "Summarize this PDF and extract the tables..."}],
)
print(resp.choices[0].message.content)
The native Google GenAI SDK also works and exposes more multimodal features. For switching between providers, the gateway path keeps one code shape.
Pro vs Flash vs Lite
Pro Hardest reasoning
- Deepest reasoning and very long, complex contexts. $2/$12. Use when quality on a tough problem beats cost.
Flash Best default
- 3.5 Flash ($1.50/$9) or 3.1 Flash ($0.50/$3) — cheap, fast, multimodal, often matching Pro on agentic work.
Flash-Lite Bulk & cheap
- $0.25/$1.50 — simple high-volume tasks where cost dominates.
Strength Multimodal + long context
- All tiers take text, image, audio, video, and PDF in, with a 1M-token window.
Calling Gemini through a gateway
To use Gemini alongside Claude, GPT and others under one key — with failover when Google is rate-limited — call it through a gateway. DataLLM Lab carries Gemini 3.1 Pro, 3.1 Flash, and 3.1 Flash-Lite today:
client = OpenAI(base_url="https://www.datallmlab.com/v1", api_key="$DATALLMLAB_API_KEY")
# reaches google/gemini-3.1-pro, anthropic/claude-opus-4.7, openai/gpt-5.4, ...
Call Gemini and 300+ models with one key
Gemini 3.1 Pro/Flash, Claude Opus 4.7, GPT-5.4, DeepSeek V3.2 and more — one OpenAI-compatible endpoint, live price comparison, automatic failover.
FAQ
How much does the Gemini API cost?
Per 1M tokens: 3.1 Pro $2/$12 (over 200K ~$4/$18); 3.5 Flash $1.50/$9; 3.1 Flash $0.50/$3; Flash-Lite $0.25/$1.50. Cached input is heavily discounted — cheaper than comparable OpenAI/Anthropic tiers.
Is the Gemini API free?
Yes — a rate-limited free tier via Google AI Studio, good for prototyping. Production moves to paid for higher limits and reliability; free-tier data terms differ, so avoid sensitive data on free.
How do I get a Gemini API key?
Create one at Google AI Studio (aistudio.google.com) — no Cloud project needed for the basic flow. Set GEMINI_API_KEY. Or reach Gemini via a gateway like DataLLM Lab.
What's the difference between Gemini Pro and Flash?
Pro is deepest-reasoning/highest-quality; Flash trades a little quality for much lower cost and speed, often matching Pro on agentic/coding work in 2026. Flash-Lite is cheapest for simple bulk tasks.
Which Gemini model should I use?
Flash (3.5 or 3.1) for most work, Pro for hardest reasoning / very long contexts, Flash-Lite for simple bulk. Gemini's strengths are long-context and multimodal input.
Is the Gemini API OpenAI-compatible?
Yes — Google provides an OpenAI-compatible endpoint, plus the native Google GenAI SDK. Through a gateway it's OpenAI-compatible by default.
DataLLM Lab