Engineering Guide

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.

How to get a Gemini API key in Google AI Studio — free tier and paid steps

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:

  1. Go to aistudio.google.com/apikey (also reachable as aistudio.google.com/api-keys) and sign in with your Google account.
  2. Click Create API key.
  3. 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:

# 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)
How this is sourced. The create-key steps and URLs are from Google's official API key documentation (verified July 2026). Live AI Studio console pages require sign-in, so the exact button labels may shift slightly; the documented flow is stable.

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.

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:

TierHow you qualifyRate limits
FreeActive project or free trialLowest
Tier 1Set up and link an active billing accountHigher
Tier 2$100 total spend + 3 days from first successful paymentHigher still
Tier 3$1,000 total spend + 30 days from first successful paymentHighest

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:

TierBest forRequires billing?Move up when
FreePrototyping, learning, low-volume side projectsNoYou hit RPD/RPM caps in testing
Tier 1Production apps with modest, steady trafficYes (linked account)Sustained load nears your limits
Tier 2Scaling apps with real usageYes ($100+ spent)You need more headroom for spikes
Tier 3High-volume / heavy agentic workloadsYes ($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 idWhat it isStatus
gemini-3.5-flashGoogle's most intelligent model; backs the gemini-flash-latest aliasGA (May 19 2026)
gemini-3.1-pro-previewLatest Gemini Pro (Gemini 3 series)Preview (Feb 19 2026)
gemini-2.5-proAdvanced 2.5-gen model for complex reasoning & codingStable
gemini-2.5-flashBest price-performance for low-latency, high-volume tasksStable
gemini-2.5-flash-liteLightest 2.5-gen modelStable

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.

Need a key? Prototyping Production Multi-provider Free tier — Create API key, no billing Link billing → Tier 1, then 2 / 3 One gateway key across many models
Choosing your Gemini key path by workload. Source: Google AI Studio API-key & rate-limits docs, July 2026.

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.

Written by
Kevin Fan

Founder of DataLLM Lab, the unified LLM gateway. Kevin tests models the boring way — same prompts, real costs, unedited outputs — and writes up what the runs actually show.

One API for every model

One API, every model.

Get a single API key for Claude Opus 4.7, GPT-5.4, and 300+ more — with automatic price comparison and routing to the best model for every request.