How to Get a Google AI (Gemini) API Key

Status: 🟩 COMPLETE 🟦 LIVING Section: how-to Tags: google, gemini, api-key, developer, setup, walkthrough


What you’re doing

A Google AI API key lets your apps connect to Gemini models programmatically. You need one if you want to:

  • Build apps that use Gemini
  • Use Gemini in developer tools (Cursor, Cline)
  • Run scripts that generate text or process documents with Gemini
  • Use the Gemini API directly

You do NOT need this for using gemini.google.com or the Gemini mobile app — those use your Google login.

Important distinction: Google has TWO ways to access Gemini via API:

  1. Google AI Studio (aistudio.google.com) — simpler, consumer/developer-focused, free tier available, this guide focuses on this
  2. Google Cloud Vertex AI (cloud.google.com) — enterprise-focused, much more complex, billed via GCP

This guide covers Google AI Studio, which is what most individual developers and small businesses want.


What you need

  • A Google account
  • A web browser
  • (Optional) Payment method for paid tier — but free tier is generous

Step-by-step

Step 1 — Go to Google AI Studio

Open https://aistudio.google.com in your browser.

Step 2 — Sign in with Google

Use any Google account.

Step 3 — Accept terms

First time, you’ll see Google’s terms for AI Studio. Read and accept.

Step 4 — Get your API key

  1. Click Get API key (left sidebar or top right)
  2. Click Create API key
  3. Choose a project (or let Google create one for you)
  4. The key appears — copy it (starts with AIza...)

Save the key in a password manager or .env file. Don’t commit to public repositories.

Step 5 — Test the key

In Google AI Studio, you can test immediately:

  1. Click Chat in left sidebar
  2. Type a message and submit
  3. Gemini responds

Or test programmatically in your tool of choice.


Pricing (mid-2026)

Google AI Studio has a genuinely generous free tier:

ModelFree tierPaid tier (per million tokens)
Gemini 2.5 FlashFree up to rate limitsInput 0.30
Gemini 2.5 ProRate-limited freeInput 10
Gemini 2.5 Flash-8BFreeInput 0.15

Free tier limits (approximate):

  • 15 requests per minute for Gemini Flash
  • 2 requests per minute for Gemini Pro
  • 1,500 requests per day for Flash
  • Rate limits reset constantly

For most personal projects, the free tier is sufficient.

Switching to paid (pay-as-you-go)

If you exceed free limits or need higher throughput:

  1. Settings → Billing
  2. Link a Google Cloud billing account (or create one)
  3. Enable billing for the API
  4. You’ll automatically move to pay-per-use pricing

Common uses

In Cursor

Settings → Models → Google API key → paste your AIza... key. Cursor adds Gemini to your model options.

In Cline

Click Cline icon → API Provider: Google → paste your key.

In Python

import google.generativeai as genai
genai.configure(api_key="AIza-your-key")
model = genai.GenerativeModel('gemini-2.5-flash')
response = model.generate_content("Hello!")
print(response.text)

(Use environment variables, not hardcoded keys.)


Free tier vs Paid: when to upgrade

Stay free if you:

  • Doing personal projects
  • Testing/learning the API
  • Low-volume use (a few hundred requests per day)

Upgrade to paid if you:

  • Building a public-facing app that may have many users
  • Hitting rate limits regularly
  • Need consistent availability without throttling

Gemini API vs Vertex AI

When should you use Vertex AI on Google Cloud instead of AI Studio?

Use Google AI Studio (this guide) for:

  • Personal projects
  • Prototypes and experimentation
  • Small business apps
  • Anything where simplicity matters

Use Vertex AI on GCP for:

  • Enterprise applications needing GCP integration
  • Australian data residency requirements (Vertex has Sydney region)
  • Compliance/audit requirements (SOC 2, HIPAA, etc.)
  • Multi-model access (Vertex has Claude, Llama, etc. alongside Gemini)
  • Production workloads needing SLAs
  • High volume requiring volume discounts

See aws-vs-azure-vs-gcp-for-ai for the cloud comparison.


Australian-specific notes

  • Free tier is excellent for Australian users — no credit card needed for testing
  • Currency: Paid tier billed in USD
  • GST: Charged for paid tier; ensure billing details have your ABN for business use
  • Data residency: AI Studio doesn’t guarantee Australian data residency — use Vertex AI in Sydney region if that’s a requirement
  • AEDT/AEST: No effect on API; works 24/7

Privacy considerations

Google AI Studio:

  • API content is NOT used to train Google models by default for paid users
  • Free tier: content may be used to improve services (check current terms)
  • Different privacy properties than consumer Gemini (which has more visibility into your data)
  • For sensitive content: prefer paid tier or Vertex AI Enterprise

For Australian Privacy Act compliance:


Common gotchas

  • Rate limits on free tier: 15 requests/minute on Flash, 2/minute on Pro. Exceeded → 429 errors. Slow down or upgrade.
  • Key visibility: You can see your key in the Console anytime (different from OpenAI/Anthropic) — but still treat it as secret
  • Model name changes: Google updates model names frequently. Old code may reference deprecated names — check current.
  • AI Studio vs Vertex differences: Same models behave slightly differently; pricing different; features different. Know which you’re using.
  • Region availability: Some Gemini models may not be available in all regions during initial rollout.

Rotating keys

  1. Get API key page
  2. Find your key
  3. Click Delete (or create a new one)
  4. Update wherever the key is used

You can have multiple keys at once — useful for separating projects.


See also


Sources

  • Google AI Studio: aistudio.google.com
  • Gemini API documentation: ai.google.dev/gemini-api/docs
  • Google AI Terms of Service
  • Tested signup flow (June 2026)