A Gemini API key lets your apps, scripts and AI tools use Google’s Gemini models. The good news: you can get one for free in about two minutes through Google AI Studio, and several Gemini models have a free tier that is generous enough for prototypes and personal projects.
What you need
- A Google account (personal or Workspace, if your admin allows AI Studio).
- To be in a country where the Gemini API is available.
- To be 18 or older.
Step-by-step: get your Gemini API key
- Go to aistudio.google.com and sign in with your Google account.
- Accept the terms of service if prompted.
- Click Get API key in the left sidebar (or the top of the dashboard).
- Click Create API key. AI Studio may create a Google Cloud project for you automatically, or you can pick an existing project.
- Copy the key and store it somewhere safe, such as a password manager.
That is it. You do not need a credit card for the free tier.
Test your key
Set it as an environment variable named GEMINI_API_KEY:
export GEMINI_API_KEY="your-key-here"
Then install the official Google Gen AI SDK for Python:
pip install google-genai
from google import genai
client = genai.Client() # reads GEMINI_API_KEY
resp = client.models.generate_content(
model="MODEL_ID",
contents="Give me three tips for writing better emails.",
)
print(resp.text)
Replace MODEL_ID with a current Flash or Pro model name from Google’s model list. A JavaScript SDK (@google/genai) works the same way.
Gemini API free tier explained
The free tier gives access to selected models, mostly Flash and Flash-Lite, with rate limits measured in requests per minute, tokens per minute and requests per day. The more advanced Pro models may have very limited or no free access. Limits change regularly, so check the rate limits page in the Gemini API docs.
Important privacy note: on the free tier, Google may use your prompts and responses to improve its products, and human reviewers may read them. Do not send personal or confidential data on the free tier. The paid tier does not use your data for product improvement.
Paid tier and pricing
To unlock higher limits and the data protections of the paid tier, enable billing on the linked Google Cloud project. You then pay per million tokens. As of October 2026, Flash-Lite models cost well under $1 per million input tokens, Flash models cost a little more, and Pro models cost a few dollars per million input tokens with higher output prices. Batch processing and context caching reduce costs. See our Gemini pricing guide for consumer plans too.
Keep your key secure
- Never hard-code the key in public repositories or client-side code.
- Restrict the key in Google Cloud Console to the Generative Language API, and to specific IPs or apps where possible.
- Rotate keys regularly and delete unused ones.
- Set budget alerts in Google Cloud Billing if you enable the paid tier.
Gemini API vs Vertex AI
The Gemini API through AI Studio is the quickest way to start and suits individuals and startups. Vertex AI on Google Cloud offers the same models with enterprise features: IAM permissions, regional data residency, private networking and enterprise support. Large organisations usually choose Vertex AI.
Common errors and fixes
| Error | Fix |
|---|---|
| API key not valid | Check for extra spaces, confirm the key exists in AI Studio and that the API is enabled in the project. |
| 429 RESOURCE_EXHAUSTED | You hit a free-tier rate limit. Slow down, add retries or enable billing. |
| User location is not supported | The API is not available in your region. |
| Model not found | Use a current model ID; older versions are retired. |
| Permission denied (Workspace) | Your administrator may have disabled AI Studio. Ask IT or use a personal account for testing. |
What can you build with a Gemini API key?
- Chatbots and customer support assistants.
- Document, image and video analysis tools (Gemini handles long context and multiple media types).
- Text-to-speech and audio transcription.
- Automations in tools like n8n, Make and Zapier.
- Coding assistants via the Gemini CLI.
Comparing providers? Read how to get a Claude API key and browse the best AI automation tools.
FAQ
Is the Gemini API key free?
Yes. Creating a key is free and there is a free tier for several models, with rate limits.
Does Google AI Pro include API credits?
No. Consumer subscriptions such as Google AI Pro are separate from Gemini API billing.
Where do I find my existing Gemini API key?
In Google AI Studio under “Get API key” or in Google Cloud Console under APIs & Services → Credentials.
Can I use the free tier commercially?
Check Google’s current terms. Remember free-tier data may be used to improve Google products, so the paid tier is better for production apps.
Browse our curated directory of AI tools by category.