Skip to content
WebSurge

Give every AI feature a price tag and an off switch

Usage costs money on every request, so limits belong in the product, not in an afterthought.

· 4 min read · By WebSurge Technologies

Most software costs roughly the same whether ten people use it or ten thousand. An AI feature does not. Every request is metered, so a popular feature, a bug or a bad actor can turn into a bill. An AI feature with no limits is an open tab.

Four limits every AI feature needs

  1. A throttle. A cap on requests per minute stops a script from hammering the feature.
  2. A per-user quota. A daily or monthly allowance keeps one account from using the whole budget.
  3. A spending cap. A hard monthly ceiling means the worst case is a number you chose in advance.
  4. A kill switch. A single setting that turns the feature off, so that you can stop it without a release.

Two further habits help: limit the size of the input (a character limit on a text box is a cost control as well as a UX choice) and keep API keys on the server, never in the browser.

What this looks like in two real projects

Aviation AI charter search. The search is throttled to 10 requests a minute and also has a daily cap, a 300-character input limit and a kill switch.

BiteBrunch photo scan. The scan is limited per member (5 a day by default) and has a monthly spending cap (10 US dollars by default). Admins can change both, because they are settings in the admin area rather than constants in code. The feature ships switched off until the owner enables it. BiteBrunch is still in development, so these are design defaults and not results.

Test without spending

An AI feature should be testable without calling the real service. We run tests against a stand-in AI service (for BiteBrunch, a fake Anthropic server), so the test suite is free, fast and repeatable, and it can exercise failure cases such as a timeout or a malformed answer.

A short checklist

  • Is there a limit per minute, per user and per month?
  • Is there a hard spending ceiling that stops the feature, not just an alert?
  • Can someone switch it off in under a minute without a deployment?
  • Is the input size limited?
  • Do tests run without the real API?
  • Does the key live only on the server?

If the answer to any of these is no, the feature is not ready for production, however good the demo looks.

Estimate the cost before you build

You can price an AI feature on paper. Providers charge per unit of text that goes in and comes out (often called tokens), at a published price. Estimate the average size of a request and of an answer, multiply by the price, then multiply by the number of requests you expect per user and the number of users. Add a margin for retries and for images, which usually cost more than text. Compare the result with what the feature is worth, and set the monthly cap above the expected figure but well below the number that would hurt.

Enforce limits on the server, before the call

  • Check the quota before calling the provider, so that a rejected request costs nothing.
  • Count atomically in your database or cache, so that two simultaneous requests cannot both slip under the limit.
  • Limit by account and by network address. Anonymous features need the network limit most.
  • Read the spending cap from a setting, so that an administrator can change it without a release.

What to log

Log enough to explain the bill without storing more personal data than you need: a request identifier, the account, the time, the size of the input and output, the estimated cost and whether the call succeeded. With these records you can see which users or features drive the cost, spot a runaway script early and answer a support question about a failed request.

What the person sees when a limit is reached

A limit should end in a polite, specific message, not an error. Say what happened (“you have used today’s scans”), when it resets and what the person can still do. Where it makes sense, fall back to the ordinary, non-AI version of the feature, such as a normal search form. The kill switch should behave the same way, so that turning the feature off never breaks the page around it.

Keep reading

Have a project in mind? Book a free consultation.