All guides
Operations

Setting Budgets and Monitoring LLM API Spend

How to forecast an LLM budget, what to log per request, which alerts and caps to set, and how often prices change, measured over 54 days of tracked changes.

Set an LLM budget in three layers: a forecast built from your real token counts, per-request logging that lets you see cost by feature and user, and hard limits that stop a runaway job before the invoice does. The forecast will be wrong in predictable ways, mostly because output tokens run longer than planned, and prices will move under you, so monitoring matters more than the initial estimate.

Prices are per 1 million tokens, as of November 25, 2026. Price-change statistics cover the tracked window of October 3 to November 25, 2026, from the site's changelog. Provider limits are as of October 24, 2026. Billing details differ by provider, so confirm how yours reports usage.

Step 1: Forecast from tokens, not from requests

A budget needs four numbers per feature: requests per month, input tokens per request, output tokens per request, and the share of input served from cache. Multiply by the model's prices. The cost calculator does this, and how to estimate costs before you build walks through collecting the inputs.

Most forecasting errors come from two places. Take a chat feature on Claude Sonnet 5.5 ($2 input, $10 output): 1,500 input and 400 output tokens per turn, 300,000 turns a month.

ScenarioCost per turnMonthly
Forecast: 1,500 in, 400 out$0.0070$2,100
Output runs 50% longer (600 out)$0.0090$2,700
Input runs 50% larger (2,250 in)$0.0085$2,550

A 50% miss on output costs 28.6% more, and the same miss on input costs 21.4% more. Output is dearer per token, so forecast it conservatively. Measure real output length on a sample before launch, then replace the estimate with logged data in the first week. The token counter helps with the input side, and input vs output token pricing covers why the two behave differently.

Add a buffer and say what it is for. A 25% contingency over the forecast is a reasonable start for a new feature. Use a smaller margin once logged data has replaced the estimates.

Step 2: Log the right fields on every request

You cannot allocate a bill you did not record. Log one row per API call, written at call time:

FieldWhy
Timestamp, request idJoin to provider invoices and traces
Model id (exact string, including snapshot or alias)Aliases can reroute to a new model with a new price
Feature or route nameCost by feature
User, tenant or account idCost per customer, and abuse detection
Input tokens, uncachedPriced at the full input rate
Input tokens, cache readPriced at the cache-read rate
Input tokens, cache write (if your provider bills it)Some providers charge a premium; check the docs
Output tokensPriced at the output rate
Computed cost, plus the price version usedSo history survives later price changes
Latency, status, retry countRetries cost money; failed calls may still bill
Prompt template versionFinds the release that caused a jump

Read token counts from the provider's usage object in the response, not from your own estimate. Field names for cached tokens vary by provider, so check which fields yours returns. Store the prices you used alongside the cost. Our data shows prices change constantly (see below), and a cost column recomputed from today's prices will not match last month's invoice.

Reconcile weekly. Sum your logged cost, compare it with the provider's usage page or invoice, and investigate any gap above a few percent. Common causes are unlogged calls from scripts or notebooks, retries, and tool or search charges that are not token-priced.

Step 3: Unit economics

Totals hide what matters. Compute cost per request, per user and per feature, then compare against revenue per user.

Cost per 1,000 requests for four typical feature shapes, uncached:

FeatureTokens (in/out)Sonnet 5.5 ($2/$10)GPT-6.1 Terra ($1/$5)Gemini 3.8 Flash ($0.75/$3.75)Haiku 5.5 ($0.10/$0.50)
Chat turn1,500 / 400$7.00$3.50$2.63$0.35
Document summary8,000 / 500$21.00$10.50$7.88$1.05
Ticket classification600 / 30$1.50$0.75$0.56$0.08
Agent step6,000 / 350$15.50$7.75$5.81$0.78

Now a per-user view. Say a typical user makes 40 chat turns, 3 document summaries and 100 classifications a month. On Sonnet 5.5 that is $0.28 + $0.063 + $0.15 = $0.493 per user per month. Classification is 30% of that and needs almost no reasoning, so moving only that feature to Haiku 5.5 ($0.0075 instead of $0.15) brings the user to $0.3505, a 28.9% cut. This is the main payoff of feature-level logging: you find which cheap task is running on an expensive model. Compare candidates on /compare and /price-performance, and see choosing the cheapest model for your workload.

Set a per-user ceiling as well as a total one. If a free-tier user can cost $0.49 a month and a heavy user costs 50 times that, you need a per-account quota, not just a global budget.

Step 4: Alerts that fire early

Alert on rate of spend, not only on totals.

  • Budget thresholds. Notify at 50%, 80% and 100% of the monthly budget, and project the month-end total from the trailing 7 days. The projection alert fires days before the threshold alert does.
  • Anomaly alerts. Flag any hour or feature whose spend is above twice its trailing 7-day average. Runaway loops show up as a spike inside one feature.
  • Per-request alerts. Flag individual requests above a token threshold, such as input over 5 times the feature's median. This catches prompt bloat and users pasting enormous inputs.
  • Unit-cost alerts. Alert when cost per active user or cost per task rises 20% week over week, even if the total looks fine because traffic grew.

Send alerts to a channel someone watches and give each one an owner.

Step 5: Guard against runaway loops and prompt bloat

Runaway agent loops. An agent that re-sends a growing context on every step has quadratic cost. Assume a loop starting at 4,000 input tokens that adds 2,000 tokens per step and writes 300 output tokens per step, on Sonnet 5.5 without caching:

StepsInput tokensCost
10 (a normal run)150,000$0.33
100 (stuck)10.5M$21.30
500 (stuck all night)252.5M$506.50

Ten times the steps costs 65 times as much. If 90% of input were served from cache (assuming a cache read at $0.10 per 1M tokens), the 100-step run would cost about $3.35. On Haiku 5.5 without caching, it would cost about $1.07. Use agent cost estimates to model your own loops. Controls:

  • Cap steps and total tokens per run, and stop the run when it hits either.
  • Cap wall-clock time and tool-call count.
  • Detect repeats: the same tool called with the same arguments three times is a loop.
  • Set a per-run and per-user dollar cap, enforced in your gateway rather than in the prompt.

Prompt bloat. Prompts grow by accretion: a new rule here, a longer example there. Adding 2,000 tokens to a prompt sent on 1 million requests a month adds this much:

ModelUncachedAt cache-read price
Claude Sonnet 5.5$4,000$200
Gemini 3.8 Flash$1,500$150
Claude Haiku 5.5$200$20
DeepSeek V4.1 Flash$102$2

Track average input tokens per feature and per prompt-template version, and fail a release review if either jumps without a reason. Caching helps, but only when the prefix is stable; see prompt caching explained and /cache-savings.

Provider-side limits. Use the controls providers offer. Our rate-limit data notes that Anthropic's Start, Build and Scale tiers carry monthly spend caps ($500, $1,000 and $200,000), that Google has a spend limit per rolling 10 minutes, and that Mistral's monthly organization and workspace spending limits can pause API access when reached. These are a backstop, and a hard stop at the provider can take your product down, so set your own softer limit well below it. Details are on /rate-limits.

How often prices change

A budget built in January and left alone will drift, so build the review into your process. Here is how much movement we measured.

From October 3 to November 25, 2026 (54 days), the site logged 905 field-level price changes. A single repricing usually touches more than one field (2.6 on average), so counting by model and day gives a cleaner picture: 344 model-day price changes across 53 models, an average of 6.4 a day, with a price change logged on every one of the 54 days.

MonthField-level changesModel-day changesModels affected
October (from the 3rd)54320833
November (to the 25th)36213639

Direction: of the 905 field changes, 486 (54%) were cuts and 419 were increases. On input and output prices only, 327 were cuts and 282 increases. The median cut was 31% and the median increase was 59%. 430 of those 609 input and output changes were 20% or larger, and only 45 were under 5%. Prices here do not drift by pennies, they jump.

The movement is not spread evenly. Of the 65 non-batch models from Anthropic, OpenAI, Google and xAI, 5 had a price change in the window. Of the other 85 non-batch models, 37 did. DeepSeek (7 of 7 models), Moonshot (4 of 5) and Z.AI (7 of 11) moved the most. Our catalog prices these through OpenRouter, so many are host prices that can move more than a lab's own list price; see the methodology. 36 models changed on two or more separate days, and three DeepSeek models changed on 26 to 29 of the 54 days.

For a benchmark of the overall level, the price index tracks the median 3:1 input-to-output blended price per tier, rebased to 100 on July 13, 2026. From October 3 to November 25 the overall index ranged from 87.1 to 108.7 and ended at 94.1. Budget closed at 95.9, Standard at 94.1 and Premium at 142.2. The overall index changed on 27 of 53 day-to-day steps. Because it is a median across tracked models and the tracked set grew from 136 to 217 models, treat tier moves as market-wide signals, not as the price you will pay for a given model. The trends page and the 2026 price-trend review have more.

What this means for your budget:

  • Price per request is a variable, so log it with every cost row.
  • Re-run the forecast monthly, and on any provider announcement. A cut on your model is a saving you must claim, and a cut elsewhere may justify a switch.
  • Few models from the largest labs changed price in this window. For cheaper and open-weight models routed through hosts, assume movement and budget a range.
  • Keep model names configurable, so that moving to a cheaper equivalent is a config change.

A starting setup

  1. Forecast each feature with token counts, add 25%, and set the monthly budget.
  2. Log the fields above on every call, with cost and price version.
  3. Build a daily report: spend by feature, by model, cost per user, cache hit rate, and the top 10 requests by cost.
  4. Add 50/80/100% budget alerts, a 2x anomaly alert and a per-run cap on agents.
  5. Reconcile against the invoice weekly.
  6. Review prices and model choices monthly, using /cheapest and /models.