GrabAICredits (GrabAICredits)Submit a deal

How to Get a Gemini API Key in 2026 (Free Tier, Paid Tiers & Rate Limits)

Verified ·11 min read

To get a Gemini API key, sign in to Google AI Studio with a Google account, open the API Keys page and click Create API key. New users get a default project and key automatically after accepting the terms. Projects start on the Free tier, which needs no payment method and covers many Flash, Flash-Lite and Gemma models within rate limits. Gemini 2.5 Pro is also free, while Gemini 4 Argon, 3.1 Pro Preview and the image and video models need a paid tier, and Google says free-tier content is used to improve its products.

Checked against Google's Gemini API documentation on October 17, 2026. Google changes model names, free-tier coverage and key rules often; the dates below are the ones Google publishes.

Before you start: who can get a key

  • A Google account. A personal Gmail account works. Work or school accounts can be limited by the organization's Google Cloud policies (see the permissions fix in troubleshooting).
  • Age 18 or older. Google's regions page lists not meeting the 18+ minimum, or not having verified your age on your Google account, as reasons AI Studio won't open.
  • A supported country or territory. Google publishes the list on its available regions page. The free and paid tiers are both offered in the EEA (including the EU), the UK and Switzerland. If you're outside the list, Google points to the Gemini API in Gemini Enterprise Agent Platform instead. For Colab users, the check applies to where the Colab instance runs, not where you are.
  • No card for the Free tier. You only add a payment method when you upgrade a project to a paid tier.

Step 1: Create the key in Google AI Studio

  1. Go to aistudio.google.com and sign in with your Google account.
  2. Accept the Terms of Service. If you're new, AI Studio automatically creates a default Google Cloud project and an API key for you.
  3. Open the API Keys page from the dashboard.
  4. Click Create API key if you need another key. Every key belongs to a Google Cloud project.
  5. Copy the key and store it somewhere safe, such as a password manager or secret store.

Already use Google Cloud? AI Studio doesn't create a default project for you and doesn't show all your Cloud projects. Import one first: open the Dashboard, select Projects, click Import projects, choose the project and click Import. Then create the key from the API Keys page. AI Studio lets you create up to 10 projects at a time, and its pages show at most 100 keys and 50 projects.

Auth keys and standard keys

Google is moving the Gemini API from standard API keys to authorization (auth) keys. An auth key is bound to a Google Cloud service account, is restricted to the Gemini API by default, and gets faster enforcement if Google detects that it leaked. The key dates Google publishes:

DateChange
May 7, 2026Unrestricted API keys that have been dormant for an extended period are blocked and show a Blocked tag in AI Studio
May 28, 2026All new keys created in AI Studio are auth keys by default
NowThe Gemini API rejects requests from unrestricted standard keys. Standard keys with explicit restrictions keep working

If you have an older key marked Unrestricted on the API Keys page, either hover over the label, click Add restrictions, choose Restrict to Gemini API only and confirm with Restrict key, or create a new auth key and switch your app to it. The Key Type column shows which of your keys are still Standard.

Step 2: Set GEMINI_API_KEY

The Google Gen AI SDKs read GEMINI_API_KEY or GOOGLE_API_KEY from your environment. If both are set, GOOGLE_API_KEY takes precedence. Google recommends environment variables over putting the key in code.

macOS (Zsh)

Add this line to the end of ~/.zshrc:

export GEMINI_API_KEY=<YOUR_API_KEY_HERE>

Then reload the file:

source ~/.zshrc

Linux or macOS (Bash)

Add the same export line to ~/.bashrc, then reload it:

source ~/.bashrc

Windows

  1. Search for "Environment Variables" in the Windows search bar.
  2. Click Environment Variables in the System Properties dialog.
  3. Under User variables or System variables, click New....
  4. Set the variable name to GEMINI_API_KEY and the value to your key.
  5. Click OK, then open a new terminal so it picks up the variable.

Step 3: Make a test request

Install the official SDK. Python:

pip install -U google-genai

JavaScript:

npm install @google/genai

With GEMINI_API_KEY set, the client finds the key on its own. A minimal Python test using Google's Interactions API:

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.8-flash",
    input="Explain how AI works in a few words"
)
print(interaction.output_text)

The same in JavaScript:

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: "gemini-3.8-flash",
  input: "Explain how AI works in a few words",
});
console.log(interaction.output_text);

Or call the REST API directly with curl. This is Google's example from the API key page; replace YOUR_API_KEY with your key:

curl "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H 'Content-Type: application/json' \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -X POST \
  -d '{
    "model": "gemini-3.8-flash",
    "input": "Explain how AI works in a few words"
  }'

A successful call returns an interaction with "status": "completed", token usage, and the model's text. If you get an error instead, see the troubleshooting section below. Model names change often, so check Google's models page for the current IDs before you hardcode one.

Is the Gemini API free?

Yes, for many models, within rate limits. Google's pricing page lists these models as Free of charge on the Free tier (standard input and output):

  • Gemini 3.8 Flash, 3.6 Flash and 3 Flash Preview
  • Gemini 3.5 Flash-Lite and 3.1 Flash-Lite
  • Gemini 2.5 Pro, 2.5 Flash and 2.5 Flash-Lite
  • Live, TTS and Transcribe models such as Gemini 3.8 Live, 3.8 Flash TTS and 3.5 Transcribe
  • Gemini Embedding 2, Gemini Robotics ER 2 Preview and Gemma 4

These have no free tier: Gemini 4 Argon, Gemini 3.1 Pro Preview, Gemini Omni Flash, the image models (Nano Banana 2.1, Nano Banana 2, Nano Banana Pro and 2.5 Flash Image), Veo and Lyria. Grounding with Google Search and Google Maps on Gemini 3 and newer models is also paid-tier only. For per-token rates, see Gemini API pricing, and for a summary of the free tier see our Gemini API free tier page.

On the Free tier, Google's pricing page marks content as "Used to improve our products". Standard paid-tier usage isn't used that way. Don't send confidential, customer or personal data from a free-tier project.

Free tierPaid tiers
Payment methodNot neededLinked Cloud Billing account; new users prepay at least $5
ModelsSelected Flash, Flash-Lite, 2.5 Pro, Gemma and othersAll models, including Pro previews, image and video
Batch APIFree on only a few models, such as 3.5 Flash-LiteYes, at about 50% of the standard price
Content used to improve Google productsYesNo (except the Contributor tier, which Google marks as used)
Rate limitsLowestRise with tier

Gemini API rate limits

Google measures limits in requests per minute (RPM), input tokens per minute (TPM) and requests per day (RPD). Going over any one of them causes an error, even if you're under the others. Some models have extra limits, such as images per minute for image models or tokens per day. Limits apply per project, not per API key, so extra keys in the same project don't add quota. RPD resets at midnight Pacific time. Experimental and preview models have tighter limits.

Google doesn't publish a fixed table of free-tier numbers. Limits vary by model and tier, and you see your active limits in AI Studio at aistudio.google.com/rate-limit. Google also says listed limits aren't guaranteed.

TierHow to qualifyBilling tier cap (monthly)Spend rate limit (per 10 minutes)
FreeActive project or free trialN/AN/A
Tier 1Set up and link an active billing account$250$10
Tier 2Paid $100 + 3 days since first successful payment$2,000$50
Tier 3Paid $1,000 + 30 days since first successful payment$20,000 - $100,000+$200

Tier 2 and Tier 3 are based on cumulative Google Cloud spend (not only Gemini) on the linked billing account, and upgrades happen automatically. Free to Tier 1 usually takes effect instantly; later upgrades within about 10 minutes. Whether spend-based limits apply depends on your billing history; hitting one returns 429 RESOURCE_EXHAUSTED. If you keep hitting limits in normal use on a paid tier, Google has a form to request a rate limit increase, with no guarantee.

Getting more out of the free limits

  • Pick the right model for each task. Limits differ by model and preview models are tighter, so compare your numbers on the rate-limit page and keep Pro-class models for prompts that need them.
  • Turn thinking down. Google notes that Gemini 3.x models think by default, which adds latency and tokens. Lowering the thinking level cuts token use for simple prompts.
  • Retry with backoff. Google's SDKs retry 429 and 5xx errors automatically (the Python SDK up to four times). In your own REST code, wait 1s, 2s, 4s and so on, with a little random jitter.
  • Separate projects for separate apps. Limits are per project, so a test script can't starve your demo app if they live in different projects. Don't do this to get around limits on one app; that's against the spirit of the terms and tiers are tracked at the billing account level anyway.

Upgrading to a paid tier

  1. In AI Studio, go to the API keys or Projects page.
  2. Find the Free tier project you want to upgrade and click Set up billing in the Billing Tier column.
  3. If you've never had a Google billing account, choose your country to accept the terms, then confirm your contact details and payment method. If you have one, pick an existing billing account or click Add new billing account.
  4. Prepay at least $5 (or the local equivalent) if asked. Some accounts are offered Postpay instead.

New users default to the Prepay plan, which started taking effect March 23, 2026. You buy credits on the AI Studio Billing page (minimum $5, maximum $5,000), usage is deducted in near real time, and unused credits expire after 12 months and aren't refundable. When the balance reaches $0, every key in every project on that billing account stops working and requests fail with HTTP 402 until you add credits. Auto-reload and a monthly auto-charge limit help avoid surprises, and you can set per-project spend caps on the Spend page.

To go back to the Free tier, disable billing on the project (or unlink it from its billing account).

Worked cost example

Using Google's standard paid price for Gemini 3.8 Flash through December 31, 2026 ($0.75 per 1M input tokens and $3.75 per 1M output tokens, with thinking tokens billed as output): 1,000 requests with 2,000 input tokens and 500 output tokens each use 2M input and 0.5M output tokens. That's 2 × $0.75 = $1.50 plus 0.5 × $3.75 = $1.875, about $3.38 in total. Google lists these rates doubling from January 1, 2027, which would make the same workload about $6.75. The same requests on the Free tier cost nothing, as long as they fit your rate limits.

The $300 Google Cloud free trial can't pay for Gemini API usage. Google says that starting March 2026 Gemini API costs are excluded from the program, and Welcome credits on billing accounts opened after March 2, 2026 can't be used for the Gemini API or AI Studio. Accounts that got the credit earlier can spend what's left on the Gemini API until it expires. Startups can apply for credits through the Google for Startups Cloud Program.

Keep your Gemini API key safe

  • Treat the key like a password and never check it into Git.
  • Don't hardcode keys in web or mobile apps; anyone can extract them. Call Gemini from a backend proxy instead.
  • Read the key from an environment variable, and keep production keys in a secret store such as Google Cloud Secret Manager.
  • Restrict keys: in the Google Cloud console credentials page, add application restrictions such as allowed IP addresses.
  • Set up billing alerts in the Google Cloud console and a project spend cap in AI Studio so a leaked key can't run up a large bill.

If your key leaks

  1. Create a replacement key in AI Studio or the Cloud console.
  2. Deploy your app with the new key.
  3. Disable the leaked key once the new one works, then delete it.
  4. Check billing and API usage in the Google Cloud console for activity you don't recognize. For unexpected charges, Google asks you to open a billing support case.

Troubleshooting

ProblemLikely cause and fix
AI Studio says it isn't availableYour country isn't on Google's supported list, you're under 18, or your Google account's age isn't verified
Create API key is greyed out: "You do not have permission to create a key in this project"You lack IAM permissions on the Cloud project. Ask an admin for a role such as Project Editor, or create a new project that isn't tied to an organization
401 authenticationThe key is missing, mistyped or expired. Check the variable is set in the terminal you're using (open a new one after editing your shell file)
"Your API key was reported as leaked"Google blocked the key. Create a new one and keep it out of public code
Key shows Blocked or Unrestricted in AI StudioDormant unrestricted keys are blocked and unrestricted standard keys are rejected. Restrict it to the Gemini API or create a new auth key
403 permission_deniedThe key doesn't have access to this resource, often because it's restricted to other APIs. Use a key restricted to the Gemini API
404 model_not_foundThe model name is wrong or retired. Check Google's models page for current IDs
429 rate_limit_exceeded or quota_exceededYou hit RPM/TPM or the daily quota. Back off and retry, wait for the midnight Pacific reset, use a lighter model, or upgrade the project
402 payment_requiredYour Prepay balance is $0. Add credits or turn on auto-reload; retrying won't help
400 failed_preconditionA prerequisite isn't met, for example billing is disabled on the project
503 service_unavailableTemporary overload. Retry with exponential backoff

Failed requests with a 400 or 500 error aren't charged, but Google says they still count against your quota.

What to use the free tier for, and alternatives

The Free tier is enough for learning, prototypes, hackathons, personal scripts and low-traffic internal tools. Move to a paid tier when you need production rate limits, a Pro or image model, or when your data shouldn't be used to improve Google's products. If you want a Gemini subscription for the chat app rather than API access, that's a separate product; see Google AI plans pricing, and students should check the free Google AI Pro offer for students.

Other providers also offer free API access, each with different limits and data policies. Compare them in our free AI API keys guide, or look at the Groq API free tier, Mistral API free tier and OpenRouter free models. If you need Claude instead, see how to get an Anthropic API key. For the bigger picture of every credit program we track, start with how to get free AI credits.

Frequently asked questions

›Is a Gemini API key free?

Yes. Creating a key in Google AI Studio is free, and new projects start on the Free tier with no payment method. Free-tier models are rate-limited, and some models such as Gemini 4 Argon, Gemini 3.1 Pro Preview and the image and video models need a paid tier.

›What are the Gemini API free tier rate limits?

Limits are set per project and per model across RPM, TPM and RPD. Google shows your exact numbers in AI Studio at aistudio.google.com/rate-limit instead of publishing a fixed table. Daily limits reset at midnight Pacific time.

›Does creating more API keys increase my Gemini quota?

No. Rate limits apply per project, not per key. To raise them, move the project to a paid tier.

›Can I use the $300 Google Cloud trial for the Gemini API?

No. Google says Gemini API usage is excluded from the $300 Google Cloud Free Trial starting March 2026. Only accounts that received the Welcome credit before the change can spend what's left on the Gemini API until it expires.

›Does Google train on my Gemini API data?

On the Free tier, Google's pricing page says content is used to improve its products. On standard paid tiers, prompts and responses aren't used to improve Google products.

›Which environment variable does the Gemini SDK use?

GEMINI_API_KEY or GOOGLE_API_KEY. If both are set, GOOGLE_API_KEY takes precedence.

›Why does my old Gemini API key stop working?

Google now rejects unrestricted standard keys, and since May 7, 2026 it blocks unrestricted keys that have been dormant for a long time. It also blocks keys it detects as leaked. Restrict the key to the Gemini API in AI Studio or create a new key.

›How much do I need to pay to leave the Free tier?

Linking a billing account moves the project to Tier 1. New users on the Prepay plan buy at least $5 of credits, which expire after 12 months.

›Can I use the Gemini API in the EU or UK?

Yes. Google says the free and paid tiers are available in the EEA (including the EU), the UK and Switzerland. Check Google's available regions page for other countries.

Sources

Checked against these pages on Oct 17, 2026. Providers change offers often: always confirm on the official page before you rely on it.

  1. Official: Using Gemini API keys (ai.google.dev)(ai.google.dev)
  2. Official: Gemini API quickstart(ai.google.dev)
  3. Official: Gemini API rate limits(ai.google.dev)
  4. Official: Gemini API pricing(ai.google.dev)
  5. Official: Gemini API billing(ai.google.dev)
  6. Official: Available regions for Google AI Studio and Gemini API(ai.google.dev)
  7. Official: Gemini API troubleshooting guide(ai.google.dev)
  8. Official: Gemini API errors reference(ai.google.dev)
  9. Official: Gemini models(ai.google.dev)