API keys · Guide
How to get a free Gemini API key
A free Gemini API key takes a few minutes in Google AI Studio and needs no credit card. Here’s how to get one, what the free tier includes, and how to keep the key safe.
- Cost
- Free tier
- Card needed
- No
- Free models
- 6
- Time
- About 5 minutes
Steps
Get your key
- Open Google AI Studio’s API keys page and sign in with your Google account.
- If it’s your first visit, accept the terms of service. Google says AI Studio then creates a default Google Cloud project and an API key for you automatically.
- If you already use Google Cloud, import a project from the Projects view, then create a key for it on the API keys page.
- Copy the key. New keys start with
AQ.; treat it like a password. - Paste it into the box on this page to check it works.
Source: Google’s Using Gemini API keys documentation.
Test your key
Your key goes from your browser straight to Google, never to this site, and is forgotten when you close the tab unless you choose to remember it.
Free tier
What the free tier includes
On 2026-10-08, Google’s pricing page listed these models as free of charge on the free tier: Gemini 3.8 Flash, Gemini 3.7 Flash, Gemini 3.6 Flash, Gemini 3.5 Flash, Gemini 3.5 Flash-Lite, Gemini 3.1 Flash-Lite.
- No billing account. The free tier only needs an active project; billing is required from Tier 1 up.
- Limits per project. Rate limits are shared by every key in a project and shown in AI Studio. Daily limits reset at midnight Pacific time.
- Your data. On the free tier, Google says content is used to improve its products. On paid tiers it isn’t. Keep confidential data off free-tier keys.
- Busy periods. Popular models sometimes return a temporary “high demand” error. Retry after a moment or switch to another model.
Use it
Call the API with your key
Save the key as an environment variable called GEMINI_API_KEY; Google’s client libraries read it (or GOOGLE_API_KEY, which wins if both are set). Then send a request with the key in the x-goog-api-key header:
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents": [{"parts": [{"text": "Explain how AI works in one sentence."}]}]}'Or skip the code and chat in the Gemini playground.
Security
Keep your key safe
- Never commit a key to Git or paste it into code you share.
- Don’t ship a key inside a website or mobile app you publish; Google recommends calling the API from your own backend instead.
- Add API key restrictions in Google Cloud to limit the damage if it leaks.
- If a key leaks, delete it in AI Studio and create a new one.
FAQ
Frequently asked questions
Is the Gemini API key free?
Yes. Creating a key costs nothing, and Google’s free tier lets you use Gemini 3.8 Flash, Gemini 3.7 Flash, Gemini 3.6 Flash, Gemini 3.5 Flash, Gemini 3.5 Flash-Lite, Gemini 3.1 Flash-Lite free of charge, within rate limits (checked 2026-10-08). You only pay if you link a billing account to move to a paid tier.
Do I need a credit card?
No. Google’s free tier needs only an active project, which AI Studio creates for you. A billing account is needed for Tier 1 and above, which have higher limits and keep your content out of product improvement.
What are the free tier limits?
Google doesn’t publish one fixed table any more: limits depend on your project and tier and are shown in AI Studio’s rate-limit page. They apply per project, not per key, so extra keys in the same project don’t add quota. Requests-per-day limits reset at midnight Pacific time.
Does Google use my data on the free tier?
Google’s pricing page says content sent on the free tier is used to improve its products, and content on the paid tier isn’t. Don’t send personal or confidential data with a free-tier key.
Why does my key start with “AQ.” instead of “AIza”?
Since 28 May 2026, AI Studio creates new keys as “auth keys”, which start with AQ.. Older keys start with AIza; Google’s documentation says the API now rejects unrestricted older keys, while restricted ones keep working. Both formats are used the same way, in the x-goog-api-key header.
Can I get a Gemini API key in Pakistan or India?
Yes. Pakistan and India are both on Google’s list of countries where the Gemini API and AI Studio are available, as are the UK and the EU. Check the available regions page if you’re elsewhere.
What should I do if my key leaks?
Delete it in AI Studio’s API keys page straight away and create a new one. Anyone with your key can use your quota, and on a paid tier, your money. Keep keys in environment variables or a secrets manager, never in code you commit or publish.