Skip to content

Running LLM APIs · 5 of 7

Denial of wallet

Step 1 · The pattern

Every answer costs a little

Users ask short questions; each call adds a little to the month's spend (amber), billed by tokens in and out. The organisation has a spend cap with its provider, comfortably above normal use. (All numbers are illustrative.)

  • a question
  • cost
  • answered

In short

Denial of wallet: how it works and how it breaks

An LLM feature costs money on every call, in proportion to the tokens in and out. Most users ask short questions. One account, a script, a scraper or simply an enthusiastic customer pasting whole documents in a loop, can send inputs a hundred times larger, around the clock. OWASP's Top 10 for LLM applications calls this unbounded consumption and names 'denial of wallet' among its risks. Without per-user limits the month's budget goes in hours. When the provider's spend cap is reached, the API refuses every request from your organisation, so all users are cut off, not just the expensive one; without a cap, the bill arrives instead. Put token budgets per user or customer at the gateway (per hour, day and month), limit input size and turns, alert on unusual spend per account, and keep the provider's spend cap as the last backstop rather than the only control.

What this simulation simplifies

  • Costs are whole units and the month is a few seconds long.
  • The budget never resets in the animation; real budgets roll over each period.

How this comes up in interviews

"How do you stop one customer from running up your LLM bill or cutting off everyone else?"

Then they ask

  1. Where do you enforce it?
  2. Per request or per period?
  3. What happens when the limit is hit?

A strong answer covers

  • Cost is proportional to tokens; inputs and loops are unbounded by default.
  • Per-user or per-customer token budgets at the gateway, per hour/day/month.
  • Input size, turn and max_tokens limits.
  • Anomaly alerts on spend per account.
  • Provider spend cap only as the final backstop.

Points to cover, not a script. Say them in your own words and tie them to a system you have worked on.

On one page: the track cheat sheet.

Last reviewed: Official documentation

Diagrams are our own simulations: the timings, rates and counts in them are illustrative, not measurements. Captions are original wording.