How to stop an AI app from running up a surprise bill
An app that calls a paid AI API can cost real money every time someone uses it, including bots, abusers and your own bugs. Protect yourself in layers.
1. Hard limit at the provider
Set a monthly spend limit in the provider’s console, and use a separate API key or workspace for each project so one cannot drain another. Enable usage alerts so you hear about spikes early.
2. Limits per user in your app
- Cap requests per user per minute and per day.
- Cap input length and set a maximum output size (
max_tokensor the equivalent). - Require sign-in before any costly call, and rate-limit by account and by IP.
3. Loop guards
If your code lets an AI agent call tools or itself repeatedly, set a maximum number of steps and a maximum spend per task, and stop when either is reached. A bug without a guard can loop all night.
Check it works
Deliberately exceed each limit in a test and confirm the app refuses politely instead of spending. Limits that were never tested are assumptions.
More in the security checklist.
Want the whole checklist?
Vibe101 is an interactive checklist, 11 chapters from idea to launch. The Security first chapter is free.
Published by the author of Vibe101, a paid checklist. This is general information, not legal advice or a security audit.