What Anthropic lets you limit
On the Start, Build and Scale usage tiers, a Claude API organization has a monthly spend ceiling of $500, $1,000 and $200,000, and Custom has none. Reaching it pauses usage until 00:00 UTC on the first of the next month, and requests fail with a 429 error coded enforced_spend_limit_reached. That 429 carries no retry-after header.
Under the ceiling, you can set a lower spend limit for the organization and a monthly spend limit for each workspace. Workspaces also take rate limits per model, in requests, input tokens and output tokens a minute. A workspace limit can't be higher than the organization's, and the Default Workspace can't have a spend limit at all. Reaching a limit you set returns a 400 invalid_request_error saying you've reached your specified usage limits.
An API key can be scoped to one workspace and can expire after 3 hours, 1 day, 7 days, 30 days, a custom duration or never. Anthropic fixes that expiry when you create the key. Setting spend limits through the Admin API is a preview you request from Anthropic's account team.
One workspace per key, the native workaround
The closest Anthropic gets to a per-key cap is a workspace per app or agent: give the workspace a monthly spend limit and scope that app's key to it.
It stops at a month. You can't cap an hour or a day, so a runaway agent can burn its whole monthly limit in an afternoon and then stay blocked until you raise the limit or the month turns. Every new agent needs a new workspace, and keys in the Default Workspace can't be capped at all.
The one per-person limit Anthropic offers sits in the Claude Code workspace, the only workspace that supports per-user monthly spend limits. Claude Code mints those keys at sign-in, and you can't create keys there yourself.
How Keylayer caps a Claude key
You add your Anthropic key to Keylayer's vault once and mint Keylayer keys from it. The official Anthropic SDKs read two environment variables, so a client created with no arguments switches over without a code change:
export ANTHROPIC_BASE_URL="https://relay.keylayer.dev"
export ANTHROPIC_API_KEY="$KEYLAYER_KEY"The base URL is the bare host, with no /v1. The relay reads the x-api-key header the SDKs send, passes the anthropic-version and anthropic-beta headers through, and streams arrive as Anthropic sends them.
Before forwarding, Keylayer reserves the request's worst case: about one token per byte of the body, plus max_tokens, which the Messages API requires. Each image adds up to 4,784 tokens, a tool list 1,024, and each of Anthropic's own tools, such as bash or the text editor, 8,192 more. On claude-sonnet-5-5, a short request with max_tokens of 1,024 reserves about $0.012, and one with 64,000 reserves about $0.70 while it runs. Both use Anthropic's US-only rate, 1.1 times the list price, which Keylayer counts unless the request sets inference_geo to global. When the response ends, Keylayer charges the usage Anthropic reports and frees the rest.
A request that would pass a cap gets 403 budget_exceeded in Anthropic's error format, with a retry-after header that says when the period resets. Admin routes under /v1/organizations/** are blocked by default, so a key you hand out can't manage your Anthropic organization. The Anthropic provider page covers what each request reserves.
A Keylayer key next to Anthropic's limits
| Control | Keylayer key | Anthropic |
|---|---|---|
| Spend cap covers | One key, and every key minted from it | The organization or a workspace |
| Spend cap period | A UTC hour, day, week or month, all at once | A calendar month, reset at 00:00 UTC on the 1st |
| Over the cap | 403 budget_exceeded, with retry-after set to the reset | 429 at the tier ceiling, 400 at a limit you set |
| Rate limits | Requests a minute and requests at once, per key | Per organization or workspace and model, in requests and tokens a minute |
| Key expiry | 1 hour by default, up to 365 days | 3 hours to 30 days, a custom duration or never, fixed at creation |
Give each app or agent its own capped Keylayer key, and keep a monthly limit on the Anthropic workspace behind them as a backstop.
Cap a Claude key at $20 a day
- Sign in at keylayer.app with Google and set up your vault with a passkey.
- Add your Anthropic API key as a credential. You paste it into the vault window, and the dashboard never sees it.
- Mint a key. Under Limits, set Spend in dollars to 20, pick A day and choose Hard.
- Set ANTHROPIC_BASE_URL to https://relay.keylayer.dev and ANTHROPIC_API_KEY to the new key.
- Set max_tokens to what each task needs, since every request holds it against the cap until it ends.
The quickstart shows each screen with OpenAI, and Anthropic works the same way.
Questions
Can I set a spend limit on one Claude API key?
Yes, by putting a Keylayer key in front of it: that key carries a dollar cap per UTC hour, day, week or month, checked before each request. The Claude Console only sets spend limits on the organization and on workspaces, per month.
Can I cap Claude API spend per day?
Yes, with Keylayer: a spend cap can run per UTC day, and one key can carry an hourly, daily, weekly and monthly cap at the same time. Anthropic's own limits run per calendar month.
Why was a request refused when the key had money left?
Keylayer counts the worst case first. A claude-sonnet-5-5 request with max_tokens of 64,000 holds about $0.70 of the cap while it runs, however short the answer turns out. Lower max_tokens to what you need and more requests fit under the cap.
Do the Anthropic SDKs work unchanged?
Yes. Point the base URL at https://relay.keylayer.dev, with no /v1, and send the Keylayer key as the API key. Streams and the anthropic-version and anthropic-beta headers pass through as they are.
What does a capped Claude key cost?
Spend caps come with every plan. The free plan covers 10 provider keys and 5,000 requests a day on each, and Pro is $19 a month with no daily request cap. Anthropic still bills you directly, with nothing added per token.