# 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

| 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_` 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.

> **Scan box (use the site's ScanBox component):** Check whether your live app has this problem. Paste your URL for a free outside-in scan covering exposed keys, open database rules, CORS and security headers. [Scan my app free →](https://proofforge.live/#scan)

## 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

- [Gemini API: Using API keys](https://ai.google.dev/gemini-api/docs/api-key)
- [Google Cloud: Manage API keys](https://cloud.google.com/docs/authentication/api-keys)

## Related

- [Google Maps key leaked: first 10 minutes](/leaked-keys/google-maps)
- [Fix: secrets in VITE_ / NEXT_PUBLIC_ vars](/fix/vite-env-secrets)
- [Exposed API key checker](/tools/exposed-api-key-checker)
- [Fix: source maps exposed](/fix/source-maps-exposed)
- [All leaked-key guides](/leaked-keys)
