Skip to content

My Gemini key leaked. What do I do?

Short answer

Delete the key in Google AI Studio (or regenerate it in Google Cloud console), create a restricted replacement on your server, then check usage and billing. Unrestricted standard keys are now rejected by the Gemini API. New AI Studio keys are authorization keys bound to a service account, with leaked-key enforcement.

Last updated 2026-11-25 · Reviewed by ProofForge

Is it this key?

Format: AIza (Google API key format)

Blast radius: Gemini usage billed to the project. If the key is unrestricted, also any other enabled Google API in that project.

The first 10 minutes

WhenDoHow
0–2 minDeleteGoogle AI Studio → API keys (or Cloud console → Credentials) → delete or regenerate the key.
2–4 minReplaceCreate a new key restricted to the Gemini API. Set GEMINI_API_KEY on the server and redeploy.
4–8 minCheck usageReview usage in AI Studio and Billing in Cloud console. Set a budget alert.
8–10 minClose the holeRemove the key from client code and git history. Don't reuse Maps keys for Gemini.

Stop the next leak

  • Keep the key in a server-side env var. Never use a VITE_, NEXT_PUBLIC_ or EXPO_PUBLIC_ variable or hard-code it in frontend code.
  • Call the provider from your backend or an edge function, and add .env* to .gitignore.
  • Re-scan the live site after every deploy. Keys also leak through JS bundles, source maps and exposed .env or .git paths.

Check your live app

A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.

Read-only. No writes or row contents.

FAQ

Can I call Gemini from the browser?

Not with a standard API key. Use your server.

What changed in 2026?

New AI Studio keys are authorization keys bound to a service account, and unrestricted standard keys are rejected.

Same key as Maps?

Use separate keys, each restricted to one API.

Sources

Related

Read as Markdown · Scan methodology