Guides

How to Cap OpenAI, Claude & Cloud API Bills

By ExcenityAI · Published · Updated

To stop an AI or cloud bill running away, turn on a hard spend limit with each AI provider (OpenAI project limits, Anthropic spend limits), add budgets and anomaly alerts on your cloud account, and turn on spend management on your host. Alerts alone do not stop spending, so the hard limits come first and the alerts are your second layer.

What is the difference between an alert and a hard cap?

An alert sends you a message when spending crosses a threshold. A cap refuses further requests. Most cloud billing tools are alerts only. AI providers offer real caps, but they are not instant, so a small overshoot is normal.

Real people do get caught out. In May 2026 The Register reported that Google Cloud and AWS customers had been billed from about $3,000 to over $100,000 after exposed or abused API keys and automatically raised spending tiers, and that a user billed directly by Anthropic was protected by its spending limit. These were individual user reports, and a follow-up covered refunds.

How do you set a hard limit on OpenAI?

OpenAI separates spend alerts from hard spend limits. Alerts notify you and let traffic continue. A hard limit makes affected requests fail with a 429 error once monthly spend reaches it.

  1. Create one OpenAI project per app so each has its own limit.
  2. For the whole organization: open the Organization limits page, choose Spend, then Edit spend limit, enter a monthly amount and turn on Enforce a hard limit.
  3. For one app: open that project's settings, go to Limits, then Spend, and repeat the same steps.
  4. Handle the error in your app. A project limit returns project_spend_limit_exceeded and an organization limit returns organization_spend_limit_exceeded.

OpenAI notes that enforcement is not instantaneous, so recorded spend can slightly exceed the amount you set. Pick a limit below what you can afford.

How do you set a spend limit on Anthropic (Claude)?

In the Claude Console, open the Billing page and find Spend limits. Click Set limit (or Adjust limit) and enter an amount. Your limit cannot exceed your usage tier's monthly cap.

  • Use a separate workspace for each app and set a workspace spend limit. Spend limits cannot be set on the default workspace.
  • When a limit you set is reached, requests return an HTTP 400 invalid_request_error that says when access resumes. Retrying will not help until you raise the limit or the month rolls over.
  • Organization-wide limits always apply, even if workspace limits add up to more.

Spend limits are separate from rate limits, which cap requests and tokens per minute and protect against bursts rather than monthly cost.

What can you do on AWS?

Use two tools together. AWS Budgets lets you set a monthly cost budget with alerts on actual and forecasted spend, sent by email or Amazon SNS, and optional budget actions, such as applying an IAM policy that denies provisioning more resources. AWS Cost Anomaly Detection uses machine learning to flag unusual spend.

  • Budgets data updates up to three times a day, and AWS warns that charges can pass your threshold before the notification arrives.
  • Cost Anomaly Detection relies on Cost Explorer data that can lag by up to 24 hours, and a new monitor can take 24 hours to start detecting.
  • AWS says Cost Anomaly Detection does not monitor most AWS Marketplace products, with third-party foundation models on Amazon Bedrock as the exception. For other Marketplace charges, use a Budgets cost budget filtered by billing entity. Check how your own models are billed.

Neither tool is a hard cap on its own. Keep AI keys out of public code, scope IAM permissions tightly and delete unused keys.

What can you do on Google Cloud?

A standard Google Cloud budget does not cap usage. Google's documentation says setting one does not automatically cap spending. Alerts default to 50%, 90% and 100% of actual spend and go to billing admins by email.

  • Add forecast-based thresholds and extra recipients, such as a Cloud Monitoring channel.
  • For automation, send budget notifications to a Pub/Sub topic and build a function that responds, for example by disabling billing on a project. Google presents this as something you build, and notices can arrive hours late.
  • Google also documents spend cap budgets, but only for supported services. Check whether yours is eligible.
  • Restrict every API key to the specific APIs and referrers or IP addresses it needs.

What about Vercel and other hosts?

On Vercel's Pro plan and Enterprise Flexible Commitment plans, Spend Management lets an owner or billing user set an On-Demand Budget. Notifications go out at 50%, 75% and 100%, and you can add a webhook.

  • Setting the amount does not stop usage by itself. Turn on Pause Production Deployments to pause all projects when the amount is reached. Visitors then see a 503 error until you resume each project manually.
  • Vercel checks spend every few minutes, so pausing can lag. Set the amount below your true maximum.
  • Pausing does not stop AI Gateway key usage, which still counts toward spend.

Other hosts differ. Look for a budget, a spend limit and an option to pause or throttle.

What should you build into the app itself?

  • Keep provider keys on the server only. A key in the browser is a key anyone can use.
  • Require login before any AI call and rate-limit per user.
  • Set max_tokens (or the provider's equivalent) on every request and cap conversation length.
  • Cache repeated answers and use a cheaper model for simple tasks.
  • Log token usage per user so one account cannot silently use most of your budget.

Our production checklist and security guide cover the first two in more detail. If you want us to look at your setup, the free audit call includes spend caps, caching and model routing.

Frequently asked questions

Does an OpenAI spend alert stop my spending?

No. According to OpenAI's documentation, spend alerts only notify you and API traffic continues. To stop spending, enable a hard spend limit at the organization or project level, which makes requests fail with a 429 error once reached.

Is an OpenAI or Anthropic limit exact?

Not to the cent. OpenAI states that enforcement is not instantaneous and recorded spend can slightly exceed the limit. Set the limit below your true maximum.

Do AWS Budgets and Google Cloud budgets cap my bill?

No. Both mainly send alerts, and their data lags by hours. AWS Budgets can run actions such as applying an IAM policy, and Google Cloud can trigger automation through Pub/Sub, but you must set those up yourself.

What usually causes a surprise AI bill?

Reported cases include exposed or abused API keys, automatically raised spending tiers, and endpoints with no rate limit or login. Our advice is to find those causes as well as capping the spend.

Can ExcenityAI set this up for me?

Yes. The free 30-minute audit call reviews your spend caps, keys and rate limits, then we send a fix plan and a quote.

Sources

Checked 27 Oct 2026. Provider settings and limits change, so confirm against the linked documentation.

Keep going

Want a second pair of eyes? Book the free audit call.

A free 30-minute review of your AI-built app, then a written fix plan and a quote.