How to Get a Gemini API Key (Free Tier & Paid)
"How do I get a Gemini API key?" has a one-line answer: sign in at aistudio.google.com/apikey and click Create API key — a key created in Google AI Studio works immediately on the free tier, no billing required. This guide covers the full path: the exact create-key steps, what the free tier actually allows (and what the docs no longer publish as a fixed table), when and how to move to paid, Gemini's OpenAI-compatible endpoint so you can reuse existing SDK code, and a gateway alternative that gives you one key for Gemini and other model families.
Get a Gemini API key (the fast answer)
Sign in at Google AI Studio and click Create API key — that is the whole thing. The key you get works immediately on the free tier, with no billing account required:
- Go to aistudio.google.com/apikey (also reachable as
aistudio.google.com/api-keys) and sign in with your Google account. - Click Create API key.
- Copy the key and store it as an environment variable — every key created in Google AI Studio is automatically an auth key you can use right away.
That is the flow documented on Google's official API key page. The sections below cover the details people actually get stuck on: what the free tier covers, when to move to paid, and how to reuse OpenAI SDK code against Gemini.
Create the key in Google AI Studio, step by step
The create-key flow lives entirely inside Google AI Studio — you do not need to touch the Google Cloud console to get started. Walking it through:
- Open the API Keys page. Navigate to aistudio.google.com/apikey. If you have never used AI Studio, you may be asked to accept terms first.
- Click Create API key. AI Studio associates the key with a Google Cloud project (it can create one for you). All keys minted here are created as auth keys automatically.
- Copy it once. Treat the key like a password — never commit it to source control or ship it in client-side code.
- Set it in your environment. Export it so your SDK picks it up:
# macOS / Linux
export GEMINI_API_KEY="your-key-here"
A first call against the native Gemini SDK, to confirm the key works:
from google import genai
client = genai.Client() # reads GEMINI_API_KEY from the environment
resp = client.models.generate_content(
model="gemini-2.5-flash",
contents="Say hi in one word.",
)
print(resp.text)
The free tier and its limits
Yes, there is a genuinely free tier — you can build and test before ever setting up billing. Google's rate-limits documentation lists a Free usage tier that provides API access at no cost with an active project or free trial. The catch to understand in 2026: the official page no longer publishes a fixed per-model RPM/TPM/RPD table. It states that limits depend on your usage tier and directs you to view your active limits in the AI Studio dashboard at aistudio.google.com/rate-limit, noting the specified limits are not guaranteed and actual capacity may vary.
So the honest answer to "what are the free-tier limits?" is: check your own dashboard, because they are account- and tier-specific and can change. One widely-cited figure — roughly 10 requests/min, 250,000 tokens/min, and 250 requests/day for gemini-2.5-flash on the free tier — comes from a search-result snippet rather than the currently-published live table, so treat it as indicative only, not a guarantee.
Moving to paid: the four usage tiers
The Gemini API scales your rate limits across four tiers; you move up by linking billing and accumulating spend. The qualification thresholds, straight from Google's rate-limits docs:
| Tier | How you qualify | Rate limits |
|---|---|---|
| Free | Active project or free trial | Lowest |
| Tier 1 | Set up and link an active billing account | Higher |
| Tier 2 | $100 total spend + 3 days from first successful payment | Higher still |
| Tier 3 | $1,000 total spend + 30 days from first successful payment | Highest |
The practical upgrade path is simple: link a billing account to your Google Cloud project and you jump from Free to Tier 1 immediately. Tiers 2 and 3 then advance automatically as your spend and payment history grow. If you keep hitting caps, this — not a support ticket — is the lever.
Free vs paid: the tier decision table
Which tier you need is mostly a function of how bursty and high-volume your traffic is. A synthesized view of what each tier is actually for:
| Tier | Best for | Requires billing? | Move up when |
|---|---|---|---|
| Free | Prototyping, learning, low-volume side projects | No | You hit RPD/RPM caps in testing |
| Tier 1 | Production apps with modest, steady traffic | Yes (linked account) | Sustained load nears your limits |
| Tier 2 | Scaling apps with real usage | Yes ($100+ spent) | You need more headroom for spikes |
| Tier 3 | High-volume / heavy agentic workloads | Yes ($1,000+ spent) | — |
Because the live per-model numeric limits are now dashboard-only, this table describes tier purpose rather than exact RPM/TPM figures — check your dashboard for the numbers that apply to your account. If rate limits are your real problem, our cross-provider 429 fix guide covers the durable fixes.
The OpenAI-compatible endpoint
You do not have to rewrite your app around Google's SDK — Gemini ships an OpenAI-compatible endpoint. Per Google's OpenAI-compatibility docs, Gemini models are accessible through the OpenAI Python and TypeScript/JavaScript libraries and the REST API by setting base_url to https://generativelanguage.googleapis.com/v1beta/openai/ and passing your Gemini API key as api_key:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_GEMINI_API_KEY",
base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
)
resp = client.chat.completions.create(
model="gemini-2.5-flash",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
Two lines change from a stock OpenAI call: the base_url and the model id. If you are new to this pattern — swapping the base URL to point an OpenAI client at a non-OpenAI provider — our OpenAI-compatible API explainer walks through why it works and where the edge cases are.
Which model to point your key at
For most work, start with a Flash model; reach for Pro only when you need deeper reasoning. The current Gemini lineup, from Google's changelog and models pages (verified July 2026):
| Model id | What it is | Status |
|---|---|---|
gemini-3.5-flash | Google's most intelligent model; backs the gemini-flash-latest alias | GA (May 19 2026) |
gemini-3.1-pro-preview | Latest Gemini Pro (Gemini 3 series) | Preview (Feb 19 2026) |
gemini-2.5-pro | Advanced 2.5-gen model for complex reasoning & coding | Stable |
gemini-2.5-flash | Best price-performance for low-latency, high-volume tasks | Stable |
gemini-2.5-flash-lite | Lightest 2.5-gen model | Stable |
Watch for aliases: gemini-3-pro-preview was shut down on March 9 2026 and now points to gemini-3.1-pro-preview, so pin the explicit id if you need reproducibility. For the wider "which model should I actually pick" question, see our best LLM API roundup and, if you are choosing between families, Gemini 2.5 Pro vs Claude.
One key for Gemini and other models
A native Gemini key only calls Google models — a gateway gives you one key across families. If your app uses Gemini alongside other models (or you want to fail over when one provider is down or rate-limited), managing a separate key per provider gets painful fast. DataLLM Lab exposes an OpenAI-compatible endpoint at https://www.datallmlab.com/v1 where a single key reaches Gemini chat models plus other model families:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_DATALLMLAB_KEY",
base_url="https://www.datallmlab.com/v1",
)
resp = client.chat.completions.create(
model="gemini-2.5-flash", # or another family — same key
messages=[{"role": "user", "content": "Hello"}],
)
Because the base URL is OpenAI-compatible, the same client also exposes a /v1/embeddings endpoint if your pipeline needs it. The routing-and-failover mechanics — reroute a rate-limited or overloaded request to an equivalent model — are covered in our routing & failover guide and the broader what-is-a-gateway explainer. Getting a Gemini-only key is a different flavour of the same task as our Grok API key walkthrough.
One key for Gemini and 300+ other models
DataLLM Lab is OpenAI-compatible on one base URL and one key — call Gemini chat models today, fail over to another family when Google is rate-limited or down, no per-provider key juggling.
FAQ
Where do I get a Gemini API key?
Sign in at Google AI Studio and click Create API key. Keys created there are auto-created as auth keys and work immediately on the free tier without billing.
Is the Gemini API free?
Yes — there is a Free usage tier that provides API access at no cost with an active project or free trial. Higher tiers unlock larger rate limits once you link billing.
What are the Gemini free tier limits?
The official page no longer publishes a fixed table; it points you to your AI Studio dashboard. One snippet reports ~10 req/min, 250K tokens/min and 250 req/day for gemini-2.5-flash — treat that as indicative only.
How do I upgrade from free to paid?
Link an active billing account to reach Tier 1. Tier 2 needs $100 spent + 3 days from first payment; Tier 3 needs $1,000 + 30 days. Tiers advance automatically with usage.
Does Gemini have an OpenAI-compatible endpoint?
Yes — set base_url to https://generativelanguage.googleapis.com/v1beta/openai/ and pass your Gemini key as api_key with the OpenAI Python/JS libraries or REST.
Which Gemini model should I use?
Start with gemini-2.5-flash or gemini-3.5-flash (GA, the most intelligent, backing gemini-flash-latest). Use gemini-3.1-pro-preview or gemini-2.5-pro for deeper reasoning.
Can one key work for Gemini and other models?
Not a native Gemini key — it only calls Google models. A gateway like DataLLM Lab uses one OpenAI-compatible key at https://www.datallmlab.com/v1 for Gemini chat models plus other families.
DataLLM Lab