Use case
How to set one monthly budget across OpenAI and Anthropic
The short answer: OpenAI's and Anthropic's own limits each see only their own traffic, so neither can enforce one company-wide total. To do that, send both providers' traffic through one layer that adds up spend and checks it before each call. LiteLLM does this for free if you run it yourself. Cloudflare AI Gateway does it for free if you're happy with a beta feature. Spendline does it as a hosted service and adds customer-level budgets. Whichever you pick, keep the native limits on as a backstop.
Your options
We make Spendline, so read this with that in mind. Facts about other products come from their own docs, checked on November 4, 2026.
| Option | One cap across both providers? | What happens at the cap | Documented overshoot | Who runs it | Published cost |
|---|---|---|---|---|---|
| OpenAI and Anthropic native limits | No. Two separate caps | OpenAI returns a 429. Anthropic returns a 400 with an invalid_request_error |
OpenAI says enforcement isn't instantaneous, so spend can slightly exceed the limit | The provider | Free |
| LiteLLM | Yes. A proxy-wide budget covers all calls | The call is rejected before it reaches the provider | Reserves estimated cost by default to handle concurrent calls. Batch jobs can't be fully reserved | You, with a database | Free and open source |
| Cloudflare AI Gateway | Yes. A rule with no provider dimension tracks all providers together | 429, or fallback to a cheaper model you've set up | Bursts of concurrent calls can briefly exceed the limit. Cost is a best-effort estimate | Cloudflare. Spend limits are in beta | Core features free |
| Portkey, now Prisma AIRS AI Gateway | Yes, with a workspace usage policy. The docs list these for Enterprise Self Hosting only | Further requests are rejected | Not described | Palo Alto Networks, or you if self-hosted | Enterprise pricing is quoted. Budget limits on a single provider are for Enterprise and select Pro customers |
| Spendline | Yes. One org or team budget covers every routed provider | The call is refused with a 402 before it reaches the provider. It doesn't switch to a cheaper model | Reserves in-flight spend, but the check uses an estimate and a response that has started isn't cut off, so one long call can settle above the cap | Spendline, hosted | Guided 30-day free pilot. Paid terms agreed before you start |
Which to pick:
- You only need a company-wide cap and you're happy to run a service: LiteLLM.
- You only need a company-wide cap and want nothing to host: Cloudflare AI Gateway, once you're comfortable with the beta label.
- You already use Portkey on an enterprise plan: ask for a workspace usage policy.
- You also need budgets per customer, agent and team, with no gateway to run: Spendline is built for that case.
How to set it up, step by step
Step 1. List every place your software calls OpenAI or Anthropic. Include batch jobs, cron scripts, internal tools and retry paths. A cap only covers traffic that goes through it, so this list decides how much the cap is worth.
Step 2. Turn on both native limits first. They protect you from anything you missed in step 1. In OpenAI, set a monthly spend limit and turn on "Enforce a hard limit". In Anthropic, set your own limit on the Billing page, below your tier's cap. Set each one near your full company budget rather than splitting it. If you split it, one provider can stop while the other still has room.
Step 3. Pick your layer from the table above.
Step 4. Point one workflow at it. Change the base URL for that workflow and test it. Move the rest one at a time. Note the exact settings for your option below.
Step 5. Set one monthly dollar budget at the widest level.
- LiteLLM: set
max_budgetandbudget_duration: 30dunderlitellm_settings. A 30-day duration resets on the 1st of each month. It needs a database: without one the budget isn't enforced at all, and requests keep flowing past the limit. - Cloudflare AI Gateway: open your gateway, go to Settings, then Spend limits. Add a rule with no provider or model dimension and a monthly window. Each gateway allows up to 20 rules.
- Spendline: ask an owner or admin to add a strict org or team budget. Spendline checks every routed provider against it before forwarding each supported request.
Step 6. Add alerts below the cap. A cap that fires with no warning stops your product with no warning. Spendline sends threshold alerts at 50, 80, 90, 100 and 120% to a Slack or Discord webhook. LiteLLM and Cloudflare have their own options, so check their docs.
Step 7. Decide what your app does at the cap. Each option answers with a different error, so handle it on purpose. Show a clear message or queue the work. Don't retry directly against the provider. That skips the cap and leaves the spend unrecorded.
Step 8. Test it with a small limit in a test environment. Send calls through both providers until the next one is refused. Check that both providers' spend counted toward the same total and that your app handled the refusal.
Step 9. Close the side doors. Compare your layer's monthly total with both provider invoices. A gap usually means traffic is still going direct. Move those paths over or accept them knowingly.
What the Spendline version looks like
This example is illustrative, not a real customer. A team named support-ai has one strict monthly budget of $6,000.
| Provider | Spend so far |
|---|---|
| OpenAI | $3,000 |
| Anthropic | $2,000 |
| Total against the $6,000 budget | $5,000 |
A budget belongs to a scope (org, team, agent or customer), not to a provider. You can still split the total by provider for reporting, because each call is recorded with its provider and model. Supported routes are chat completions for OpenAI-compatible providers, Anthropic Messages and non-streaming OpenAI Responses. Embeddings, images and audio aren't supported, so those calls fall outside the cap. Details are in the integration guide.
What to know before relying on any of these
- Direct calls aren't capped. That includes any fallback that calls a provider directly when the layer is down.
- A check before the call works from an estimate or from recorded spend. Final cost can land above the limit on every option here.
- You're adding a step to each call. Decide per workflow whether to keep serving if that step fails, or stop.
Frequently asked questions
Can OpenAI or Anthropic enforce one budget across both?
No. Each limit only sees that provider's own traffic. A shared budget has to sit somewhere both providers' traffic passes through.
What's the cheapest way to do this?
LiteLLM and Cloudflare AI Gateway both have free options. LiteLLM needs you to run the proxy and a database. Cloudflare's spend limits are in beta.
Do I still need native limits?
Yes. They're your backstop for traffic that doesn't go through your cap, and they cost nothing.
Can I also cap one customer or one agent?
Yes, on most of these. LiteLLM has customer budgets and Cloudflare can split a rule by a customer ID you send. Spendline nests budgets by org, team, agent and customer, and checks each of them before the call. Native limits stop a whole project or workspace.
Can the shared total still be broken down by provider?
Yes in Spendline, where each call is recorded with its provider and model. Cloudflare's analytics also filter by provider. For other tools, check their reports.
See what this would look like in your product.
Start with a guided 30-day free pilot on live production traffic. The 30 days start when your traffic flows through Spendline, not at sign-up. We agree the scope, success criteria and paid terms before you start. There is no Spendline subscription fee during the pilot; your model-provider charges still apply.
Prefer email? fida@spendline.ai