Guardrails & Control · 8 min read
Vibe coding and runaway AI bills: 8 cost mistakes and how to cap them
An AI-built app rarely fails on cost loudly. Every call succeeds and the bill arrives later. The eight mistakes behind runaway AI spend, and what to ask your agent instead.
By Akhil Anand · November 23, 2026
Vibe coding's famous failures are security failures: open databases, deleted production data, keys in the browser. Jobbit's guide to the 12 vibe coding mistakes and security risks covers that side well, with a checklist you can paste into your builder.
This post is about the other way an AI-built app hurts you: money. The moment your app calls OpenAI, Anthropic or Gemini, it has a meter running. And cost failures don't look like failures. Every request returns 200 OK, the app works, and you find out from the invoice.
The causes are as predictable as the security ones. Here are the eight we see most, what each one costs, and what to ask your agent for instead.
1. The AI key ships to the browser
If your app calls the AI provider straight from front-end code, the key is in the browser bundle. Anyone who opens the developer tools can copy it and use it, on your bill, for anything they like. Nothing in your app will show it: the calls never touch your code.
Ask for: "All AI calls go through a server route. The provider key lives only in a server-side environment variable. Confirm nothing in the browser bundle contains a key." Then give each app and environment its own key, so one leak can be revoked without breaking everything else.
2. No limit per user
An endpoint that calls a model is an endpoint that spends money. Without a limit, one user, one bug in your front end or one script can call it thousands of times an hour. Rate limiting by IP alone doesn't help much when the caller is a logged-in user.
Ask for: "Every route that calls an AI model has a per-user rate limit and a daily quota. Over the quota, return a clear error instead of calling the model."
3. Retrying errors forever
Agents love wrapping calls in retries, often with no cap and no delay. That's harmless until the provider has a bad hour. Then every request in your app is retried three, five or ten times, and every retry that gets through is billed. We wrote about how this multiplies the bill in retry storms.
Ask for: "At most 2 retries, with exponential backoff and jitter. Never retry a 4xx error. If more than half the calls in a minute fail, stop calling the provider for a minute."
4. An agent loop with no step limit
Agent features (anything that calls tools and decides what to do next) can get stuck. The expensive part is that each turn usually re-sends the whole conversation, so a loop doesn't cost the same per step. It gets more expensive every step.
Take a modest example: an agent that starts with 8,000 tokens of context, adds 2,000 per turn and writes 500 tokens back, on a model priced at $3 per million input tokens and $15 per million output tokens:
50 turns: 2.85M input + 25k output tokens ≈ $9
200 turns: 41.4M input + 100k output tokens ≈ $126
Four times the turns, about fourteen times the cost. Run that across a few users at once and it's real money within the hour (we ran fuller numbers here). Prompt caching lowers the input price but doesn't stop the growth.
Ask for: "Every agent run has a maximum number of steps and a maximum cost. Stop the run if the same tool call repeats three times in a row, and log why it stopped."
5. The premium model for everything
The default in most tutorials is the provider's best model, and agents copy the default. So the same model that writes your product's hardest answers also classifies support tickets, extracts dates and writes one-line summaries, at many times the price of a small model that would do those jobs just as well. More on this in model overkill.
Ask for: "Use the small model for classification, extraction and short summaries. Use the large model only where a test shows the small one isn't good enough, and list which calls use which model."
6. Re-sending everything, every call
Chat apps that send the full history on every message, "chat with your document" features that paste the whole document into every question, system prompts that grew to 5,000 tokens: input tokens are most of most AI bills, and nobody notices them growing.
Ask for: "Keep the last N messages plus a running summary instead of the full history. Retrieve only the relevant parts of documents. Turn on prompt caching for the system prompt and other fixed context."
7. No budget, no alert
Provider dashboards update with a delay, and most founders look at them when the invoice arrives. By then a bad weekend is already paid for.
Ask for: nothing from the agent; this one is on you. Set the spend limit or budget alert your provider offers today, in its console. It's the cheapest insurance there is. Just know its limits: it covers the whole account, it can't tell which feature is misbehaving, and when it trips, everything stops, not only the broken part.
8. Not knowing which feature costs what
"Our AI bill doubled" is not something you can act on. "The onboarding assistant doubled because it now re-reads every uploaded file" is. Without a label on each call, you can't tell a successful launch from a loop.
Ask for: "Tag every AI call with the feature that made it (for example support-chat, onboarding, search) and log the model, input tokens, output tokens and cost of each call."
The cost checklist for AI-built apps
Paste this next to your security checklist before you launch:
| Check | What to ask the agent |
|---|---|
| Keys | AI calls only from the server; keys in server environment variables; one key per app and environment |
| Per-user limits | Rate limit and daily quota on every route that calls a model |
| Retries | At most 2, with backoff and jitter; no retrying 4xx; pause when most calls fail |
| Agent runs | Maximum steps and maximum cost per run; stop on repeated tool calls |
| Model choice | Small model for simple tasks; large model only where tested |
| Context | Trimmed history, retrieval instead of whole documents, prompt caching on fixed context |
| Budget | Provider spend limit or alert set in the console |
| Attribution | Every call tagged with its feature; model, tokens and cost logged |
A standing prompt for cost
Like security, cost is easiest when it's in the brief from the start. Add this to your project instructions:
Cost rules for everything you build for me: AI provider calls only from the server, with keys in
server-side environment variables. Every route that calls a model has a per-user rate limit and a
daily quota. Retries: at most 2, exponential backoff with jitter, never on 4xx errors. Every agent
run has a maximum number of steps and a maximum cost, and stops if the same tool call repeats three
times. Use the smallest model that passes the test for each task. Trim conversation history and
cache fixed context. Tag every AI call with a feature name and log model, tokens and cost.
Before you tell me something is done, check it against these rules and report what you checked.
Where AtlasBurn fits
Most of the list above is code your agent can write in an afternoon. The part that's hard to build yourself is watching all of it while it runs: noticing within seconds that one feature has started looping, and stopping that feature without taking the rest of the app down.
That's what AtlasBurn does. It records the cost of every AI call by feature (tokens and cost only, never your prompts or responses), forecasts your month, and has a daily budget. When a feature loops, it slows that one feature down, then stops it at the edge if the loop keeps going, while everything else keeps running. Setup is one command, npx abn init, or ask Claude Code or Codex to "Integrate AtlasBurn" and approve the key.
Ship fast, but put a meter and a brake on it. Try AtlasBurn free.
Frequently asked questions
Can someone use my OpenAI or Anthropic key if it's in my front-end code?
Yes. Anything shipped to the browser can be read by whoever loads the page, and an AI API key works from anywhere. If a key has ever been in front-end code, revoke it, create a new one and keep the new one on the server.
Why did my AI bill suddenly spike?
The usual causes are a retry loop during a provider outage, an agent stuck repeating itself with a growing context, a switch to a more expensive model, or a leaked key. Per-feature cost tracking tells you which one within minutes instead of at the end of the month.
Do rate limits stop a runaway agent?
Not on their own. A looping agent usually stays under your rate limits; it just never stops, and each call costs more than the last. You need a step or cost limit per run, or a guardrail that recognises the loop pattern itself.
Is a provider spend limit enough?
It's a good last line of defence and you should set one. But it applies to the whole account, it usually acts on a monthly total, and when it trips everything stops. Limits per user, per run and per feature catch the problem earlier and only stop the broken part.