Guide · Keys

Your AI API key leaked. Here's what to do now.

If someone else is spending on your OpenAI, Anthropic or OpenRouter key, the rule is simple: stop the spend first, investigate second. This guide walks through each provider's official steps, in order.

Published

1. First 5 minutes: stop the spend

Cut off the key before you work out how it leaked. Whatever still depends on it will break, and that's the right trade-off while you're under attack.

OpenAI: delete the project API key (permanent)

In the OpenAI platform, open the project that owns the key, go to its API keys page, and delete the compromised key. To do it programmatically, an organization Admin API key can call DELETE /v1/organization/projects/{project_id}/api_keys/{api_key_id}. That endpoint returns an error if the key belongs to a service account. [1]

Deletion can't be undone. Create a replacement key, then move your apps over to it.

If you can't find the key right away, turn on a hard spend limit for the project or the organization (see Section 4) to stop traffic while you look. [2]

Anthropic: disable the key (reversible)

In the Claude Console, go to API keys (platform.claude.com/settings/keys) and choose Disable on the key. Anthropic says Disable is reversible: the key shows as inactive, and Re-enable brings it back. Delete is permanent; the key is archived. [3]

To do it programmatically, an Admin API key can call POST /v1/organizations/api_keys/{api_key_id} with {"status": "inactive"}. [4] The Admin API is only available on organizations, not individual accounts. [5]

OpenRouter: disable the key (reversible)

In OpenRouter's security settings, open the Key safety tab, find the key, and choose Disable. OpenRouter says disabling is reversible and archiving is permanent; archiving asks you to type archive to confirm. [6]

To do it programmatically, a Management API key can call PATCH /api/v1/keys/{hash} with {"disabled": true}. [7]

2. Check the damage

Find which key was used

Line up your provider's usage data with the key you just disabled. On OpenRouter, each key reports usage_daily, usage_weekly and usage_monthly in USD. [7] On OpenAI, each project key records a last_used_at timestamp. [8]

Pick the date range

Start from the earliest point the key could have been exposed. That might be a breach date a third-party tool has disclosed, or the date the key was committed to code. Check every day from then until now, not just today.

Find every copy

Search your repos (including old ones), CI secrets, .env files, and every third-party tool you pasted the key into. Rotate any key whose location you can't account for.

3. Contact support about the unauthorized usage

Write to the provider's support team with:

  • the key's ID or name (never the secret itself)
  • a timeline: when it was exposed, when you noticed, and when you disabled it
  • the usage you believe wasn't yours, and why

None of these providers publishes a guaranteed refund policy for leaked keys, so treat a refund as possible, not promised.

4. Why a spend limit may not stop every dollar

  • OpenAI supports monthly hard spend limits per organization and per project. When one is hit, requests return a 429 error with organization_spend_limit_exceeded or project_spend_limit_exceeded. OpenAI notes that "enforcement is not instantaneous, so recorded spend can slightly exceed the configured amount." Spend alerts only notify you; they don't stop traffic. [2]
  • OpenRouter lets you set a credit limit on each key, with an optional daily, weekly or monthly reset. Once a key uses up its limit, its requests are rejected. OpenRouter recommends a limit on every key and warns that a key with no limit can spend your entire balance, including auto top-ups. [9][7]
  • Anthropic offers key expiration at creation time, with presets from 3 hours to 30 days, a custom duration, or Never. Expiration can't be changed later. [3]

A monthly limit caps the worst case. It doesn't tell you that a key that normally spends a little is suddenly spending a lot.

5. Make sure it doesn't happen again

One key per tool or agent

When every tool and agent has its own key, a leak or a loop is limited to that one key, and you know exactly which one to turn off.

Cap each key

Use the provider's own controls: OpenAI project hard limits, OpenRouter per-key limits, and Anthropic key expirations. OpenRouter's security settings flag keys with no spend limit or no expiry. [6]

Add a spike rule

Alongside the cap, watch the rate. If a key's spend over the last M minutes is more than N times its recent baseline, something is looping or someone else is using it.

Decide your kill action in advance

Agree on it while it's daytime: OpenAI, delete (permanent). Anthropic, disable (reversible). OpenRouter, disable (reversible).

6. Automating it with BillCurfew

BillCurfew watches per-key spend without sitting in your request path:

  • No proxy, no code change. Paste an OpenAI organization admin key, an Anthropic org admin key, or an OpenRouter management key. Requests still go straight to the provider.
  • No prompt access. We read usage and dollars, never the conversation.
  • A daily dollar cap and a spike rule for each key. Alerts go by email (and by Slack on paid plans) on a poll every five minutes or so.
  • Optional auto-kill. It disables Anthropic and OpenRouter keys (reversible) or deletes OpenAI keys (permanent, and off until you turn it on).

The honest trade-off: we act on the next poll, not the next token. Use BillCurfew together with provider limits, not instead of them.

Plans: Free is $0 for one provider, one key and email alerts, with no card. Solo is $19/month, Team $49/month and Agency $149/month, each with a 14-day trial. See pricing and security.

Start free with one key, no card.

FAQ

Does an OpenAI spend limit stop charges immediately?

No. OpenAI says hard-limit enforcement is not instantaneous, and recorded spend can slightly exceed the limit. Spend alerts only notify you; they don't block requests. [2]

Who pays for usage on a stolen API key?

By default, the usage is billed to the account that owns the key. Contact the provider's support team with a timeline and the key ID. None of the three publishes a guaranteed refund policy.

Can I disable an Anthropic key without deleting it?

Yes. Disable in the Claude Console is reversible; the key shows as inactive and can be re-enabled. Delete is permanent. [3]

Is disabling an OpenRouter key reversible?

Yes. Disabling is reversible and archiving is permanent. [6]

Can I undo deleting an OpenAI key?

No. Deleting a project API key removes it, so you'll need to create a new key. [1]

Do I need a proxy or gateway to cap AI spend?

No. Provider-side limits and admin-API monitoring like BillCurfew's work without routing your prompts through a third party. A proxy can block the very next request; a poller can't. That's the trade-off to weigh.

How do I find out which tool leaked my key?

Check where each copy of the key lives: repos, CI, .env files and third-party tools. Then compare each key's usage timestamps with when you used each tool. Giving every tool its own key makes this a one-step answer next time.

Sources

  1. https://developers.openai.com/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/api_keys/methods/delete [1]
  2. https://developers.openai.com/api/docs/guides/spend-limits [2]
  3. https://platform.claude.com/docs/en/manage-claude/authentication [3]
  4. https://platform.claude.com/docs/en/api/organization/api_keys/update [4]
  5. https://platform.claude.com/docs/en/manage-claude/admin-api [5]
  6. https://openrouter.ai/docs/guides/overview/auth/security-settings [6]
  7. https://openrouter.ai/docs/api/api-reference/api-keys/update-an-api-key [7]
  8. https://developers.openai.com/api/reference/go/resources/admin [8]
  9. https://openrouter.ai/docs/api_reference/authentication [9]