Playbooks · Coding tasks
Stop an agent running up a bill
Written October 28, 2026 · Edited November 8, 2026
For a solo builder × API spending caps × the OpenAI and Anthropic consoles, ending with a hard limit that stops traffic, an alert that warns before it, and one container per experiment so a runaway job can only spend its own budget.
Before you start
You need an API account on at least one vendor, and the permission to change its settings: on OpenAI, an organization or project owner; on Anthropic, access to the Console billing settings. The distinction that decides whether any of this works is the difference between an alert and a limit. On OpenAI, a spend alert sends a notification and traffic continues; a hard spend limit makes requests fail with a 429 error once tracked spend reaches the amount. The two controls live in the same place and look alike, and the alert on its own stops nothing. On Anthropic, the same split exists in different clothes: your usage tier carries a monthly spend cap you did not choose, and below it you can set your own limit, which stops traffic with a different error.
Know your tier cap before you set your own number. Anthropic's rate limits page lists the monthly spend cap for each tier: $500 on Start, $1,000 on Build, $200,000 on Scale, and none on Custom. Your own limit cannot exceed your tier's cap. OpenAI separately assigns an approved monthly usage limit based on usage tier; that limit is separate from the spend limits you configure, and it has its own error code when reached. A runaway job meets whichever ceiling is lowest first, so set your own number below all of them.
One honest caveat: enforcement is not instant on either vendor. OpenAI's guide states that recorded spend can slightly exceed the configured amount while the limit state propagates. Anthropic's tier cap pauses usage until 00:00 UTC on the first day of the next month. A hard limit is a ceiling with a small lag, not a wall: the certain stop is a prepaid balance at $0 with auto-reload off, and this playbook uses both.
What "done" looks like
At the end of one sitting you have a hard limit set at the organization level and on the project or workspace doing the work, an alert set below the limit, auto-reload off or capped on any prepaid balance, and each experiment in its own project or workspace with its own key. You have also seen the usage page move after a small job, so you know where to look when a job goes quiet.
Steps
- Find your tier cap and your current spend. On Anthropic, open the Rate limits page in the Console to see your tier and its cap, and the Billing page to see spend so far this month. On OpenAI, open Organization limits and the usage page. Write both numbers down: the cap you did not choose, and the spend already incurred. A limit set without knowing current spend is a guess, and a guess set above spend already incurred does nothing until next month.
- Set the hard limit on OpenAI, with the switch on. On the Organization limits page, in Spend, select Edit spend limit, enter a monthly spend limit, and turn on Enforce a hard limit before saving. Without that switch, the number is only an alert. Do the same on the project that will run the job: a project hard limit applies only to traffic billed to that project, and reaching it returns a 429 with the
project_spend_limit_exceededcode, while the organization limit returnsorganization_spend_limit_exceeded. Set the project limit lower than the organization limit, so one project cannot spend the whole organization's budget. - Set your own limit on Anthropic, below the tier cap. In the Console, go to the Billing page, open the Spend limits section, and set a limit below your tier's cap. When usage reaches a limit you set, requests return HTTP 400 with the message starting "You have reached your specified API usage limits." That 400 is easy to mistake for an ordinary error, so note it now: a 429 with no retry-after header and the code
enforced_spend_limit_reachedmeans the tier cap; a 400 with that message means your own limit. The fix for the first is a tier increase or waiting for the 1st; the fix for the second is raising or removing the limit you set. - Give each experiment its own container and key. On OpenAI, a project; on Anthropic, a workspace you created — spend limits cannot be set on the Default workspace, so a key living there answers only to the organization-wide limit. Set a spend limit on each workspace, sized at two to three times that experiment's normal month. One key per container: if a key leaks or a job runs away, you revoke one key and the other work keeps running, and the usage page shows exactly which container spent the money.
- Set an alert below the limit, and turn auto-reload off. Add a spend alert at about half your normal month, so unusual use reaches you while there is still time to act. On a prepaid OpenAI balance, turn auto-reload off, or set a low monthly reload cap: with auto-reload on and uncapped, a runaway job refills the balance as fast as it spends it, and the hard limit's small enforcement lag is the only thing standing between the job and the card. With auto-reload off, the worst case is roughly the credit bought plus the lag.
- Run a small job and watch the usage page move. Send one real request from the new key, then open the usage page and confirm the spend appears under the right project or workspace. This is the step that catches the two silent failures: a key living in the Default container, and a limit set on the wrong project. If the spend appears under the wrong container, move the key before running anything larger.
- Write down what each failure looks like, where you will see it. Keep a short note with the job: the 429 codes for the limits you set, the 400 message for a self-set Anthropic limit, and the usage page address. When a job goes quiet mid-month, the note tells you in one look whether a limit fired or the code broke. A limit that fires without anyone recognizing it gets raised in a panic and reopens the tap for whatever caused the spike — including a leaked key, which is revoked first, before any limit is raised.
Check the agent's work
- Check that the OpenAI hard-limit switch is on, not just the number entered. The settings page shows both; the number without the switch is an alert.
- Check that the Anthropic limit you set is below the tier cap, and that it sits on the Billing page or a named workspace — not the Default workspace, which takes no limit of its own.
- Check that each experiment's key lives in its own project or workspace, and that the usage page attributes a test request to the right container.
- Check that an alert exists below the limit, and that auto-reload is off or capped on any prepaid balance.
- Check that the failure note names the error code or message for each limit, so a quiet job is diagnosed in one look.
What can go wrong
- Setting an alert and calling it a cap. The alert notifies; traffic continues. Every vendor's documentation draws this line, and every runaway-bill story crosses it.
- Setting the limit on the wrong container. A limit on the organization while the job runs in a project with no limit, or a key in the Default workspace on Anthropic, leaves the job uncapped where it actually runs.
- Raising a limit before revoking a leaked key. If the spike is not yours, raising the limit reopens the tap for whoever holds the key. Revoke first, then raise.
- Treating the tier cap as a budget. The tier cap is the vendor's ceiling, not your budget. A Start-tier account can spend $500 in a month without anything stopping it until the cap. Your own limit is the budget; the cap is the backstop.
- Assuming enforcement is instant. Both vendors state spend can slightly exceed a new limit while it propagates. Size the limit with that lag in mind, and keep the prepaid balance small.
Limits
- This playbook caps API spend at the vendor. Subscription usage pools — Claude Pro or Max, ChatGPT Plus or Pro — have their own usage windows and are not capped by these settings.
- Rate limits are separate from spend limits. A job can be stopped by requests-per-minute limits long before it nears a spend limit, and a spend limit does nothing about a job that is slow rather than expensive.
- On Anthropic's Claude Platform on AWS billing, spend limits are available: the tier cap applies, and you can set your own monthly organization limit in Settings > Billing and per-workspace limits on the Workspaces page, after adding at least one email recipient under Email recipients on the Billing page. Spend is calculated at list prices and can take about 2 hours to reflect recent use, so usage can exceed a cap or limit before requests fail, and the overshoot is billed.
Related playbooks
- Baseten Sandboxes keep agents running for days
- Check your first DeepSeek search/fetch bill
- Stop fork subagents inheriting your context
- Claude Code 2.1.319: unattended runs stop stalling
Sources
Sources: OpenAI spend limits guide, Anthropic rate limits, Managing projects in the API platform — OpenAI help article, Claude Platform on AWS — Anthropic docs.
Back to: Coding playbooks hub · Also: Pick the cheapest model for the job · Token cost calculator