Guide · Keys
Leaked AI key: the first 15 minutes
Stop the spending first, then investigate. Deleting the key from your code, host, or .env file does not turn it off. A copied key keeps working until the provider disables or deletes it.
Checked against the providers' docs on . For OpenAI, Anthropic, or OpenRouter.
Minutes 0–5: turn the key off at the provider
- OpenAI. Delete the affected key in the API key dashboard, then create a new one. [1] If you cannot find the right key quickly, enforce a hard spend limit. For the organization: Organization limits, then Spend, Edit spend limit, Monthly spend limit, Enforce a hard limit, Save. For one project: Project settings, Limits, then the same Spend steps. Enforcement is not instantaneous, so recorded spend can go slightly over the limit. [2]
- Anthropic. Open the API keys page at platform.claude.com/settings/keys. The compromised-key article says to open the menu (three horizontal dots) and choose Delete API key. [3] On that same page, Disable is reversible and Delete is permanent. [4]
- OpenRouter. On Security settings, open the Key safety tab. Disable is reversible. Archive is permanent and asks you to type
archive. [6] A management key can also sendPATCH /api/v1/keys/{hash}with{"disabled": true}. [7] - Any app still using the key will break. That is expected.
Minutes 5–10: replace the key, cap it, and check usage
- Make a new key and put it only in the one app that needs it. Store it in a secrets manager, not in code or version control. OpenAI says not to embed a key in an application such as a mobile app. [1] Anthropic says the same about version control, and you can set an expiration when you create the key. [3] [4]
- OpenAI. The hard limit above is monthly, on the organization or the project. [2]
- Anthropic. Set your own spend limit on the Console Billing page,
platform.claude.com/settings/billing. It cannot exceed the tier cap. [5] - OpenRouter. Set a spend limit on the key. A management key can set
limit_resetto daily, weekly, or monthly. You cannot change the expiration of a key that already exists. [6] [7] - Review usage for each key from the earliest date it could have leaked. Keep the export or the screenshots. [1]
Minutes 10–15: clean up the repo and contact support
If the key was committed to git. GitHub says revoking or rotating the secret is the first step, and that may be all you need. Rewriting history is optional. [8]
- To erase the text from history, use
git-filter-repo2.47 or later:git-filter-repo --sensitive-data-removal --replace-text ../passwords.txt, thengit push --force --mirror origin. [8] - After that, contact GitHub Support to remove cached views. Anyone who cloned the repo should re-clone it, or clean the old clone. A later
git pullandgit pushfrom an old clone can put the secret back. Copies in forks can still contain it. [8]
Contact the provider with the key's name or ID, when it leaked, when you turned it off, and the usage that was not yours. Do not send the secret. A refund is not promised.
- OpenAI: open a new chat on any Help Center page. [1]
- Anthropic: contact their Support team. [3]
- OpenRouter: these docs do not name a support page. Use the support channel in your OpenRouter account.
Prevent the next one
- Use one key per app or agent. OpenAI recommends a separate key per feature, team, product, or project. [1]
- Put a cap on every key. Give a new Anthropic key an expiration. OpenRouter can reject keys that never expire if you set a maximum lifetime. [4] [6]
- GitHub push protection for your personal account is on by default and blocks pushes of secrets to public repositories. Repository push protection is a separate setting and is off until an admin turns it on. Add
.envto.gitignorewhen that file should not be tracked. [8] [9] - Do not put an OpenAI key in a mobile app or other client-side app. [1]
BillCurfew watches per-key spend at OpenAI, Anthropic, and OpenRouter. It emails you when a daily cap or a spike trips. The check runs about every five minutes. It is not a proxy, and it does not block the next request. A manual kill works on every plan, including Free: type DELETE for OpenAI (permanent) and DISABLE for Anthropic and OpenRouter (reversible). Auto-kill is paid-only and stays off until you turn it on.
Free is one provider, one watched key, and email alerts, with no card. Solo is $19/month, Team is $49/month, and Agency is $149/month. Each paid plan includes a 14-day trial. Start free with one key, no card. Prices are on pricing. What we store is on security.
Sources
- OpenAI Help Center, Keeping your OpenAI account secure. https://help.openai.com/en/articles/8304786-preventing-unauthorized-usage
- OpenAI, Spend limits. https://developers.openai.com/api/docs/guides/spend-limits
- Anthropic Help Center, What should I do if I suspect my API key has been compromised?. https://support.claude.com/en/articles/8384961-what-should-i-do-if-i-suspect-my-api-key-has-been-compromised
- Anthropic, Authentication. https://platform.claude.com/docs/en/manage-claude/authentication
- Anthropic, Rate limits. https://platform.claude.com/docs/en/api/rate-limits
- OpenRouter, Security settings. https://openrouter.ai/docs/guides/overview/auth/security-settings
- OpenRouter, Management API keys. https://openrouter.ai/docs/guides/overview/auth/management-api-keys
- GitHub Docs, Removing sensitive data from a repository. https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository
- GitHub Docs, Push protection. https://docs.github.com/en/code-security/secret-scanning/introduction/about-push-protection