How to Get a Gemini API Key in 2026: The Free Tier, Billing, and Startup Credits
A Gemini API key takes about a minute to create in Google AI Studio and costs nothing to start. Here is exactly how to get one, what the free tier lets you do, when you need to add billing, and how startups cover the paid side with Google Cloud credits.
How to get a Gemini API key, step by step
From Google's API key docs. The whole thing takes about a minute if you have never used Google Cloud before.
-
1
Go to Google AI Studio
Open aistudio.google.com/apikey and sign in with a Google account. You must be 18 or older, and Google may ask you to verify your age. -
2
Accept the terms
For new users, AI Studio automatically creates a default Google Cloud project and an API key once you accept the Terms of Service. There is nothing to configure. -
3
Copy your key
Your key appears on the API keys page. Copy it and store it somewhere safe, such as a password manager or your shell environment. Treat it like a password. -
4
Already use Google Cloud? Import a project first
If your account already has Cloud projects, AI Studio will not create a default one. Go to Dashboard, then Projects, then Import projects, pick the project, and create the key from the API keys page. -
5
Make your first call
Set the key as theGEMINI_API_KEYenvironment variable and run one of the examples below. If it returns text, you are done.
Using your key: first request in Python, JavaScript or curl
Google's SDKs read the key from the GEMINI_API_KEY or GOOGLE_API_KEY environment variable automatically. If both are set, GOOGLE_API_KEY wins. Set it once in your shell:
export GEMINI_API_KEY="YOUR_API_KEY"
Python
Install the SDK with pip install -U google-genai, then:
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)
JavaScript
Install with npm install @google/genai, then:
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);
curl
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"model": "gemini-3.8-flash", "input": "Explain how AI works in a few words"}'
These use Google's newer Interactions API, which is now the default in the quickstart. The older generate_content call still works if you are following an older tutorial.
What the free tier includes
"Free" means free input and output tokens, with rate limits instead of a bill. Model availability from Google's pricing page; paid rates are per million tokens.
| Model | Free tier | Paid input / MTok | Paid output / MTok | Good for |
|---|---|---|---|---|
| Gemini 3.8 Flash | Yes | $0.75 | $3.75 | The current default for most apps |
| Gemini 3.5 Flash-Lite | Yes | $0.30 | $2.50 | High-volume classification and extraction |
| Gemini 3.1 Flash-Lite | Yes | $0.25 | $1.50 | Cheapest current model |
| Gemini 3.1 Pro Preview | No | $2.00 | $12.00 | Hardest reasoning tasks |
| Nano Banana image models | No | Paid only | Paid only | Image generation and editing |
| Gemini Omni Flash | No | $1.50 | $9.00+ | Video generation |
A few things the free tier does not do:
- Limits are per project, not per key. Creating more keys in the same project does not raise your limits. Daily limits reset at midnight Pacific time.
- Google no longer publishes the exact free limits. You can see your project's current limits on the rate limit page inside AI Studio. Preview models get tighter limits.
- No Batch API, and no free Search grounding on 3.x models. Both need the paid tier.
- Your prompts may be used to train Google's models and read by human reviewers. Google's terms say not to send sensitive, confidential or personal information on the free tier.
The 3.x Flash price is a promotional rate through December 31, 2026, rising to $1.50 / $7.50. Full rates for every model are on our Gemini API pricing page.
When you need to add billing
Move to the paid tier when you hit the free limits, need Gemini 3.1 Pro or the image models, or are about to handle customer data. Paid requests are not used to improve Google's products.
Click Set up billing on the API keys or Projects page in AI Studio, link or create a Cloud Billing account, and add a payment method. New accounts are on Prepay: you buy credit up front, with a $5 minimum.
Three Prepay rules catch people out:
- At $0 your keys stop. Requests fail with a 402 error. The project does not drop back to the free tier. Turn on auto-reload if you are running anything in production.
- Prepaid credit expires after 12 months and is non-refundable.
- The $300 Google Cloud welcome credit does not work on the Gemini API for accounts opened after March 2, 2026.
Paid accounts move up usage tiers as they spend. Tier 1 is instant when you link billing and caps spend at $250 a month. Tier 2 unlocks after $100 paid and 3 days, with a $2,000 cap. Tier 3 unlocks after $1,000 paid and 30 days. Spend on any Google Cloud service counts toward the upgrade.
If you are in the UK, Switzerland or the EEA, Google's paid data terms apply even on the free tier, but you can only use the paid tier to serve an app to users there.
Keep your Gemini API key safe
A leaked key on a billed project is a blank cheque. Google's own rules:
- Never commit it to Git. Keep it in an environment variable or a secrets manager such as Google Cloud Secret Manager.
- Never put it in a web or mobile app. Anyone can pull it out of the client. Call Gemini from your own backend instead.
- Restrict it. In AI Studio, any key marked "Unrestricted" can be limited to the Gemini API only. In the Cloud Console you can also restrict it to your server's IP addresses.
- Set a billing alert so a runaway script or leaked key shows up in hours, not at the end of the month.
If a key leaks, create a new one, deploy it, then disable the old key once the new one works, and check your usage. Google blocks keys it detects as leaked with the message "Your API key was reported as leaked." Unrestricted keys left unused for a long time can also be blocked, so create a fresh restricted key if an old one stops working.
Common Gemini API key errors and fixes
From Google's troubleshooting guide. The SDKs retry 429 and 5xx errors automatically; do not retry 400, 402 or 403.
| Error | What it means | Fix |
|---|---|---|
| 401 authentication | Key missing, wrong or expired | Check the environment variable and copy the key again |
| 429 rate limit | Too many requests or tokens this minute | Back off and retry, or add billing for higher limits |
| 429 quota exceeded | Daily free quota used up | Wait for the midnight Pacific reset, or move to paid |
| 402 payment required | Prepay balance is $0 | Top up credit in AI Studio |
| 403 permission denied / access restricted | Key lacks access, or you are in an unsupported region | Check project access; use from a supported country |
| 404 model not found | Old or misspelled model name | Use a current name such as gemini-3.8-flash |
| "Create API key" greyed out | No permission in that Cloud project (common on work accounts) | Ask for Project Editor, or create a project outside your organization |
On a Google Workspace account, an admin can switch AI Studio off for your organization. If you see "you do not have access to Google AI Studio", ask your admin or use a personal account.
AI Studio key vs Vertex AI
Google offers Gemini two ways. The Gemini Developer API is what you get with an AI Studio key, and it is what Google recommends for most developers. Vertex AI, which Google's docs now call the Gemini Enterprise Agent Platform, runs the same models inside Google Cloud with service-account authentication, regional controls and enterprise compliance.
Start with an AI Studio key. Move to Vertex AI when a customer asks for data residency or enterprise controls, or when your whole stack already runs on Google Cloud. The SDK is the same; you switch with one setting on the client.
For founders
How startups pay for Gemini with credits
The free tier is fine for a prototype. Once you launch, you want paid-tier limits and data handling without paying cash for it. That is what the Google for Startups Cloud Program is for, and Google says its credits cover Gemini and Gemma models.
The fine print
To qualify, your company must be founded within the last five years, have raised equity funding (SAFEs count), and have received no more than $5,000 in Google Cloud credits before. You need your billing account ID and an email on the same domain as your website.
One catch for AI Studio keys: Google's billing docs say eligible Cloud credits only apply to the Gemini API while your project has a positive Prepay balance. Keep at least the $5 minimum topped up and the credits are used first. Running Gemini through Vertex AI bills your Cloud account directly instead.
Our Google Cloud program page has the full eligibility rules and how to apply. If you also use Claude, Claude for Startups gives API credits on the Anthropic side.
Google for Startups Cloud Program
Up to $350,000
- Up to $200,000 in Google Cloud credits for 2 years
- Access to Google Cloud experts and technical guidance
- Google Cloud training credits
Questions founders ask
Is the Gemini API key free?
How do I get a Gemini API key?
What are the Gemini API free tier limits?
Do I need a credit card for a Gemini API key?
Does the Gemini API key expire?
Is my data private on the free tier?
Can I use Google Cloud startup credits on the Gemini API?
Why is "Create API key" greyed out?
Related guides
Gemini API pricing
Every model rate, batch and caching discounts.
Google Cloud startup credits
Eligibility, tracks, and how to apply.
How to get an Anthropic API key
The Claude equivalent, with free credits.
OpenAI API pricing
GPT model rates and OpenAI startup credits.
Claude API pricing
Anthropic's per-token rates for comparison.
Cloud credits for students
What students can get from Google Cloud and others.