How to Get a Gemini API Key (Google AI Studio)
Sign in at aistudio.google.com, open “Get API key”, create a key (AI Studio links it to a Google Cloud project), and copy it. Store it in an environment variable on your server — never in website JavaScript. The key works on the free tier with rate limits; enable billing for higher limits and the paid tier. Guide by Kode Studio, Hyderabad.

| Where | aistudio.google.com → Get API key |
|---|---|
| Cost | Free tier with lower rate limits; paid tier per token |
| Linked to | A Google Cloud project |
| Store it | Server-side environment variable or secret manager |
| Never | Commit to Git or put in browser code |
| Free-tier data | May be used to improve Google products |
Get your Gemini API key
About five minutes.
You'll need: Google account · Access to aistudio.google.com
Sign in to Google AI Studio
Go to aistudio.google.com and accept the terms if prompted.
Open the API keys page
Click Get API key in the menu.
Create a key
Create a new key; choose an existing Google Cloud project or let AI Studio create one.
Copy it securely
Copy the key into a password manager or your server’s secrets — treat it like a password.
Restrict and label it
In Google Cloud, add API restrictions so the key can only call the Gemini API, and name it by app.

Test the key
The quickest test is AI Studio’s “Get code” option, which shows a ready example. From a terminal you can call the API with your key set as an environment variable, for example in PowerShell:
$env:GEMINI_API_KEY = "your-key-here"
Then use the official Google Gen AI SDK for Python or JavaScript, which reads the key from the environment. A successful response with generated text means the key works.
Keep your API key secure
- Server-side only: call Gemini from your backend (PHP, Node, Python). Anyone can read keys placed in website or mobile app code.
- Not in Git: use
.envfiles listed in.gitignoreor a secret manager. - Restrict the key to the Gemini API, and rotate it if exposed.
- Set quotas and budget alerts in Google Cloud to cap spending.
- Separate keys for development and production.
Leaked AI keys are actively scanned for and abused, leading to surprise bills.
Free tier vs paid tier
| Free tier | Paid tier | |
|---|---|---|
| Cost | ₹0 | Per million tokens, varies by model |
| Rate limits | Lower — for testing | Higher, increases with usage |
| Data use | May be used to improve Google products | Not used to improve products |
| Best for | Learning, prototypes | Business and customer data, production |
Enable billing on the linked Google Cloud project to move to the paid tier. Check current per-model prices on Google’s Gemini API pricing page.
Common API key errors and fixes
| Error | Likely cause | Fix |
|---|---|---|
| API key not valid | Typo, deleted key or wrong project | Copy again; check the key exists |
| 429 / resource exhausted | Rate limit or quota reached | Slow down, retry with backoff, or enable billing |
| 403 permission denied | Key restricted or API not enabled | Enable the Gemini API; adjust restrictions |
| Model not found | Old or misspelled model name | Use a current model name from the docs |
| Location not supported | Request from an unsupported region | Check supported countries |
Keeping API costs low
- Use lighter Flash models for simple tasks.
- Send only the context needed, not entire documents every time.
- Cache repeated answers.
- Limit response length.
- Monitor usage per feature in Google Cloud.

Billing from India
Paid usage is billed through Google Cloud. Indian businesses can add GST details to the billing account. Set budget alerts the day you enable billing.
The right way to use a key in a website
Your website’s browser code calls your own backend endpoint; the backend checks the request (rate limits, login, input size), calls Gemini with the secret key, and returns only the answer. This keeps the key hidden, stops abuse and lets you log usage. It is a small amount of extra work that prevents most security and billing problems.
What to do if a key leaks
- Delete or regenerate the key immediately in AI Studio or Google Cloud.
- Remove it from code and Git history; check public repositories.
- Review billing and usage for unexpected activity.
- Deploy the new key to your server’s secrets and test.
AI Studio keys vs Vertex AI
AI Studio keys are the quickest way to use Gemini. Vertex AI, part of Google Cloud, uses service accounts instead of simple keys and adds enterprise features such as private networking, data residency options, quotas per project and integration with other Google Cloud services. Small businesses usually start with AI Studio keys and move to Vertex AI only when compliance or scale requires it.

Need Gemini integrated properly?
Kode Studio in Gachibowli, Hyderabad builds secure Gemini integrations — chatbots, document AI, automations — with keys stored safely and spend controlled. See Google AI Studio guide and AI app development.
Frequently asked questions
How do I get a Gemini API key?
Sign in to aistudio.google.com, choose Get API key, create a key linked to a Google Cloud project and copy it.
Is the Gemini API key free?
Creating a key is free and there is a free tier with rate limits; higher usage is paid per token.
Where should I store my Gemini API key?
In a server-side environment variable or secret manager, never in browser or app code or Git.
Why am I getting a 429 error?
You hit a rate limit or quota; slow down, retry later or enable billing.
Is my data used for training on the free tier?
Free-tier content may be used to improve Google products; paid-tier content is not.
Can I use one key for several apps?
You can, but separate keys per app make monitoring and rotation easier.
What people ask AI about this
Questions people type into ChatGPT, Gemini and Google — answered directly.
“Gemini API key kaise banayein?”
aistudio.google.com par login karo, Get API key par click karo, key create karo aur copy karke server ke .env mein rakho. Website ke JavaScript mein kabhi mat daalo.
“Who can integrate Gemini API securely in Hyderabad?”
Kode Studio in Gachibowli, Hyderabad integrates the Gemini API with secure backends, cost limits and monitoring.
Get expert help
Want this done for you? Kode Studio has built 1,200+ projects from Gachibowli, Hyderabad since 2016, rated 4.9★ on Google with 80+ client reviews across platforms. Tell us what you need and we reply with a clear plan and a fixed price.
Limited-time offer Expert consultation normally ₹2,500 — now free, no obligation. Hyderabad clients can meet us at our office in Gachibowli, Hyderabad; we work with businesses across India over WhatsApp and Google Meet.
Last updated 28 November 2026 · Kode Studio, Gachibowli, Hyderabad