How to set a spending limit for an AI agent: API keys, cards and daily budgets
Cap what an AI agent spends on models, cards, x402 and paid tools. Seven spending limits compared by scope, interval and whether they block or only alert.
CrabTalk Team
An AI agent spends money in two places: the model it runs on, and the tools, APIs and purchases it pays for. Each has its own spending limit, set in a different place, with a different scope and reset interval, and some of them only send an alert. This post compares seven spending limits for AI agents, from model API keys to virtual cards and x402 wallets, and shows what a limit needs to stop an agent rather than report on it afterwards.
What a spending limit for an agent needs
When people ask for one, they describe the same shape. Under a Launch HN for an agent payments MCP, a commenter asked for a "Payment Key" with daily, weekly and lifetime limits, "like an OpenRouter key". Another put the reason plainly: "If you can't undo a transaction, all the safety has to happen before it executes."
That gives four properties to check in any limit:
- Per agent. One limit for each agent, so a runaway agent spends its own allowance and revoking it leaves the others running.
- Per day. A loop can spend a month's budget in an afternoon. A daily limit bounds the worst day; a monthly one bounds only the bill.
- Blocks before. The request is refused before the money moves. An alert arrives after it has.
- Per seller. The agent pays only the services a person approved. An agent can be talked into paying someone by text it read, and an amount limit alone doesn't stop that.
Model API spend limits
| Provider | Scope | Interval | At the limit |
|---|---|---|---|
| Anthropic | Organization or workspace | Month | Requests fail |
| OpenAI | Organization or project | Month | Alert, unless a hard limit is on |
| OpenRouter | API key | Day, week, month or none | The key's remaining limit reaches zero |
Anthropic. "Spend limits set a maximum monthly cost an organization can incur for API usage" (rate limits). You can set your own below your tier's cap, and per workspace. When usage reaches it, "requests return HTTP 400 with error type invalid_request_error". The limit is monthly and applies to the organization or workspace, not to a single key, so give each agent its own workspace if it needs its own limit.
OpenAI. "Monthly API spend limits are available at both the organization and project levels" (projects). By default "A spend limit can monitor spending without stopping requests"; turn on Enforce a hard limit for requests to fail. Even then "Enforcement isn't instantaneous, so recorded spending can slightly exceed the configured amount."
OpenRouter. A key takes an optional limit, "spending limit for the API key in USD", and a limit_reset of daily, weekly, monthly or none; resets happen "at midnight UTC" (create API key). It's the one model limit here that is per key and per day.
Card spending limits
A card is how an agent pays a merchant who takes cards. Card fees, 2.9% + 30¢ for a US card on Stripe, make it suited to purchases, not to one-cent tool calls.
Privacy.com. "Each card can have its own adjustable spend limit", on "a per transaction, per month, per year, or total recurring schedule", and "If a transaction goes over your limit, it's instantly declined" (spend limits). Cards "lock to a single merchant" by default (Privacy), which makes one card per seller the default.
Stripe Issuing. For a business issuing its own cards, spending controls set limits per card or per cardholder, per authorization, day, week, month, year or all time, and allow or block merchant categories. They "run before real-time authorizations and can decline a purchase", but "Spending aggregation is done on a best-effort basis", and later tips and fees can take a card past its limit.
x402 client spending limits
With x402, a server answers 402 and the client pays in stablecoins, so the limit lives in the client.
Coinbase. The CDP x402 client takes spendControls: maxAmountPerPayment, and maxCumulativeSpend over a maxCumulativeSpendWindow such as "24h". "Blocked payments throw SpendControlError", and "Spend is reserved before paying, then confirmed or rolled back once settlement is known" (client configuration). The TypeScript client has them; the page says the Python SDK doesn't yet.
Cloudflare. The Agents SDK's x402 client takes a confirmation callback on each paid tool call, "Your human-in-the-loop confirmation flow"; set it to null "for the agent to pay automatically" (pay from Agents SDK). The callback is yours to write, and so is any amount limit in it.
Comparing the seven
| Limit | Per agent | Per day | Blocks before | Per seller |
|---|---|---|---|---|
| Anthropic spend limit | One workspace each | No, monthly | Yes | No |
| OpenAI project limit | One project each | No, monthly | Only with a hard limit | No |
| OpenRouter key limit | Yes | Yes | See its docs | No |
| Privacy.com card | One card each | No; per transaction, month or year | Yes | Locks to one merchant |
| Stripe Issuing card | One card each | Yes | Yes, best effort | By merchant category |
| Coinbase x402 client | One client each | Any window | Yes | No |
| Cloudflare x402 callback | Your code | Your code | Your code | Your code |
No single limit covers both places an agent spends. Model spend and payments are set apart, and each needs its own.
A spending limit for paid tool calls on CrabTalk
When an agent calls priced tools on CrabTalk, the limit sits on the API key it calls with. An MCP connection that signs in with OAuth gets a dedicated key of its own.
crab key create research-agent
crab key budget <key> 20
crab key grant <key> acme/enrich- Per key, per day. A key spends at most its budget on tool prices in a UTC day, $5 unless an owner sets another. Calls in flight count. A call past it is refused with E0010 before it runs.
- Per seller. A key calls another account's priced service only once an owner grants it. The first call is refused with E0009.
- Asking for more. Each refusal links to a grant request page the agent hands to a person, who approves the service or a higher budget once. An agent can ask ahead with
crab key ask --service acme/enrich --budget 20. - Failures are free. The price is held before the call and kept only when the tool succeeds. A failure, a refusal or a timeout returns it.
Connecting through MCP with OAuth shows the budget on the approval page before the key is issued; see MCP. Every setting is in Keys. Pricing your own tools is covered in How to charge for MCP tool calls.