Leaked an API key? › Google (Gemini API)
Leaked Gemini API key: what to do in the next 10 minutes
Last updated: November 9, 2026. Steps checked against Google (Gemini API)'s own docs on November 9, 2026.
Short answer: Create a new Gemini key in Google AI Studio, move it to your server, then disable or delete the leaked key in the Google Cloud console. Check usage and billing, and set a monthly project spend cap on the AI Studio Spend page.
Which Google (Gemini API) keys are secret?
- Secret: Gemini API keys from Google AI Studio or the Google Cloud console (Google treats them like passwords)
- Secret: Any Google API key that has the Generative Language API (Gemini API) in its API restrictions
- Meant to be public: A Firebase web config apiKey can sit in your frontend only if it is restricted to Firebase APIs. Firebase says never to put the Gemini Developer API (Generative Language API) on a public key.
The next 10 minutes
Times are a rough guide. Do the first step before anything else.
1. Make a new key and move it to the server (Minutes 0-2)
- Google's leak checklist starts with a replacement: create a new key on the AI Studio API Keys page (aistudio.google.com/apikey) or in the Google Cloud console.
- Put it only in a server-only environment variable or secret store, not in a VITE_ or NEXT_PUBLIC_ variable, then redeploy. Google says not to hardcode keys in web or mobile apps and to call the API through your own backend.
2. Disable or delete the leaked key (Minutes 2-5)
- Once the new key works, disable or delete the leaked key in the Google Cloud console (APIs & Services > Credentials). Google's checklist says to wait until the new key is active to avoid downtime.
- If the key is public and you see usage you don't recognize, a short outage costs less than a running bill. That's our advice, not Google's. A deleted key can be restored for 30 days if it was a false alarm.
- If your app already gets 403 PERMISSION_DENIED with "Your API key was reported as leaked. Please use another API key.", Google has blocked it: Google says that key can no longer be used with the Gemini API, so make a new one.
3. Check usage and cap spend (Minutes 5-8)
- Look at the AI Studio Usage page (aistudio.google.com/usage) and billing reports in the Google Cloud console for requests or charges you don't recognize. Write down times and amounts.
- Set a monthly project spend cap on the AI Studio Spend page (Monthly spend cap > Edit spend cap). Google calls it experimental and says spend can run over for about 10 minutes before the cap applies; it isn't available for invoiced billing accounts. Billing alerts only notify you.
4. Restrict keys and clean up (Minutes 8-10)
- In AI Studio, any key marked Unrestricted can be set to "Restrict to Gemini API only". The Gemini API now rejects unrestricted standard keys.
- If you saw charges you didn't make, submit a billing support case from the Google Cloud console. We can't promise how Google will handle the charges.
- Rotate any other secrets that sat in the same file or commit, remove the key from your frontend, public files and git history, then re-check your live site.
Good to know
- New keys created in Google AI Studio since May 28, 2026 are authorization keys bound to a service account and limited to the Gemini API by default; Google says they get faster leaked-key enforcement.
- SniffPup flags any Google API key (AIza…) it sees in your public pages as a low-severity finding, because most are Firebase config keys. Check that key's API restrictions in the Google Cloud console: if Generative Language API is on the list, treat it as a leaked Gemini key.
- SniffPup's free scan is passive and read-only on a site you own. It can't see your server code, Google Cloud settings or bill.
After the first 10 minutes
Move the code that needs the key to the server (an API route, serverless function or Supabase Edge Function), keep the key in a server-only environment variable, redeploy, and re-check your live site. The general plan, with a prompt you can paste into Lovable, Bolt, Cursor or Claude Code, is in I leaked an API key in my vibe-coded app. What do I do now?
What SniffPup checks, and what it doesn't
A free SniffPup scan reads only what your live site serves to the public: secret key patterns in HTML and same-origin JavaScript (masked in the report) and public files such as /.env and /.git/config. It never uses a key it finds. It can't see your repo, your server or Google (Gemini API)'s logs, so the steps above are always on you. A clean report is not a guarantee of security.
Sources
- Google AI for Developers: Gemini API keys
- Google AI for Developers: Troubleshooting
- Google AI for Developers: Project spend caps
- Firebase Docs: API keys
- Google Cloud: Manage API keys
- Google Cloud Blog: API keys are open secrets
Google (Gemini API) can change its dashboard and steps at any time. If something here doesn't match what you see, follow Google (Gemini API)'s docs and tell us.
Other providers
- Leaked OpenAI API key: what to do in the next 10 minutes
- Leaked Anthropic API key: what to do in the next 10 minutes
- Leaked Resend API key: what to do in the next 10 minutes
- Leaked Perplexity API key: what to do in the next 10 minutes
- Leaked OpenRouter API key: what to do in the next 10 minutes
- Leaked ElevenLabs API key (unauthorized charges): what to do
- Leaked Stripe secret key: what to do in the next 10 minutes
- Leaked Supabase service_role or secret key: next 10 minutes
- Leaked AWS access key: what to do in the next 10 minutes
- Leaked GitHub token: what to do in the next 10 minutes