Set a daily spend limit on each API key your agents use
On OpenCheap, every API key can carry its own spend limit: daily, weekly, monthly or lifetime, in UTC windows. Set it to hard_stop and the key's requests are refused with a 402 once the limit is reached, so a coding agent left running overnight stops at the amount you chose instead of draining your balance. An email goes out at 80 % of the limit. One key covers every model, so the cap holds whichever model the agent switches to.
Cap an agent in three steps
- 1Give the agent its own keyOne key per agent, project or customer, so each one's spend is counted and capped on its own.
- 2Set the limitIn the console under API keys, by asking your agent over MCP, or with the Management API:
daily,weekly,monthlyandlifetime, at least one. - 3Choose what happens at the limit
hard_stoprefuses the key's requests with a 402 until the window resets;alert_onlyonly emails. Both email once per limit and window atalertPct(80 by default, 0 for none).
From code, or from your agent
# A daily cap of $5 and a monthly cap of $50 on one key, refusing requests at the limit
curl -s -X PUT https://app.opencheap.si/api/v1/keys/$KEY_ID/budget \
-H "Authorization: Bearer $OPENCHEAP_API_KEY" -H "Content-Type: application/json" \
-d '{ "limits": { "daily": 5, "monthly": 50 }, "alertPct": 80, "mode": "hard_stop" }'
# → { "scope": "key", "limits": { "daily": 5, "weekly": null, "monthly": 50, "lifetime": null }, "status": "ok",
# "windows": [ { "window": "daily", "limitUsd": 5, "spentUsd": 1.27, "resetsAt": "…T00:00:00Z" }, … ] }You: Make a key for my coding agent with a $5 daily limit that stops at the limit.
Agent: create_key → set_key_budget { daily: 5, mode: "hard_stop" }
Done: key "coding-agent", $5 a day, resets 00:00 UTC.Every endpoint, including the account budget and GET /budgets with each limit's spend this window, is in the Management API docs; connecting an agent over MCP is in the MCP docs.
Spend limits elsewhere
From each one's own docs, as of November 14, 2026.
| Per key? | Windows | At the limit | |
|---|---|---|---|
| OpenCheap | Yes, and per account | Daily, weekly, monthly, lifetime | 402 (hard_stop), or an email only (alert_only) |
| OpenAI | No: per organization and per project | Monthly | Hard limits return 429, not instantly; alerts only notify |
| Anthropic | No: per organization and per workspace | Monthly | Requests are refused until the month resets or the limit is raised |
| LiteLLM | Yes: max_budget on a virtual key | Any budget_duration, such as 1d or 30d | Requests rejected; you run the proxy and its Postgres database yourself |
Questions, answered
How do I set a daily spend limit on an API key?
On OpenCheap, give the key a budget: in the console under API keys, from your agent over MCP, or with PUT https://app.opencheap.si/api/v1/keys/{id}/budget and { "limits": { "daily": 5 }, "mode": "hard_stop" }. At the limit the key's requests are refused with a 402 until the day resets at 00:00 UTC.
Can each key have its own limit?
Yes. Every key can carry its own daily, weekly, monthly and lifetime limits, and the whole account can have one too. Give each agent, project or customer its own key and its own cap.
Does the limit block requests or only send an alert?
Your choice per budget: hard_stop refuses the key's requests with a 402 at a limit, alert_only never blocks. Both send one email per limit and window when spending crosses the alert share, 80 % by default.
When do the limits reset?
In UTC windows: daily at 00:00 UTC, weekly on Monday, monthly on the first. A lifetime limit counts from when it was set and never resets.
Does OpenAI or Anthropic have per-key spend limits?
Not per key, from their docs as of November 14, 2026: OpenAI sets monthly limits per organization and per project, and Anthropic monthly limits per organization and per workspace. A key on OpenCheap carries its own daily limit, across every model it calls.
Does the limit cover every model?
Yes. A budget counts the key's spend at our price on every model it calls, Claude, GPT, Gemini and open models alike, so one cap covers an agent that switches models.
More guides
OpenCheap is an LLM router that sends every request to the cheapest healthy provider of the model you name, fails over to the next one before the first byte, and bills you that provider's price.
One OpenCheap key calls models from Anthropic, Google, OpenAI, DeepSeek, Moonshot, Qwen and more through the OpenAI SDK you already use: change the base URL and the key.
An AI agent can pay OpenCheap for one completion in USDC on Base with x402: call with no key, read the 402 price, sign, and get the answer in the same request.
Point Claude Code at OpenCheap with three environment variables and pick the model per task: Claude at the provider's price, or open models that cost a fraction of it, all on one key with a spend limit.