My Gemini key leaked. What do I do?
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
| When | Do | How |
|---|---|---|
| 0–2 min | Delete | Google AI Studio → API keys (or Cloud console → Credentials) → delete or regenerate the key. |
| 2–4 min | Replace | Create a new key restricted to the Gemini API. Set GEMINI_API_KEY on the server and redeploy. |
| 4–8 min | Check usage | Review usage in AI Studio and Billing in Cloud console. Set a budget alert. |
| 8–10 min | Close the hole | Remove 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_orEXPO_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
.envor.gitpaths.
Check your live app
A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.
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.