The key point
Go to aistudio.google.com, sign in with a Google account and accept the Terms of Service. New users automatically get a free Gemini API key, and you just copy it. Per the official quickstart, your first API call takes under a minute. The free tier can use Gemini 4 Hydrogen. The trade-off is that Google uses free-tier content to improve its products.
If you are new to AI Studio itself, start with the Google AI Studio complete guide. This article is only about the API key.
Is it free?
Yes. Google’s pricing page is clear: on the free tier, input and output tokens (the unit AI uses to measure text) cost nothing, and AI Studio itself is free in all supported regions. If your country is on the official supported list, you can sign up directly.
The free tier has two limits:
- Lower rate limits: There are caps on requests per minute (RPM), input tokens per minute (TPM), and requests per day (RPD). Going over any one of them returns an error. The daily quota resets at midnight Pacific time.
- Only some models: Gemini 4 Hydrogen, Gemini 3.8 Flash and a few others have a free tier. Gemini 4 Argon, Gemini 4 Carbon and the Nano Banana image models are paid only.
You must also be 18 or older to use the API.
How do I get a Gemini API key?
- Open aistudio.google.com and sign in with your Google account.
- On first use you will see the Terms of Service. Accept them, and AI Studio automatically creates a Google Cloud project and an API key for you.
- Go to the API Keys page and copy that key.
- Want another key? Click Create API key and follow the dialog to pick a project.
- Save the key as an environment variable (commands in the next section). Don’t paste it into your code.
If you already have a Google Cloud account, AI Studio does not create a project for you. Open Dashboard from the left panel, choose Projects, click Import projects, select your project and press Import, then create a key on the API Keys page.
Projects imported from Google Cloud, or extra projects you create, sometimes need phone verification before you can use the free tier. You scan a QR code with your phone. No phone number and no app install are needed.
How do I test the key?
First, save the key as an environment variable. On macOS or Linux:
export GEMINI_API_KEY="YOUR_API_KEY"
On Windows PowerShell:
$env:GEMINI_API_KEY="YOUR_API_KEY"
The official SDKs (software development kits) read GEMINI_API_KEY or GOOGLE_API_KEY on their own. If both are set, GOOGLE_API_KEY wins.
Then try the curl command from the official quickstart:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-H "Api-Revision: 2026-05-20" \
-d '{
"model": "gemini-4-hydrogen",
"input": "Explain how AI works in a few words"
}'
If you get a JSON answer back, the key works. If you prefer Python, run pip install -U google-genai and create a client with genai.Client(). It picks up the key from the environment variable on its own.
What is the difference between free and paid?
| Free tier | Paid tier | |
|---|---|---|
| Cost | Input and output tokens are free | Billed per token; Hydrogen is $1.50 per million input tokens and $7.50 per million output tokens |
| Rate limits | Lower | Higher; Batch API is 50% off |
| Models | Some models | Includes flagships such as Argon and Carbon |
| Your data | Google uses it to improve its products | Not used to improve products |
How your data is used is the biggest difference. On the free tier, Google uses what you send and what comes back to improve its products, and human reviewers may read it. The Terms of Service say plainly: do not submit sensitive, confidential or personal information on the free tier.
To upgrade, click Set up billing on the API Keys page, link a billing account and prepay at least $5 in credits. Once a project has billing enabled, API calls count as a paid service, and your data is not used to improve products.
How do I keep my key safe, and what if it leaks?
The official advice is to treat your API key like a password. Four rules:
- Never push the key to version control such as Git.
- Never hardcode the key in a website or mobile app. Users can pull front-end code apart, so call the API through your own backend.
- Read the key from an environment variable. For production services, use Google Cloud Secret Manager.
- Set billing alerts in the Google Cloud console so you get notified if usage suddenly spikes.
Since May 28, 2026, every new key created in AI Studio is an auth key. By default it can only call the Gemini API, and Google can quickly block it if a leak is detected.
If you suspect a leak, do this in order:
- Create a new key on the API Keys page in AI Studio.
- Switch your app to the new key and deploy.
- Once the new key works, disable or delete the leaked key in the Google Cloud console.
- Check your billing records and API usage for misuse.
The order matters. If you delete the old key before the new one is live, your service goes down.
How do I fix common errors?
- 429 RESOURCE_EXHAUSTED: The official docs say the API returns this when you hit a spend-based rate limit. Rate limits apply to the whole project, so creating more keys does not add quota. The official advice is to retry with exponential backoff, meaning you wait a short time at first and longer after each failure. The Python SDK retries automatically up to 4 times by default. If your usage is simply high, upgrade to the paid tier.
- 403 FREE_TIER_VERIFICATION_REQUIRED: The free-tier project has not been phone-verified yet. Open the verification link in the error message, click Verify device, scan the QR code with your phone camera, and retry after you see Project verified. A new key in the same project won’t fix it, because verification belongs to the project. If you would rather skip verification, you can set up billing and use the paid tier.
- Other 403 PERMISSION_DENIED: The error message is Your project has been denied access, and the project status may show Restricted, Free tier unavailable, Payment needed or Unavailable. Free tier unavailable means the project can’t use the free tier. Link a billing account and move to the paid tier. A new key won’t help.
- Create API key button is disabled, showing You do not have permission to create a key in this project: You lack permission to create keys in that project. Ask the project admin to grant it, or create a new project that does not belong to any organization.
- Old key shows an Unrestricted tag: The Gemini API rejects old-style keys (standard keys) that have no restrictions. On the API Keys page, hover over the Unrestricted tag, click Add restrictions, choose Restrict to Gemini API only, then press Restrict key.
- Old key shows a Blocked tag: Unrestricted old keys that sit unused for a long time get blocked. Switch to a key that has restrictions, or click Create API key on the API Keys page to make a new one.
- Can’t open AI Studio: Check your region first. Taiwan is on the supported list. Hong Kong and mainland China are not.
Penchan’s Take
Getting a Gemini API key is easier than most people expect: a new user signs in to AI Studio, accepts the terms, and the key is already waiting on the API Keys page. The free tier lets you try Hydrogen right away. Just remember two things: keep your key in an environment variable, never on Git or in front-end code, and don’t send sensitive, confidential or personal data through the free tier, because Google uses that content to improve its products. For more on Gemini, head back to the Gemini overview.
This article provides consumer information about AI model API pricing. It is not securities or investment advice. The information here is current as of November 14, 2026.