Why it happens
Your app is calling the model far more than usual, but nothing is failing: a retry loop that calls the model on every error, a feature that regenerates on every render, or one user running bulk generation. It looks like a loop or a new heavy feature, not an outage.
How to tell
- Hourly tokens far above the usual for that hour, for two or more hours running.
- No error spike — the calls succeed.
- One route, or one user, accounts for most of it.
The fix
- Log the route and the user id on every model call, so the spike has a name.
- Add a per-user daily cap with a friendly message when it is reached.
- Cap retries with backoff, and never retry a 4xx.
- Set a monthly limit with the provider as the last line.
The prompt for your builder
Paste this into Lovable, Bolt, Cursor, Claude Code or whatever built the app. Replace anything in capitals. It never asks you to paste a secret into a chat; keys go into your host’s environment, by you.
Add a per-user daily limit of 200 AI requests to my app, return a friendly message when it is reached, log the route and user id for every model call so I can see who is using the most, and make sure any retry logic backs off and gives up after three attempts.
How Keelnest catches it
Cost Guard polls usage hourly and compares it with the same hour's usual level; the billed cost arrives daily from the provider and confirms it. Budgets warn at 80% and alert at 100%.
Know the moment this happens.
Keelnest watches your production app every five minutes and tells you in plain English what broke — with the fix. Free for your first app.
Related
- The AI provider is rate-limiting youFeatures that call the model fail now and then with 429. Users see spinners, or errors, at the busy times.The fix
- An API key is in your public codeThe free health check — or a stranger — finds an OpenAI, Anthropic or Stripe secret key, or a Supabase service-role key, inside a script your browser downloads.The fix