StartupAI.
Back to Blog
How-To Guides

How to Get a Free Gemini API Key in 2026 (Step by Step)

By Faizan Arif October 9, 2026 5 min read
How to Get a Free Gemini API Key in 2026 (Step by Step)
How to Get a Free Gemini API Key in 2026 (Step by Step)
How to Get a Free Gemini API Key in 2026 (Step by Step)

A free Gemini API key from Google AI Studio remains one of the best free entry points into serious AI development. No credit card, a genuinely usable daily quota, and an OpenAI-compatible endpoint that works with your existing code. The whole setup takes about three minutes if you follow these steps.

Step 1: sign in to Google AI Studio

Open Google AI Studio in your browser and sign in with a regular Google account — no Google Cloud billing account needed for the free tier. AI Studio is Google's developer console for the Gemini API: it holds your keys, shows usage, and lists the current rate limits for every model. If you have never used it before, the dashboard will look empty; that changes in the next step.

Step 2: create the API key

Click "Get API key" in the top bar (or go straight to the API keys page). Choose "Create API key in new project" — Google automatically spins up a Google Cloud project behind the scenes and attaches the key to it. If you already manage Cloud projects, you can pick an existing one instead.

The key appears in a dialog. Copy it immediately and paste it into a secret manager or an environment variable. Treat it like a password: anyone holding it can spend your quota. If you ever leak one, come back to the API keys page, delete it, and generate a fresh one — old keys stop working the moment you revoke them.

Step 3: restrict the key before you use it

This step matters more than it used to. Unrestricted API keys are blocked on Google's side, so a key with no restrictions may simply fail. Open the key's settings in the Google Cloud console and add two restrictions: API restrictions (limit the key to the Generative Language API only) and application restrictions (HTTP referrers for a web app, or IP addresses for a server). A key locked to one API and one origin is useless to anyone who steals it, and it costs nothing extra.

Step 4: test the key in under a minute

The fastest smoke test is a single curl request:

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{"contents":[{"parts":[{"text":"Say hello in five words or fewer."}]}]}'

A JSON response with generated text means your key, project and restrictions are all correct. For real code, install the official SDK and keep the key out of your source files:

import os
from google import genai

client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="Explain why the sky is blue in one sentence.",
)
print(response.text)

Prefer your existing OpenAI-style code? Gemini exposes an OpenAI-compatible endpoint at https://generativelanguage.googleapis.com/v1beta/openai/. Point any OpenAI SDK client at that base URL, use your Gemini key, and set the model to gemini-2.5-flash — your chat.completions code works unchanged.

What the free tier actually gives you

Gemini's free tier is tri-metered: every request counts against requests per minute (RPM), tokens per minute (TPM) and requests per day (RPD). Hit any one of the three and you get a 429 error. For Flash-class models the recently reported allowances are 15 requests per minute, one million tokens per minute, and 1,500 requests per day — and the limits apply at the Google Cloud project level, so all keys in one project share the same bucket. Lighter Flash-Lite models carry higher per-minute allowances.

Two caveats worth knowing before you build. First, Google changes these numbers regularly and no longer publishes fixed static figures, so always check the rate-limits page inside AI Studio rather than trusting a blog post — this one included. Second, the beefier Pro-class models are no longer available on the free tier at all, so plan on Flash for free workloads and budget for paid calls if you need Pro reasoning.

The one privacy trade-off to know

On the free tier, Google's terms allow your prompts and responses to be reviewed by humans and used to improve its products. For side projects and learning this is usually acceptable; for anything with customer data, trade secrets or personal information, it is not. Attaching billing removes the training use, but it also converts your usage to pay-as-you-go. Never send sensitive data through a free-tier key.

What to do when you hit a 429

Hitting the limit is normal, not a ban. The fixes, in order: add exponential backoff and retry (the Python SDK examples all show this); switch heavy polling to a Flash-Lite model with higher per-minute headroom; spread workloads across separate Cloud projects, since each project gets its own quota bucket; and watch the usage dashboard in AI Studio to see which of the three meters you are actually hitting. Most people hit the daily request count, not the per-minute ones.

When the free tier is not enough

If your app outgrows free quotas, enable billing on the same Cloud project and usage converts to pay-as-you-go at published per-token prices. Nothing in your code changes — the same key, the same endpoint, higher limits. This is also the point where the training-use policy stops applying, which is the real reason many teams upgrade long before they need the extra quota.

Key takeaways

StartupAI Tools

Access 100+ Free Browser Web Utilities

From JSON formatters and URL shorteners to live currency markets, enjoy fast developer tools with zero registration.

Explore 100+ Tools →Or browse all 100+ free tools →