How to Get a Gemini API Key in 2026: Google AI Studio, Free Tier, Billing and First Call

Updated · By topai.one editorial team

Quick answer: Sign in to Google AI Studio, open the API Keys page and copy the key Google created for you (or click Create API key). Store it as GEMINI_API_KEY and send one test request. New projects start on the Free Tier; link a billing account only when you need higher limits or paid-only models. Current rates are on Google’s Gemini API pricing page (accessed October 25, 2026).

What do you need before you start?

Just a Google account. Every Gemini API key belongs to a Google Cloud project, which handles billing, collaborators and permissions. Google’s API key docs say that if you are new, AI Studio “automatically creates a default Google Cloud project and API key after you accept the Terms of Service.” If you already use Google Cloud, AI Studio does not create one; you import an existing project instead (Dashboard > Projects > Import projects).

How do you get a Gemini API key, step by step?

  1. Sign in to Google AI Studio and accept the Terms of Service.
  2. Open the API Keys page in the dashboard. New users will already see a default key.
  3. Click Create API key if you need another one, and pick the project it belongs to.
  4. Copy the key and store it as an environment variable:
export GEMINI_API_KEY="your_key_here"
  1. Test it with one request:
curl "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -X POST \
  -d '{"model": "gemini-3.8-flash", "input": "Say hi"}'

This mirrors the example in Google’s key docs, which uses gemini-3.8-flash. The official SDKs read GEMINI_API_KEY or GOOGLE_API_KEY automatically; if both are set, GOOGLE_API_KEY wins.

What changed with Gemini API keys in 2026?

Google is moving the Gemini API from standard keys to authorization (auth) keys, which are bound to a Google Cloud service account:

  • New keys are auth keys. Since May 28, 2026, every new key created in AI Studio is an auth key, restricted to the Gemini API by default and covered by fast leaked-key enforcement.
  • Unrestricted standard keys are rejected. Standard keys that have explicit restrictions keep working. To fix an “Unrestricted” key, hover over the label on the API Keys page, click Add restrictions and choose Restrict to Gemini API only.
  • Dormant unrestricted keys are blocked. Since May 7, 2026, unrestricted keys that sat unused for a long time show a Blocked tag. Create a new key instead.

If an old tutorial’s key suddenly stops working, one of these three rules is the usual reason.

Is the Gemini API key free?

The key is free, and so is the Free Tier, within limits. Google’s pricing page describes it as limited access to certain models with free input and output tokens, and notes that Free Tier content is used to improve Google’s products. Some models, such as Gemini 4 Argon, are not available on the Free Tier at all.

Free Tier Paid Tier
How you get it Default for new projects Link a billing account and prepay credits
Models Limited access to certain models Google’s most advanced models
Rate limits Free tier limits Higher, rising with cumulative spend and account age
Extras AI Studio access Context caching, Batch API at a discount
Data use Used to improve Google’s products Not used to improve Google’s products
Prices Free ai.google.dev/gemini-api/docs/pricing

To upgrade, click Set up billing next to the project in AI Studio. Google’s billing docs say paid tiers (Tier 1 to Tier 3) are unlocked by linking a billing account and then by cumulative spend, and each tier has a billing cap.

What if you can’t create a key?

  • “You do not have permission to create a key in this project”: your Google Cloud project or organization admin must grant a role with key-creation permissions (Project Editor works), or you can create a new project that is not tied to an organization.
  • You don’t see your keys: AI Studio only lists keys that are unrestricted or restricted to the Gemini API, and only for imported projects. Import the project, or manage the key in the Google Cloud console.
  • 429 RESOURCE_EXHAUSTED: you hit a rate limit for your tier. See how to fix API errors.

How do you keep the key safe?

Treat it like a password. Google’s rules: never commit it to Git, never put it in browser or mobile code (use a backend proxy), read it from an environment variable or a secret store such as Secret Manager, and set billing alerts. If a key leaks, create a replacement, deploy it, then disable the old key in the Cloud console and audit usage.

Need keys for other providers too? See how to get a Claude API key and how to get an OpenAI API key.

FAQ

Is the Gemini API key free?

Creating a key is free, and new projects start on the Free Tier, which gives limited access to certain models up to free rate limits. Google says Free Tier content is used to improve its products. Higher limits, the most advanced models and data privacy for prompts need the Paid Tier.

Where do I create a Gemini API key?

In Google AI Studio, on the API Keys page. New users get a default Google Cloud project and API key automatically after accepting the Terms of Service.

Why is my old Gemini API key rejected?

Since 2026 the Gemini API rejects requests from unrestricted standard keys, and it blocks unrestricted keys that sat dormant for a long time. Restrict the key to the Gemini API in AI Studio, or create a new key, which is an auth key by default.

What is the difference between GEMINI_API_KEY and GOOGLE_API_KEY?

The Gemini client libraries read either variable automatically. If both are set, GOOGLE_API_KEY takes precedence, which can cause confusing errors when an old value is still set.

Who pays for my Gemini API usage?

The Google Cloud project behind your key. Google's billing docs say tiers, rate limits and billing caps are all set at the billing account level for that project.

Sources

  1. Google AI for Developers: Using Gemini API keys (accessed 2026-10-25)
  2. Google AI for Developers: Gemini API billing (accessed 2026-10-25)
  3. Google AI for Developers: Gemini Developer API pricing (accessed 2026-10-25)

Independent guide. Some links may be affiliate or partner links; they never change what we write. See our disclosure. Found an outdated price? Tell us.