Stolen OpenAI or Anthropic API key? What to do in the first hour
Last updated 19 Oct 2026
Short answer: Revoke the key at the provider straight away, so new requests using it are rejected. Then check usage to see what was spent and whether any other key was involved, turn on a hard monthly spend limit so a future leak has a ceiling, and report the misuse to OpenAI or Anthropic. After that, replace the key with a new, dedicated key for each app or tool, so one leak can't drain everything.
How do I stop a stolen API key right now?
- OpenAI: rotate the key immediately from the API Keys page, then update your apps with the replacement [O2].
- Anthropic: in the Claude Console, open the API keys page, use the menu next to the key and choose Delete API Key [A2]. The Console also offers Disable, which can be reversed, while Delete is permanent [A3].
- Revoke every key that could have been exposed, not just the one you noticed.
How do I find out what was spent?
- OpenAI: review the Usage page and check that the activity matches your own work [O2].
- Anthropic: review the usage and logs for your keys in the Console [A4].
- Note the key IDs, the time window and any models or traffic you don't recognise. You'll need them for your report.
- Usage can show up after the requests were made, so check again a few hours later.
How do I put a ceiling on future damage?
- OpenAI: set a monthly spend limit for the organization or a project, and turn on Enforce a hard limit. Once tracked spend reaches it, requests fail with a
429error. OpenAI says enforcement isn't instantaneous, so recorded spend can slightly exceed the limit, and the limit resets with the next monthly cycle [O1]. Spend alerts on their own don't stop traffic [O1]. - Anthropic: every Start, Build and Scale tier has a monthly spend cap. You can set your own lower limit on the Billing page, and set custom spend limits per workspace (but not on the default workspace) [A1].
- Keep prepaid balances and auto-recharge or auto-reload amounts modest. Anthropic notes that auto-reload settings affect how much a leaked key can spend [A4].
Who do I report it to?
- OpenAI: contact OpenAI through help.openai.com so they can investigate [O2].
- Anthropic: if suspicious activity continues, contact Anthropic Support [A2].
- Include the key IDs, the time window, when you revoked the key, and the usage you don't recognise.
- Never paste the key itself into a support ticket [A4].
How do I stop it happening again?
- One key per app or tool, so you can revoke one without breaking the rest. Anthropic recommends separate keys for different purposes so you can 'quickly disable just that use case' [A4]; OpenAI recommends a unique key for each team member [O2].
- Expiring keys: OpenAI project keys can have an expiration date [O2], and Anthropic lets you choose an expiration when you create a key, from 3 hours to 30 days or a custom period (or 'Never') [A3].
- Never put a key in client-side code (browsers, mobile apps) or in a repository. Use environment variables or a secrets manager [O2] [A4].
- Restrict network access where you can. OpenAI offers IP allowlisting [O2].
- Be careful with third-party tools. Anthropic points out that giving your key to a tool gives that tool's developer access to your account [A4].
Where does a spending-cap proxy fit?
Provider limits are monthly. For tighter limits per run or per day, you can send requests through a proxy that checks a budget before forwarding each one. That's what CostLatch does (disclosure: CostLatch is my product, and this is its site):
- Per-run, daily and monthly dollar caps for each CostLatch key†, checked before a request is forwarded to OpenAI or Anthropic. Over-cap requests are refused.
- It stops exact repeated identical prompts. It doesn't catch every kind of loop.
- It works with any app or agent that lets you set a custom base URL for the OpenAI Chat Completions API or the Anthropic Messages API.
- What it can't do: it only covers traffic sent through it. A stolen provider key used directly at OpenAI or Anthropic bypasses any proxy, so keep the provider's own spend limit on.
- Key storage: "Your provider key is encrypted with AES-256-GCM before it's stored, and it's only decrypted in memory to forward your request." "Like any proxy, CostLatch has to decrypt your key to use it, so it isn't zero-knowledge: you're trusting me as the operator and Cloudflare as our host. That's why I recommend a dedicated, revocable key." "Create a dedicated OpenAI project key or Anthropic workspace key just for CostLatch, keep the provider's own spend limit on, and you can revoke it at the provider any time."
- Pricing: Solo is US$19/month after a 7-day free trial (card required). Pro is US$39/month. Both renew monthly until cancelled, and tax may apply.
FAQ
Does revoking a key stop charges immediately?
Revoking (OpenAI) or deleting or disabling (Anthropic) is how both providers say to stop a compromised key, and new requests using it should then be rejected. Usage made before that can still appear on your usage page and be billed afterwards, so check again later.
Is a spend limit enough on its own?
It's the most important backstop, but it's monthly. OpenAI says enforcement isn't instantaneous, so spend can slightly exceed it [O1]. Pair it with one key per app, expiring keys and keeping keys out of client code.
Will OpenAI or Anthropic refund unauthorized usage?
The pages cited here don't promise a refund. Contact the provider's support with your evidence (key name or ID, time window and unrecognised usage, but never the key itself) and ask.
Can a proxy like CostLatch stop a stolen key?
Only for traffic that goes through it. A stolen provider key used directly bypasses any proxy. A proxy adds per-run and daily caps for your own apps and agents on top of the provider's limit.
Do I need a separate key for each tool?
It's good practice, and Anthropic recommends separate keys for different purposes [A4]. If one tool or app leaks a key, you revoke just that key and the rest keep working.
†CostLatch checks your budget before forwarding each request. Spend can still slightly exceed a cap, for example from requests already in progress or running at the same time, or where our cost estimate differs from the provider's final charge. Keep your provider's own limits on too. See our Terms (cl 3.3).
CostLatch is not affiliated with or endorsed by OpenAI or Anthropic. OpenAI and Anthropic are trademarks of their respective owners.
General information, not security or legal advice. Provider steps were checked against the linked pages on 19 Oct 2026 and can change.