How to Get a Gemini API Key in Google AI Studio (2026)
To get a Gemini API key, open Google AI Studio at aistudio.google.com/apikey, sign in with your Google Account, click Create API key, name the key, choose an imported project and click Create key. New users get a default project and key automatically after accepting the Terms of Service. Save the key as the GEMINI_API_KEY environment variable, never in client-side code (Google AI Studio docs, November 2026).
Every key belongs to a Google Cloud project, which sets its tier and billing. New in 2026: keys are auth keys bound to a service account, and unrestricted standard keys are rejected. Steps follow Google's AI Studio docs, read November 20, 2026, and our screenshots from the same day on a paid Tier 2 account.
Open aistudio.google.com/apikey and sign in. You must be 18 or older to use the APIs.
Accept the Terms of Service. New users get a default Google Cloud project and API key automatically.
Import a project if you already use Google Cloud: Projects, Import projects, Import.
Click Create API key, name the key, choose the project and click Create key.
Copy the key with the Copy API key icon and save it as GEMINI_API_KEY.
Test it with Get code in the Playground or Google's curl command.
The Gemini app plans (Google AI Plus, Pro and Ultra) are a separate product from the API; see the Gemini pricing plans guide for those.
Step 1: Open the API Keys Page in Google AI Studio
The API Keys page lists the keys in your imported projects, with Create API key at the top right. In our test on November 20, 2026, the left panel read PROJECT (API Keys, Projects), USAGE & BILLING (Usage, Rate Limit, Spend, Billing) and OBSERVE (Logs).
The table has Key, Project, Created and Billing Tier columns, and each row has icons for Copy API key, View spend, View usage, View logs and more actions.
Key missing? "This list only shows API keys for projects imported into Google AI Studio," so click Import projects. Existing Cloud accounts get no default project. The pages display at most 100 keys and 50 projects.
Step 2: Create the Key (and What Changed in 2026)
Click Create API key, name the key, pick a project and click Create key. The "Create a new key" dialog has "Name your key" (prefilled "Gemini API Key") and "Choose an imported project." We cancelled here to avoid a spare key.
"You do not have permission to create a key in this project" means you lack IAM permissions; ask an admin for a role such as Project Editor.
The 2026 key change. "Starting May 28, 2026, all new API keys created in Google AI Studio are automatically created as auth keys." Auth keys are "Bound directly to a Google Cloud service account" and restricted to the Gemini API by default. Also:
"The Gemini API rejects requests from unrestricted standard keys." Standard keys with explicit restrictions still work.
Since May 7, 2026, unrestricted keys left dormant for a long time are blocked and show a Blocked tag.
Google's docs mention a Key Type column; our API Keys page did not show one.
Step 3: Store the Key in an Environment Variable
Google recommends the GEMINI_API_KEY or GOOGLE_API_KEY environment variable, which the client libraries read automatically. If both are set, GOOGLE_API_KEY takes precedence.
On macOS with zsh, add this line to ~/.zshrc, save, then run source ~/.zshrc (use ~/.bashrc for Bash):
export GEMINI_API_KEY="YOUR_API_KEY"
On Windows, search for "Environment Variables", click Environment Variables, click New..., set the name to GEMINI_API_KEY and the value to your key, click OK and open a new terminal.
Step 4: Test the Key With Get Code or curl
The fastest test is Get code in the AI Studio Playground, which writes a script that reads GEMINI_API_KEY. In our test the Playground opened on Gemini 4 Hydrogen (gemini-4-hydrogen), and the prompt box showed "No API key selected."
Run settings showed Thinking level (High), Tools such as Code execution and Grounding with Google Search, and Output length 65536 ("Up to 1,048,576"). AI Studio usage stays free "unless users link a paid API key."
Click Get code, pick a language and copy:
import os
from google import genai
client = genai.Client(api_key=os.environ.get("GEMINI_API_KEY"))
generation_config = {'max_output_tokens': 65536, 'thinking_level': 'high'}
interaction = client.interactions.create(
model='models/gemini-4-hydrogen',
input="""INSERT_INPUT_HERE""",
generation_config=generation_config,
)
print(interaction.output_text)
Run pip install -U google-genai first and replace INSERT_INPUT_HERE with a prompt. Without Python, use Google's REST call:
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" }'
A text reply means the key works.
Gemini API Free Tier: Where to See Your Limits
Your free-tier limits are on the Rate Limit page in AI Studio, under USAGE & BILLING. Google's rate limits page measures RPM, input TPM and RPD, and "Rate limits are applied per project, not per API key." Daily quotas reset at midnight Pacific time.
As of November 2026, Google's docs no longer publish per-model free numbers for the main text models, so check the dashboard.
Free models include Gemini 4 Hydrogen, Gemini 3.8 Flash and Gemini 2.5 Pro ("Free of charge").
Paid only: Gemini 4 Carbon, Neon and Argon, and the Nano Banana image models.
Your data: free-tier prompts help improve Google products, so "Do not submit sensitive, confidential, or personal information." Paid-tier content is not used for that.
Verification: extra projects return 403 (FREE_TIER_VERIFICATION_REQUIRED) until you click Verify project on the Projects page and scan a QR code. Paid projects skip this (verification docs).
Billing, Prepay and Usage Tiers
The paid tier starts when you link a billing account and prepay at least $5. Click Set up billing under Billing Tier, then Buy credits on the Billing page, up to $5,000 (billing docs).
Tier
How you qualify
Billing tier cap
Free
Active project or free trial; some projects need verification
N/A
Tier 1
Set up and link an active billing account
$250
Tier 2
Paid $100 + 3 days from first successful payment
$2,000
Tier 3
Paid $1,000 + 30 days from first successful payment
$20,000 to $100,000+
At a $0 balance, every key on that billing account fails with HTTP 402.
"All Prepaid API credits expire after 1 year and cannot be refunded."
Since March 2026 the $300 Google Cloud trial credit does not cover the Gemini API.
Paid prices per 1 million tokens, Standard, as of November 20, 2026 (pricing page):
Model
Free tier
Input
Output
Gemini 4 Hydrogen
Free of charge
$1.50
$7.50
Gemini 3.8 Flash
Free of charge
$0.75 through Dec 31, 2026; $1.50 from Jan 1, 2027
$3.75, then $7.50
Gemini 4 Carbon
Not available
$2.00 through Nov 30, 2026; $4.00 from Dec 1, 2026
Keep Your Gemini API Key Secret, Restrict or Delete It
"Treat your Gemini API key like a password," Google says.
Never commit it to Git or hardcode it in web or mobile apps; "Keys compiled in client-side code can be extracted by users." Use a backend proxy and, in production, Google Cloud Secret Manager.
Restrict old keys: on the API Keys page, hover the Unrestricted label, click Add restrictions, select Restrict to Gemini API only, then Restrict key.
Limit by IP: in the Cloud console credentials page, set IP addresses under Application restrictions.
If a key leaks: create and deploy a new key, then disable or delete the old one in the Cloud console.
Deleting needs the apikeys.keys.delete permission; the Viewer role "cannot create, update, or delete" keys (AI Studio troubleshooting).
Using the Gemini app alongside the API? AI Toolbox (formerly Gemini Toolbox) adds folders, full-text search, saved prompts and export to Gemini chats at gemini.google.com. The free plan includes 2 root folders with unlimited subfolders and 10 saved prompts; Premium makes them Unlimited. 40,000+ users on the Chrome Web Store.
Our Tier 2 account cannot show free-tier numbers. The API works only in listed countries; a 403 Access Restricted error often means an unsupported region (available regions). Prices change soon: Carbon on December 1, 2026 and 3.8 Flash on January 1, 2027. AI Toolbox cannot change any of these limits.
Frequently Asked Questions
Is the Gemini API key free?
Yes. New Google AI Studio accounts start on the free tier, which includes free input and output tokens for models such as Gemini 4 Hydrogen and Gemini 3.8 Flash. Some models, including Gemini 4 Carbon, need the paid tier, which starts with a $5 prepay.
Where do I find my Gemini API key?
Open Google AI Studio and go to the API Keys page under PROJECT in the left panel. Each key row has a Copy API key icon. If a key is missing, the list only covers projects imported into AI Studio, so click Import projects and add the Google Cloud project that owns it.
What are the Gemini API free tier limits?
Google measures limits as requests per minute, input tokens per minute and requests per day, applied per project rather than per key. As of November 2026 the docs no longer list per-model free numbers for the main models, so open the Rate Limit page in AI Studio to see yours.
Can I use the $300 Google Cloud credit for the Gemini API?
No. Google says that starting March 2026, Gemini API usage is excluded from the $300 Google Cloud Free Trial program, and the welcome credit cannot be used for the Gemini API or AI Studio. To reach the paid tier you link a billing account and prepay at least $5 in credits.
Why is my Gemini API key rejected?
The most common 2026 cause is an unrestricted standard key, which the Gemini API now rejects. Restrict it to the Gemini API in AI Studio or create a new auth key. Other causes are a $0 prepaid balance, which returns HTTP 402, and an unverified free project, which returns 403.
Bottom Line
Create the key on the API Keys page, save it as GEMINI_API_KEY, test it, check the Rate Limit page and restrict it. New to Gemini? Start with the Gemini beginner guide.
A Full Stack Developer with 7+ years of experience building AI productivity tools. Leads product development and frontend architecture for AI Toolbox, the Chrome extension suite (ChatGPT, Gemini, Grok, and Claude modules) that helps users search, organize, and export their AI conversations.
Liked this guide? Get the next one first.
Join 40,000+ readers getting practical prompts, new features, and subscriber-only deals. No spam, unsubscribe in one click.
New features and product updates before anyone else
Time-saving prompts and workflows for ChatGPT, Gemini, Claude, and Grok