Leaked an API key? Do this in the next 10 minutes
Bots scan public GitHub commits, pastes and shared chats for keys around the clock. Assume a leaked key is already being used. Order matters: kill the key first, clean up second.
Rule #1: deleting the commit, file or message does not help. The key is still valid and copies already exist. Revoke it.
Your checklist
Where to revoke each key
| Provider | Revoke / roll | Spending cap |
|---|---|---|
| OpenAI | API keys | Limits |
| Anthropic | API keys | Limits |
| Google AI Studio (Gemini) | API keys | Cloud Billing budgets |
| Stripe | API keys (use "Roll key") | n/a. Check recent payments and payouts |
| AWS | IAM security credentials | AWS Budgets |
| GitHub token | Personal access tokens | n/a |
Dashboard paths change. If a link 404s, search the provider's docs for "rotate API key".
Cleaning a Git repo
After the key is revoked, remove it from history with git filter-repo (the tool Git's own docs recommend), then force-push:
echo 'sk-OLDKEY==>REMOVED' > replace.txt git filter-repo --replace-text replace.txt git push --force --all
Forks and clones made before the cleanup still contain the key. That's why revoking comes first.
Paste check (stays in your browser)
Paste a file, log or chat export to find strings that look like common key formats before you share it.