Leaked API keys

Get warned when a leaked API key starts spending, and switch it off

Costbrake checks your API spend every 5 minutes on Pro and alerts you when an hour runs past 3 times its usual spend and at least $5 over it, including the hour still in progress. The alert follows the spend, so it fires whether the key leaked through a public repo, a log file or a shared laptop.

An admin can then switch off that exact key on Anthropic, OpenRouter, xAI, ElevenLabs or AWS, or freeze the OpenAI project at a $0.01 hard limit. A brake only runs when an admin clicks it and confirms.

How a leaked key shows up in Costbrake

Costbrake can't see a key being copied. It sees what the key costs, read from each provider's own usage API, and three alerts catch the usual pattern of a stolen key:

  • Spike: on for every connection from the start. An hour that costs more than 3 times the usual hourly spend of the past 7 days, and at least $5 more, raises an alert. At 10 times it is critical.
  • New charge (Pro and Team): the first $1 from a model or project with no recent spend, once a connection has a week of data. That catches a key being used for a model you never call.
  • Budget: alerts at 50, 80 and 100 percent of a monthly budget, on every plan.

After a spike the connection stays on fast checks for 2 hours: every minute for Anthropic and OpenRouter, every 2 minutes for OpenAI, xAI and ElevenLabs. The alert goes to email, Slack, Discord, a webhook or PagerDuty, depending on your plan.

Which providers let Costbrake switch off a single key

Five providers have a key-level brake. OpenAI does not let Costbrake switch off a key, so its brake freezes the project the key belongs to.

ProviderBrakeWhat stopsUndo
AnthropicDisable API keyEvery request made with that key fails right awaySets the key back to active
AnthropicDisable workspace keysEvery active key in the workspace, up to 60 per brake; organization-wide keys keep workingTurns back on exactly the keys it switched off
OpenRouterDisable API keyEvery request made with that key fails right awayEnables the key again
xAIDisable API keyRequests with the key are rejected once the change reaches xAI's API serversEnables the key again
ElevenLabsDisable API keyEvery request made with that service account key failsRe-enables the key with its settings unchanged
AWSDeactivate IAM access keyEvery request signed with the key fails within seconds; the key is not deletedMarks the key Active again
OpenAIFreeze projectPaid requests in that project fail with 429 project_spend_limit_exceeded once OpenAI enforces the $0.01 limit, usually within minutesRestores the project's previous spend limit

Every brake is a click by an admin. The killswitch is off until an admin turns it on for a connection, each brake asks for the connection's label before it runs, and the request is written to the audit log first. Workspace members cannot brake; admins and owners can. Each brake and its caveats are on the Anthropic, OpenRouter, xAI, ElevenLabs, OpenAI and AWS pages.

Brake first, then rotate the key

A disabled key stops the bill but it is still the leaked key. GitHub's advice for an exposed secret is to rotate the affected credential immediately, and AWS suggests generating credential reports to audit the access keys of every IAM identity after a suspected compromise. Our guide to the first hour after a leaked API key walks through the full cleanup per provider.

Preventing the leak is a separate job. GitHub push protection blocks pushes that contain secrets before they reach your repository, and when secret scanning finds a partner's secret, GitHub notifies the provider so they can take action, such as revoking it. Costbrake covers the case where a key got out anyway. For a leaked AWS access key, follow what to do when an AWS access key leaks, and for a Gemini key Google reported as leaked, the Gemini leaked key guide. If the bill comes from a traffic flood instead, see denial of wallet protection.

Where the alert can be late

  • Provider lag: OpenAI usage lags a few minutes and Anthropic arrives within about 5 minutes. Costbrake can only alert on what the provider has reported.
  • AWS: with the CloudWatch permission, Costbrake has estimates every few minutes for Lambda, Bedrock, NAT gateway and GPU spend. Everything else comes from Cost Explorer, which can be up to 24 hours behind.
  • Google Cloud: the billing export usually runs a few hours behind; live estimates cover the Gemini API, Vertex AI, Cloud Run and Cloud Run functions.
  • Free plan: checks run every hour and there are no brakes. Pro and Team check every 5 minutes and include the brakes.

Pro is $12 a month for 10 accounts, and every new workspace starts on a 14-day Pro trial with no card. See pricing for all limits.

Questions and answers

How fast will I know if my API key leaks?

Costbrake can't see the leak itself, only the spend. On Pro it checks every 5 minutes and looks at the hour in progress, so once the provider reports the usage, an hour past 3 times your usual spend and at least $5 over it triggers an alert. OpenAI usage lags a few minutes and Anthropic about 5 minutes. On Free, checks run every hour.

Can Costbrake disable a leaked OpenAI API key?

Not the key itself. The OpenAI brake sets the project's monthly hard spend limit to $0.01, and once OpenAI enforces it, usually within minutes, every paid request in that project fails with 429 project_spend_limit_exceeded. Other projects keep working, and undo restores the previous limit.

Does Costbrake scan GitHub for leaked keys?

No. Costbrake watches what your keys cost, not your code. GitHub push protection blocks pushes that contain secrets, and GitHub secret scanning notifies partner providers when it finds their secret so they can revoke it. Costbrake catches a leaked key that slipped past both once it starts spending.

Does Costbrake switch off a key without me?

No. Alerts go out on their own, but a brake only runs when an admin clicks it and types the connection's label to confirm. Workspace members cannot use brakes; admins and owners can.

Which Costbrake plan includes the key brake?

Pro and Team. Pro is $12 a month or $120 a year for 10 accounts with 5-minute checks; Team is $39 a month or $390 a year for 50 accounts. Every new workspace gets a 14-day Pro trial with no card, so the brake works from the first day. Free gives alerts on 2 accounts with hourly checks, without brakes.

Sources

Updated

Start with 14 days of Pro, free

Catch the next spike before the invoice.

14 days of Pro, then Free for 2 accounts. No card needed.