Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
  1. Home
  2. Blog
  3. Cost Controls for AI Features in Production
Cloud & DevOps

Cost Controls for AI Features in Production

Usage-based pricing means a bug or a burst costs money directly. The limits worth setting before launch, not after the invoice.

Updated 2 min readBy SpiderHunts Technologies

Free estimateNo obligation

Get a free estimate

Tell us what you need. A senior engineer reads every enquiry.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →

Quick answer — TL;DR

Set per-user and per-period limits, alert on spend rather than only on errors, and cap what a single request can consume. A retry loop or an automated client can generate a month of expected spend in an afternoon.

The short answer

Anything billed by usage needs a ceiling you control, not just the provider's. Set limits per user, per period and per request, and alert on spend as it accumulates rather than discovering it on the invoice.

The expensive incidents are rarely malicious. They are a retry loop, an automated client, or a feature used far more than expected.

Where the surprises come from

  • A retry loop with no cap, hitting the provider repeatedly
  • An automated client or scraper using an unauthenticated endpoint
  • A single user with a use case nobody anticipated
  • Inputs far longer than expected, since cost scales with size
  • A bug that calls the provider inside a loop
  • A feature becoming popular faster than the budget allowed

The second is why unauthenticated endpoints that cost money per call are a bad idea. Anything that costs you money should require identification.

The limits to set

LimitProtects against
Per request input sizeOne enormous input
Per user per dayOne user consuming everything
Per account per monthOverall budget
Concurrent requestsBursts and retry storms
Retries per requestLoops

All five are straightforward to implement and each one has prevented a real incident somewhere. Setting them before launch costs an hour.

Alert on spend, not just errors

  1. Track spend continuously rather than at billing time.
  2. Alert at a fraction of the monthly budget, early enough to act.
  3. Alert on rate of spend, not only on total.
  4. Attribute spend per feature so you know what is consuming it.
  5. Review monthly against what the feature is worth.

Point three catches the incident while it is happening. A total-based alert fires after most of the damage.

Decide what happens at the limit

Degrade rather than break where you can: a cheaper model, a cached answer, a simpler non-AI path, or an honest message. Silently failing is the worst option.

And make sure hitting a limit is visible to you as well as to the user, because a limit quietly throttling a legitimate use case is its own problem.

FAQ

Frequently asked questions

The questions readers ask us after this guide.

Still have a question?

Ask us directly — a senior engineer will get back to you.

Ask about your project

What is the most common cause of a surprise bill?

A retry loop or an automated client hitting an endpoint that costs money per call. Both are preventable with caps.

Should AI endpoints require authentication?

Anything that costs you money per call, yes. Unauthenticated paid endpoints get found and used.

What limit should we set per user?

Enough for legitimate use with headroom, low enough that one user cannot consume the budget. Review it against actual usage after launch.

What should happen when a limit is hit?

Degrade to something cheaper or simpler with an honest message, and alert yourself. Never fail silently.

Keep reading

More on Cloud & DevOps

Cloud & DevOps

CI/CD for Machine Learning Projects

Software pipelines test code. Model pipelines must also test data and behaviour. What to add, and which gates should stop a release.

Start here

Scaling an AI system or trying to ship faster?

Tell us what you are running, where it slows down and what your volumes look like. We will come back with an honest view on what is worth changing first, what it would involve and a realistic range. If the bottleneck is not where you think, we will tell you that.

  1. You tell us what you needTwo minutes on the form, or a message on WhatsApp.
  2. A senior engineer reviews itAnd comes back with questions, a realistic range and an honest view on fit.
  3. Free 30-minute scoping callWe talk through scope, options and a realistic estimate — with no obligation.
Free estimateNo obligation

Talk to someone who builds this

Send a short brief and we will come back with an honest view and a realistic range.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →