Skip to content

Leaked Google Gemini API key? What to do now

Revoke it first, then check what it was used for, cap what your keys can spend and clean up where it leaked. Every Google Gemini step below comes from Google Gemini's own docs, checked 15 Nov 2026.

Free. No sign-up.

Whose key leaked?
Where did it leak?

What to do now, for Google Gemini

  1. Revoke the key now

    Delete the key on Google Cloud's Credentials page, or use Rotate key, which makes a new key with the same restrictions, then delete the old one. Deleted keys can be restored for 30 days. Do this first: until it's revoked, anyone who copied it can keep spending. GitHub reports standard Google API keys to Google, but its push protection doesn't block Google or Gemini keys, so it won't stop you pushing one.

    Google Cloud credentials

  2. Keep the new key on the server

    Put the new key only in a server-side secret: your host's environment settings, your builder's secrets, or Supabase function secrets. Never in a variable starting NEXT_PUBLIC_, VITE_ or EXPO_PUBLIC_, which are sent to every visitor.

    Lovable secretsBolt secretsSupabase function secrets

  3. Check usage for charges that weren't yours

    AI Studio's usage page shows requests per named key, and the spend page shows cost. Spend can take up to 24 hours to appear. Note the time the key leaked and the time you revoked it.

    AI Studio usage

  4. Cap what any key can spend

    Set a project spend cap on AI Studio's spend page (still experimental; expect about 10 minutes of overage), or a spend cap budget in Google Cloud Billing. An ordinary Cloud budget only sends alerts. New accounts are prepaid, which stops at $0 unless auto-reload is on.

    AI Studio spend

  5. Clean up the repo, after revoking

    Remove the key from the code and the git history, but only once it's revoked: anyone who cloned the repo, or a fork, still has it. Then turn on push protection, so GitHub blocks the next key you try to push.

    GitHub: removing sensitive dataGitHub: push protection

  6. If someone ran up charges, ask for them back

    Contact Cloud Billing customer care to report the compromised key. Google reviews billing adjustments case by case. Say when the key leaked, when you revoked it and which usage wasn't yours.

    Google Cloud Billing help

Checked in Google Gemini's own docs. Sources: Gemini API keys, Google Cloud API keys, Gemini billing, budgets and spend caps, billing problems. Dashboards move, so if a link is out of date, look for the same setting under account or organisation settings.

Then find every other copy, with your coding agent

Find every place an API key or other secret is exposed in this project, and fix it. Search the code, env files, config and local settings files (such as .claude/settings.local.json), the full git history (with gitleaks or a similar scanner) and the built browser bundle. Flag any secret in a variable with a public prefix such as NEXT_PUBLIC_, VITE_ or EXPO_PUBLIC_, and any AI provider called from browser code. Move every AI call into a server route or function that reads its key from a server-only variable, add .env and local settings files to .gitignore, and list each key that was exposed and where, so I can revoke it. Don't rewrite git history.

Questions

Does Google Gemini disable a leaked key for you?

GitHub reports standard Google API keys to Google, but its push protection doesn't block Google or Gemini keys, so it won't stop you pushing one. Revoke it yourself either way.

Can I cap what a Google Gemini key spends?

Set a project spend cap on AI Studio's spend page (still experimental; expect about 10 minutes of overage), or a spend cap budget in Google Cloud Billing. An ordinary Cloud budget only sends alerts. New accounts are prepaid, which stops at $0 unless auto-reload is on.

How do I see what a leaked Google Gemini key was used for?

AI Studio's usage page shows requests per named key, and the spend page shows cost. Spend can take up to 24 hours to appear.

Will Google Gemini refund charges from a leaked key?

Contact Cloud Billing customer care to report the compromised key. Google reviews billing adjustments case by case.

How do I find where my Google Gemini key leaked?

Search your code, your git history and your live site's JavaScript for “AIza” (how Google Gemini keys start). Common places are browser code, a committed .env or local settings file, and screenshots.

Other providers