How to get a Gemini API key

Gemini API keys are made in Google AI Studio: open aistudio.google.com/apikey, click Create API key, and copy it. For new users, AI Studio creates the Google Cloud project the key belongs to, and the key works on the free tier at once.

· Zurelay guides · Prices update live

Get a key from Google, step by step

  1. Open Google AI Studio at aistudio.google.com/apikey and sign in with a Google account.
  2. Click Create API key. Every key belongs to a Google Cloud project. New users get a default project made for them; if you already use Google Cloud, pick or create a project.
  3. Copy the key and keep it somewhere safe. Since May 28, 2026, new keys are auth keys: tied to a service account and restricted to the Gemini API from the start.
  4. Set it as an environment variable. Google's SDKs read GEMINI_API_KEY or GOOGLE_API_KEY; if both are set, GOOGLE_API_KEY wins.

Have an older key? The Gemini API rejects unrestricted standard keys. In AI Studio, hover the key's Unrestricted label, choose Add restrictions and restrict it to the Gemini API.

Test the key

Gemini answers OpenAI-style requests too, which makes for a short test. Native requests send the key in an x-goog-api-key header instead.

terminal
export GEMINI_API_KEY="your-key"
curl https://generativelanguage.googleapis.com/v1beta/openai/chat/completions \
-H "Authorization: Bearer $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gemini-3.8-flash",
"messages": [{"role": "user", "content": "Say hello"}]}'

The free tier, and what it costs you

A new key runs on the free tier with no card. It covers the Flash and Flash-Lite models, Gemini 2.5 Pro, the text-to-speech and Live models and embeddings, with lower rate limits than the paid tiers. Gemini 4 Argon, Gemini 3.1 Pro and the image models need billing.

The trade: on the free tier Google uses what you send and what comes back to improve its products, and human reviewers may read it. On the paid tier it doesn't. Keep personal and confidential data off a free key.

Turn on billing

In AI Studio, choose Set up billing on the project, link a Cloud billing account and prepay at least $5. Spend caps rise with what you've paid:

TierTo qualifySpend cap
FreeAn active projectFree models only
Tier 1A linked billing account$250
Tier 2$100 paid, 3 days after the first payment$2,000
Tier 3$1,000 paid, 30 days after$20,000 and up

Then each request is billed per token. List prices per 1M tokens:

ModelInputOutputOn Zurelay (in / out)
Gemini 4 Argon$2.00$10.00$0.80 / $4.00
Gemini 3.1 Pro$2.00$12.00$0.80 / $4.80
Gemini 3.8 Flash$0.75$3.75$0.32 / $1.59
Gemini 3.5 Flash-Lite$0.30$2.50$0.12 / $1.04

Does Google AI Pro or Ultra include the API?

No. A Google AI plan's benefits apply inside the AI Studio website only; calling the Gemini API with a key is billed separately, through Google Cloud.

Keep the key safe

  • Keep it on the server. A key in a web page or app can be copied and spent on your billing account.
  • Restrict every key to the Gemini API, and use a separate project per app.
  • Set a budget alert in Google Cloud billing, since paid usage is billed to your account.

Another way: Gemini on the same key as Claude and GPT

On Zurelay, Gemini is one more model name on an OpenAI-compatible key, billed from prepaid credit with no Cloud billing account (58% below Google's list on Gemini 3.8 Flash):

gemini.py
from openai import OpenAI
client = OpenAI(base_url="https://api.zurelay.com/v1", api_key="YOUR_ZURELAY_KEY")
reply = client.chat.completions.create(
model="gemini-3.8-flash",
messages=[{"role": "user", "content": "Say hello"}],
)
print(reply.choices[0].message.content)

There's no free tier on Zurelay; credit starts at $10. If the free tier covers what you need, Google's own key is the cheaper start. See Gemini API pricing for every model.

Steps, free tier and billing read from Google's API key, pricing, rate limits, terms and Google AI plans pages on October 28, 2026.

Every model on one OpenAI-compatible key, below list price. Credit from $10, no subscription.Get your API key

FAQ

Questions people ask

Anything else? Ask our team and we’ll answer by email.

Is the Gemini API key free?

Yes. Creating a key in Google AI Studio is free, and the key works on the free tier without a card, with low rate limits and only some models. On the free tier Google may use your prompts and responses to improve its products; paid usage isn't used that way.

Where do I find my Gemini API key?

In Google AI Studio at aistudio.google.com/apikey, which lists your keys with the Google Cloud project each belongs to.

Why is my old Gemini API key rejected?

The Gemini API rejects unrestricted standard keys, and since May 7, 2026 long-dormant unrestricted keys are blocked. In AI Studio, add a restriction to the Gemini API, or create a new key: new keys are restricted auth keys.

Does Google AI Pro include Gemini API access?

No. Google AI plan benefits apply inside the AI Studio website only. Calling the Gemini API with a key is billed separately through a Google Cloud billing account.

Which environment variable does the Gemini SDK read?

GEMINI_API_KEY or GOOGLE_API_KEY. If both are set, GOOGLE_API_KEY takes precedence. REST requests send the key in the x-goog-api-key header.

More guides

Stop paying list price.
Start saving today.

Create a key in seconds, point the SDK you already use at Zurelay, and every request costs up to 90% less from the first token.