Skip to content
itsorted.online
AI guide

Stop Surprise AI API Bills: Spending Limits, Keys and Monitoring

A chatbot or AI feature on your website runs on an API key that is billed per token. If the key leaks, a bot loops, or a popular page triggers far more calls than expected, the bill arrives at the end of the month. The three big providers now all offer real controls: OpenAI and Gemini support hard spend caps per project, and Anthropic lets you set your own spend limit below your tier's cap. This guide shows what each provider offers (from their docs, October 2026), how to scope and rotate keys, why a key must never sit in website code, and a simple monitoring routine.

By IT Sorted teamReviewed 7 min readHow we write guides
in

Key takeaways

  • OpenAI supports hard spend limits per organisation and per project; alerts alone don't stop traffic.
  • Gemini API supports project spend caps in AI Studio, but billing data can lag about 10 minutes.
  • Anthropic lets you set your own monthly spend limit below your usage tier's cap.
  • OpenAI says never deploy an API key in client-side code such as browsers or mobile apps.
  • Use a separate key and project per app so one leak or bug can't drain the whole budget.
In this guide · 8 sections
  1. 01Why AI API bills surprise small businesses
  2. 02Spend limits by provider (OpenAI, Anthropic, Gemini)
  3. 03Set up spend limits step by step
  4. 04API key safety: scoping, storage and rotation
  5. 05Protect a public chatbot from abuse
  6. 06A weekly monitoring routine
  7. 07Do it yourself or get help?
  8. 08Frequently asked questions

Short answer

Set a hard monthly spend limit for each project (OpenAI and Gemini) or organisation (Anthropic), plus alerts at lower amounts. Use one key per app, keep keys on the server never in browser or app code, rotate them, and check usage weekly. Limits aren't instant, so leave headroom.

Why AI API bills surprise small businesses

Most AI API costs are tiny per request, which is why nobody watches them. Problems come from volume you didn't plan for.

  • Leaked key: a key pasted into website JavaScript, a public code repository or a shared document gets found and used by others.
  • Runaway loop: an automation or agent that retries endlessly, or calls the model on every page view.
  • Abuse of a public chatbot: someone uses your website assistant as a free general-purpose AI.
  • Expensive model by default: a developer tested with the top model and nobody switched it back.
  • Long context: every request sends a whole document or chat history, multiplying input tokens.

To estimate what normal usage should cost, see our guides to LLM token costs per customer reply and API pricing per token. Knowing the normal number is what makes an alert useful.

Spend limits by provider (OpenAI, Anthropic, Gemini)

All three providers now separate notification-only alerts from limits that actually stop traffic. The details differ.

ProviderHard cap you can setAlertsThings to know
OpenAIMonthly hard limit per organisation and per projectSpend alerts at thresholds you chooseAt the limit, requests fail with a 429 error; enforcement isn't instant
Anthropic (Claude)Your own monthly spend limit below your tier's capUsage and cost in the Console; Admin API for reportingUsage tiers carry their own monthly spend caps; workspaces separate projects
Google Gemini APIMonthly spend cap per project in AI StudioPlus billing-account tier capsBilling data can lag around 10 minutes; batch and agent jobs may overrun
From OpenAI, Anthropic and Google documentation, checked October 2026.

Sources: OpenAI's spend limits guide, Anthropic's rate and spend limits page and Google's Gemini API billing page. OpenAI notes that enforcement "is not instantaneous", so recorded spend can slightly exceed the limit; Google says the same about billing data delays.

Set up spend limits step by step

The same pattern works on each platform. Do it before the AI feature goes live.

  1. Create a project or workspace per app

    One for the website chatbot, one for internal tools, one for testing. OpenAI uses projects, Anthropic uses workspaces, Gemini uses Google Cloud projects in AI Studio.

  2. Estimate normal monthly spend

    Multiply expected requests by average tokens and the model's price. Set the hard limit at roughly two to three times that, so a busy month still works but a leak doesn't drain the account.

  3. Turn on the hard limit

    OpenAI: Project settings, Limits, Edit spend limit, Enforce a hard limit. Gemini: AI Studio, Spend, Monthly spend cap. Anthropic: Console, Billing, set your own spend limit.

  4. Add alerts below the limit

    For example at 50% and 80% of the limit, sent to a shared mailbox that someone reads, not one developer's inbox.

  5. Plan what happens at the limit

    Your app should handle the 429 error gracefully, for example showing "Our assistant is unavailable, please WhatsApp us" rather than breaking the page.

API key safety: scoping, storage and rotation

Spend limits cap the damage; good key handling prevents it. OpenAI's API key safety article lists the basics: a unique key per team member, never deploying keys in browsers or mobile apps, secure storage, monitoring, rotation and IP restrictions. Administrators can also enforce a maximum key lifetime.

API key checklist

AI-generated code is a common source of leaks, because quick prototypes often put the key straight into the front end. Our vibe-coding risks guide covers this and other security gaps in AI-built apps.

Protect a public chatbot from abuse

A chatbot on your website is a public door to a paid API. Even with a spend cap, abuse can exhaust your budget and take the bot offline for real customers.

Controls that help

  • Rate limit per visitor or IP on your server
  • Cap message length and conversation length
  • System prompt that keeps the bot on your business topics
  • A cheaper model for routine questions
  • Bot protection (such as a challenge) on the chat endpoint

Set-ups that invite abuse

  • Browser calling the AI provider directly with your key
  • Unlimited conversation history sent with every message
  • No per-visitor limits
  • Top-tier model for every greeting and FAQ
  • Nobody reviewing usage after launch

A weekly monitoring routine

Five minutes a week is enough for most small businesses.

  • Open each provider's usage dashboard and compare this week's spend with last week's.
  • Check spend per project or key; a sudden jump on one key points to the cause.
  • Look at which models are being used; an expensive model appearing unexpectedly is a red flag.
  • Confirm alerts still go to a monitored address.
  • If something looks wrong, revoke the key first and investigate second.

If a key has leaked, revoke it immediately, create a new one, update the app, check usage logs for when the misuse started, and contact the provider's support about unexpected charges.

Do it yourself or get help?

Setting spend limits and alerts takes minutes and every business using AI APIs should do it now. Help is worth it when an app was built quickly with keys in the front end, when you need a server-side proxy with rate limits, or when you aren't sure where keys have been copied.

Our Security Health Check (S$290) reviews where keys are stored, who has access and what limits are set. For a properly built AI feature with server-side keys, rate limits and usage reporting, our Custom Tool or Dashboard service starts at S$1,990.

Frequently asked questions

Yes. OpenAI supports monthly hard spend limits at organisation and project level. Once tracked spend reaches the limit, requests fail with a 429 error until you raise the limit or the next month starts. Spend alerts are separate and only send notifications. OpenAI notes enforcement isn't instantaneous, so spend can slightly exceed the limit.

Yes. Google's Gemini API documentation describes monthly spend caps you can set per project in AI Studio, plus caps tied to your billing account's usage tier. Google warns that billing data can be delayed by around 10 minutes, and long-running batch or agent jobs may go over the project cap.

No. Anyone can read a key in browser code and use it on your account. OpenAI's key safety guidance says never to deploy keys in client-side environments such as browsers or mobile apps. Route requests through your own server, which holds the key and can apply rate limits.

Revoke the key straight away in the provider's console, create a replacement and update your app. Check usage logs to see when unusual activity started and which models were used, then contact the provider's support about charges. Review how the key leaked, often a public repository or front-end code, and fix that.

Estimate normal monthly spend from expected requests, average tokens and model prices, then set the hard limit at roughly two to three times that. Add alerts at about half and 80% of the limit. That leaves room for a busy month while stopping a leaked key or loop from running unchecked.

Rather have it done for you?

Fixed price, set up in your own accounts.

Order online, get a written scope, and keep full ownership of everything we set up. Questions first? Ask us in writing.