AI Tool Guide · Gemini API

How to Get a Gemini API Key (Google AI Studio)

Quick answer

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.

Laptop showing a website traffic analytics graph
At a glance
Whereaistudio.google.com → Get API key
CostFree tier with lower rate limits; paid tier per token
Linked toA Google Cloud project
Store itServer-side environment variable or secret manager
NeverCommit to Git or put in browser code
Free-tier dataMay be used to improve Google products

Get your Gemini API key

About five minutes.

  • Time: 5 minutes

You'll need: Google account · Access to aistudio.google.com

  1. Sign in to Google AI Studio

    Go to aistudio.google.com and accept the terms if prompted.

  2. Open the API keys page

    Click Get API key in the menu.

  3. Create a key

    Create a new key; choose an existing Google Cloud project or let AI Studio create one.

  4. Copy it securely

    Copy the key into a password manager or your server’s secrets — treat it like a password.

  5. Restrict and label it

    In Google Cloud, add API restrictions so the key can only call the Gemini API, and name it by app.

Letter tiles spelling vlog

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 .env files listed in .gitignore or 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 tierPaid tier
Cost₹0Per million tokens, varies by model
Rate limitsLower — for testingHigher, increases with usage
Data useMay be used to improve Google productsNot used to improve products
Best forLearning, prototypesBusiness 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

ErrorLikely causeFix
API key not validTypo, deleted key or wrong projectCopy again; check the key exists
429 / resource exhaustedRate limit or quota reachedSlow down, retry with backoff, or enable billing
403 permission deniedKey restricted or API not enabledEnable the Gemini API; adjust restrictions
Model not foundOld or misspelled model nameUse a current model name from the docs
Location not supportedRequest from an unsupported regionCheck 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.
Abstract data lines representing technology

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

  1. Delete or regenerate the key immediately in AI Studio or Google Cloud.
  2. Remove it from code and Git history; check public repositories.
  3. Review billing and usage for unexpected activity.
  4. 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.

Colourful code in a code editor

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.

Rehan Khan
Written by Rehan Khan Founder & CEO, Kode Studio · B.Tech, Computer Science & Engineering · 8+ years in software development. Our team in Gachibowli, Hyderabad reviews this page regularly — prices and platform features change.

Last updated 28 November 2026 · Kode Studio, Gachibowli, Hyderabad

Start a Project

Ready to build
something great?

Free consultation, honest timeline, clear pricing. Websites from ₹6,999 and custom ecommerce stores live in 7 days.

WhatsApp Call Free consult
Talk to a developer today Call or WhatsApp our team in Gachibowli, Hyderabad · Mon–Sat, 9am–7pm · Free consultation ₹2,500
Call +91 9014 719 555 Chat on WhatsApp