Why the AI spend forecast is wrong, and what to keep on record so you notice in time
You were given a budget for an AI feature, the first invoice is higher than expected and the second is higher still. The question you get is "why", and a total does not answer it: you need to know whether volume went up, whether tokens per request went up, whether users moved to the more expensive model, or whether a price list changed. The short answer of this article is that the AI spend forecast goes wrong for three structural reasons (the price and the model mix move, the cost per user is not an average you can extend, and you usually find out late) and that you fix it less with a better statistical model than with a per-call cost log, written well from day one. I show you the three causes on four executed listings, with invented and declared numbers, and then how the FinOps Foundation proposes to organise the work.
The title of this article carries a percentage, 85%, that circulates in industry slide decks. I did not find it in a primary source that says what counts as "going over" and on which sample it was measured, so here you do not take it as proof of anything. What you need does not require an industry statistic: it requires that you can say, for your own product, by how much you went over and because of what.
This article opens the group dedicated to the operational control of spend. If you are missing the basics, the map of cost items says what to add up, the methods to reduce tokens and the comparison between your own server and an API explain the levers, and the twelve-month forecast builds the driver model that is put to the test here.
First cause: cost is a product of factors, and they all move
The monthly cost of a pay-per-use feature is the product of requests, tokens per request, the share of the models used and the price of each model. A forecast that extends "last month's spend plus 10%" assumes that the four factors stay still, or cancel each other out. There is no reason for that to happen: prompts grow longer when someone adds an example, users discover the mode that uses the large model, a price list is adjusted. The FinOps Foundation, in its framing document on AI, points to exactly this as the difference from traditional cloud: tokens are a new unit, the billed tokens are not the ones the user types because the application adds system prompts, history and retrieved content, and prices change often, in both directions.
The first listing takes a forecast of 960 euros and an actual of 2,393 euros, both invented, and breaks the difference down by replacing one factor at a time, from forecast to actual. The con function builds a copy of the forecast with a single field changed, instead of modifying the starting dictionary: this way every step starts from a known state and the cost jump is attributed to the factor just replaced. The listing does it in two different orders, and the reason is honesty of method: the sum of the jumps is always the total overrun, but the share attributed to each factor depends on the order, because the factors multiply.
"""Breaking down a budget overrun: volume, tokens per request, mix, price.
Every number is INVENTED. No model calls: arithmetic only."""
MODELLI = ("small", "large")
# December forecast: what we thought we would spend
prev = {
"requests": 300_000,
"tokens_per_request": 2_000, # input + output
"share": {"small": 0.80, "large": 0.20}, # share of requests per model
"price": {"small": 0.50, "large": 6.00}, # EUR per million tokens (invented)
}
# Actuals: volume grows a little, prompts get longer, the mix slides
# towards the large model and the large model's price list changes
cons = {
"requests": 345_000,
"tokens_per_request": 2_500,
"share": {"small": 0.65, "large": 0.35},
"price": {"small": 0.50, "large": 7.00},
}
def costo(p):
mtok = p["requests"] * p["tokens_per_request"] / 1e6
return sum(mtok * p["share"][m] * p["price"][m] for m in MODELLI)
def con(base, **cambi):
"""Copy of base with a few fields replaced: no dictionary is modified."""
return {**base, **cambi}
def scomposizione(ordine):
"""Replaces one driver at a time, in the given order, and records the cost jump."""
corrente, passi = prev, []
for nome in ordine:
nuovo = con(corrente, **{nome: cons[nome]})
passi.append((nome, costo(nuovo) - costo(corrente)))
corrente = nuovo
return passi
print(f"forecast {costo(prev):9.2f} EUR")
print(f"actual {costo(cons):9.2f} EUR overrun {costo(cons) - costo(prev):+.2f} EUR")
for ordine in (
("requests", "tokens_per_request", "share", "price"),
("price", "share", "tokens_per_request", "requests"),
):
print("\norder:", " > ".join(ordine))
for nome, delta in scomposizione(ordine):
print(f" {nome:20s} {delta:+9.2f} EUR")
# Output:
# forecast 960.00 EUR
# actual 2393.44 EUR overrun +1433.44 EUR
#
# order: requests > tokens_per_request > share > price
# requests +144.00 EUR
# tokens_per_request +276.00 EUR
# share +711.56 EUR
# price +301.88 EUR
#
# order: price > share > tokens_per_request > requests
# price +120.00 EUR
# share +585.00 EUR
# tokens_per_request +416.25 EUR
# requests +312.19 EUR
In the example the factor that weighs most, in both orders, is the drift of the mix: in the first order it is worth about 712 euros out of 1,433, in the second 585. The other items change a lot between the two orders (the price goes from 302 to 120 euros, the requests from 144 to 312), and this tells you how to read the table: the ranking of the dominant factor is reliable, the figures to the cent are not. The practical advantage is that the four rows have four different owners, and the question "why did we go over" becomes "who is watching the mix", which a total does not allow. The limit is that the breakdown is useful only if you kept the four factors for every period: you cannot reconstruct them from the invoice alone.
Second cause: the pilot's average does not extend to the population
A pilot with twenty users produces an average cost per user, and multiplying it by the number of expected users looks like the most natural forecast. It works if each user's cost is proportional to a quantity that is distributed symmetrically. Conversations are not like that: when every turn sends the whole history back to the model, turn k reads the fixed tokens plus k times the tokens of one turn, and the sum over the turns grows like the square of the turns. An activity whose cost is convex in its volume makes the average of the cost greater than the cost of the average, and the difference grows with the long tail of those who use the product far more than the others.
The second listing shows it with a fixed seed. Twenty pilot users make about four turns a day, with a narrow distribution; the simulated population of 5,000 users has a long-tailed lognormal distribution. The token_conversazione function is the formula of the accumulating history, the rest is descriptive statistics. The mean turns change little, from 3.85 to 4.42, and the mean cost per user changes a lot.
"""Why the pilot's average underestimates the cost per user: the cost of a conversation is
convex in the number of turns. INVENTED data, fixed seed, standard library."""
import random
from statistics import mean
T_FISSI = 600 # system tokens + opening question, resent at every turn
T_TURNO = 350 # new tokens per turn (question + answer)
PREZZO = 2.0 # EUR per million input tokens (invented; output is ignored)
def token_conversazione(turni):
"""If every turn resends the whole history, turn k reads T_FISSI + k*T_TURNO tokens:
the sum grows like turns**2, not like turns."""
return sum(T_FISSI + k * T_TURNO for k in range(turni))
def costo_utente(turni_per_giorno, giorni=20):
return token_conversazione(turni_per_giorno) * giorni * PREZZO / 1e6
rng = random.Random(7)
pilota = [max(1, round(rng.gauss(4, 1))) for _ in range(20)] # 20 curious users, short sessions
popolazione = [max(1, round(rng.lognormvariate(1.1, 0.9))) for _ in range(5000)] # long tail of long sessions
for nome, turni in (("pilot", pilota), ("population", popolazione)):
costi = [costo_utente(t) for t in turni]
print(f"{nome:12s} mean turns {mean(turni):5.2f} max {max(turni):3d} "
f"mean cost per user {mean(costi):6.3f} EUR/month")
media_pilota = mean(costo_utente(t) for t in pilota)
media_pop = mean(costo_utente(t) for t in popolazione)
print(f"\nforecast for 5000 users from the pilot: {media_pilota * 5000:8.0f} EUR/month")
print(f"cost of the simulated population: {media_pop * 5000:8.0f} EUR/month ({media_pop / media_pilota:.2f}x)")
ordinati = sorted(costo_utente(t) for t in popolazione)
top = ordinati[int(len(ordinati) * 0.9):]
print(f"share of cost due to the top 10% most expensive users: {sum(top) / sum(ordinati):.1%}")
# Output:
# pilot mean turns 3.85 max 5 mean cost per user 0.176 EUR/month
# population mean turns 4.42 max 73 mean cost per user 0.369 EUR/month
#
# forecast for 5000 users from the pilot: 878 EUR/month
# cost of the simulated population: 1844 EUR/month (2.10x)
# share of cost due to the top 10% most expensive users: 61.1%
The mean turns grow by about 15%, the cost doubles: the forecast from the pilot reaches 878 euros a month, the simulated population 1,844, and the top 10% of users alone produce 61% of the spend. The figures depend on the distribution I chose (lognormal, invented parameters), and the point is not the 2.10: it is that the error has a precise sign. A pilot systematically underestimates when the cost is convex and the population has a tail. Two remedies: estimate the cost from the distribution of turns and not from the mean, and plan a limit per session (a history window or a summary), which cuts the tail exactly where it is most expensive. A case where this does not hold: if every request is independent (classifying documents, for example), the cost is linear in volume and the pilot's average holds.
Third cause: you notice the problem when the invoice is already closed
The most dangerous cause is not a high cost but a high cost that nobody sees. An agent that enters a loop, a prompt that doubles its tokens after a release, a key shared with an experiment: these are events that last hours. The FinOps Foundation recommends monitoring tokens per minute at the application level and not only the daily spend, and it is the same logic as the third listing, which compares three ways of noticing the same event on an invented hourly series of 30 days: a loop that adds 9 euros an hour starting from hour 400, with a base spend of 840 euros in the month and a daytime peak.
The three rules are deliberately elementary. The monthly invoice discovers the event at closing. The daily check compares the day's total with the median of the previous days and fires above double. The hourly check compares the hour with the median of the previous twenty-four hours and fires above triple. The median, and not the mean, is used so that an isolated spike does not push the reference up.
"""What it costs to notice a runaway loop late. INVENTED HOURLY series, 30 days.
An agent enters a loop at hour 400 and spends 9 EUR/h more. Three ways to notice it."""
from statistics import median
ORE = 24 * 30
INIZIO = 400
BASE = [1.0 + 0.4 * (1 if 9 <= h % 24 <= 18 else 0) for h in range(ORE)] # daytime peak
spesa = [b + (9.0 if h >= INIZIO else 0.0) for h, b in enumerate(BASE)]
def fermato_a_ora_fattura():
return ORE # the invoice arrives at month end
def prima_ora_oltre(soglia_giorno):
"""Daily check: at the end of each day, compare with the median of the previous days."""
giorni = [sum(spesa[d * 24:(d + 1) * 24]) for d in range(ORE // 24)]
for d in range(3, len(giorni)):
if giorni[d] > soglia_giorno * median(giorni[:d]):
return (d + 1) * 24 # found at the end of the day
return ORE
def prima_ora_oltre_oraria(soglia):
"""Hourly check: every hour, compare with the median of the previous 24 hours."""
for h in range(24, ORE):
if spesa[h] > soglia * median(spesa[h - 24:h]):
return h + 1
return ORE
def extra_pagato(ora_stop):
return sum(spesa[h] - BASE[h] for h in range(INIZIO, ora_stop))
for nome, stop in (
("monthly invoice", fermato_a_ora_fattura()),
("daily check x2", prima_ora_oltre(2.0)),
("hourly check x3", prima_ora_oltre_oraria(3.0)),
):
print(f"{nome:26s} found at hour {stop:4d} delay {stop - INIZIO:4d} h excess spend {extra_pagato(stop):7.1f} EUR")
print(f"base spend for the month: {sum(BASE):.1f} EUR")
# Output:
# monthly invoice found at hour 720 delay 320 h excess spend 2880.0 EUR
# daily check x2 found at hour 408 delay 8 h excess spend 72.0 EUR
# hourly check x3 found at hour 401 delay 1 h excess spend 9.0 EUR
# base spend for the month: 840.0 EUR
The same event costs 2,880 euros of excess if you wait for the invoice, 72 if you check every day and 9 if you check every hour. The figures come from invented parameters, but the ratio between the three numbers depends on one thing only, the discovery delay multiplied by the speed of the incident. The hourly check, however, produces false positives in production: in the listing the series has no noise, and a threshold at three times the median on real data with legitimate peaks (a release, a night job) would fire all the time. That is why the article on checking the cost within the month uses a robust measure of dispersion and a comparison with the planned spend, not a fixed threshold.
The per-call log: the basis of all the fixes
To break down an overrun you need the four factors, to see the tail you need per-user data, to notice loops you need data that is fresh enough. All three depend on a log written at every call, with the tokens received from the provider and not estimated. In the APIs, the response reports the usage: for Claude, for example, the usage block contains input_tokens, output_tokens and, when prompt caching is in use, the fields cache_creation_input_tokens and cache_read_input_tokens. The documentation specifies that input_tokens counts only the tokens after the last cache breakpoint, and that the total input is the sum of the three fields: a log that reads only input_tokens underestimates the input of anyone using the cache, silently.
The fourth listing is a decorator that logs one row per call, with function, model, price list version, tokens and cost. The model is a scripted fake: it returns the usages I tell it, in order, and one of the five calls times out. Two choices matter. The price list version sits in the row, so a price cut does not rewrite the past and you can recompute the same tokens with a different price list. And the timeout is logged at zero cost with a different outcome, because if you do not log it the number of failures disappears, and failures are where a retry loop hides spend.
"""A per-call cost log: decorator, versioned price list, SCRIPTED FAKE model.
No network, no SDK: the decorated function returns a dictionary, as a response would."""
from collections import defaultdict
from dataclasses import dataclass
from functools import wraps
# Invented price list, with a version: every log row says which price list it was computed with
LISTINO = {
"v1": {"small": (0.50, 1.50)}, # (EUR per Mtok input, EUR per Mtok output)
"v2": {"small": (0.40, 1.20)}, # a price cut mid-month
}
@dataclass(frozen=True)
class Riga:
funzione: str
modello: str
listino: str
token_in: int
token_out: int
costo_eur: float
esito: str
REGISTRO: list[Riga] = []
def traccia(funzione, listino):
def decora(f):
@wraps(f)
def interno(*a, **k):
try:
r = f(*a, **k)
except TimeoutError:
# No usage declared: the call is logged at zero cost and with a different outcome,
# so the number of failures stays visible and is not silently lost.
REGISTRO.append(Riga(funzione, "?", listino, 0, 0, 0.0, "timeout"))
raise
p_in, p_out = LISTINO[listino][r["modello"]]
u = r["uso"]
c = (u["input_tokens"] * p_in + u["output_tokens"] * p_out) / 1e6
REGISTRO.append(Riga(funzione, r["modello"], listino, u["input_tokens"],
u["output_tokens"], c, "ok"))
return r
return interno
return decora
# Scripted fake model: returns the usage we tell it to, in order
COPIONE = iter([(1200, 300), (800, 150), "timeout", (5000, 900), (1100, 280)])
def modello_finto(prompt):
voce = next(COPIONE)
if voce == "timeout":
raise TimeoutError
t_in, t_out = voce
return {"modello": "small", "uso": {"input_tokens": t_in, "output_tokens": t_out}}
riassumi = traccia("summaries", "v1")(modello_finto)
for i in range(5):
try:
riassumi(f"document {i}")
except TimeoutError:
pass
totale = defaultdict(float)
for r in REGISTRO:
totale[(r.funzione, r.esito)] += r.costo_eur
print(r)
print({k: round(v, 6) for k, v in totale.items()})
# The same usage, recomputed with price list v2: the log keeps the tokens, the price changes later
ricalcolo = sum((r.token_in * LISTINO["v2"]["small"][0] + r.token_out * LISTINO["v2"]["small"][1]) / 1e6
for r in REGISTRO)
print(f"same tokens with price list v2: {ricalcolo:.6f} EUR (with v1: {sum(r.costo_eur for r in REGISTRO):.6f})")
# Output:
# Riga(funzione='summaries', modello='small', listino='v1', token_in=1200, token_out=300, costo_eur=0.00105, esito='ok')
# Riga(funzione='summaries', modello='small', listino='v1', token_in=800, token_out=150, costo_eur=0.000625, esito='ok')
# Riga(funzione='summaries', modello='?', listino='v1', token_in=0, token_out=0, costo_eur=0.0, esito='timeout')
# Riga(funzione='summaries', modello='small', listino='v1', token_in=5000, token_out=900, costo_eur=0.00385, esito='ok')
# Riga(funzione='summaries', modello='small', listino='v1', token_in=1100, token_out=280, costo_eur=0.00097, esito='ok')
# {('summaries', 'ok'): 0.006495, ('summaries', 'timeout'): 0.0}
# same tokens with price list v2: 0.005196 EUR (with v1: 0.006495)
The four successful calls cost 0.006495 euros in all, the fifth is logged as a timeout at zero, and the same tokens recomputed with price list v2 cost 0.005196 euros (the invented cut is 20%). The decorator is not production-ready: it does not read the cache fields, it does not handle streaming, and you cannot rule out that a client-side timeout corresponds to a call the provider counted anyway. The way to check is to compare the sum of the log with the provider's usage report, and treat the difference as a metric to keep under a threshold.
What to ask of a FinOps programme, and what not
The FinOps Foundation organises the work in three maturity levels, called Crawl, Walk and Run, and applies them to AI as well. The maturity model document warns that a level is not a finish line: the aim is not to reach "Run" everywhere, but to bring each capability to the level at which it produces the result the organisation needs. As examples of targets it uses three indicators that you can measure too.
- Share of cost attributable to a known owner: at least 70% at the Crawl level, 85% at Walk, over 90% at Run.
- Gap between forecast spend and actual spend: under 20% at Crawl, under 10% at Walk, under 5% at Run.
- Coverage of commitment discounts: about 60% at Crawl, over 75% at Walk, over 80% at Run.
These are example targets taken from the community, not normative thresholds, and the third row concerns purchase commitments that for AI through APIs often do not exist. Read them this way: the first is the prerequisite of the others, because without attribution you do not know who owns the gap in the second. In a small team, starting from the log of the previous section and the share of attributed spend is more useful than aiming for a forecast within 5%, which with a series of a few months is not a sensible target. The AI document adds that AI forecasts are less predictable than cloud ones, especially at the beginning, and recommends shorter windows and more frequent reviews.
The same document asks you to measure the use case and not the token: the cost per successful outcome (a ticket resolved, a case processed) reported as a distribution, not as an average, because costs vary from run to run. It is the fix for the second cause applied to the metric: the cost per outcome with its tail, not the cost per request with its average.
Frequently asked questions
What do I log first, if I start from zero?
One row per call with function, model, input and output tokens read from the response, price list version and outcome. With that table you can compute everything else: cost per function, breakdown of the overrun, the users' tail. Without real tokens, every other estimate is an estimate of an estimate.
Is a pilot's forecast useless?
No, but it is a lower bound when the cost grows more than linearly with use, as in conversations with accumulated history. Use it with the distribution of turns, not with the mean, and check the share of spend due to the most expensive users.
What is the right threshold for a cost alarm?
There is no universal threshold: it depends on the noise of your series. The thresholds in the listing (double the median per day, triple per hour) serve to show the order of magnitude of the delay; yours must be tuned on history, counting how many times they would have fired for nothing.
What you can do now
You can explain a budget overrun as a sum of effects with different owners, and you know that the order of the breakdown changes the figures but not the dominant factor. You know why a pilot's average underestimates a product with long conversations, and what to change in the estimate. You can compare the discovery times of a runaway loop with three check cadences, and you know what to write in a cost log so that all this is possible. The series and the prices in the listings are invented: replace them with your own. The next step is to decide where and how to tag the calls, in the article on tracking architecture; the techniques to reduce spend, in turn, are in the article on optimisation techniques, and those on the cost of agents in the piece on FinOps for agents and tokens.
Sources
- FinOps for AI Overview (FinOps Foundation) - tokens as a new cost unit, volatile prices, monitoring of tokens per minute, cost per outcome reported as a distribution, AI forecasts less predictable than cloud ones; consulted on 2026-11-13
- Maturity Model (FinOps Framework) - Crawl, Walk and Run levels and example targets on attribution, forecast gap and commitment coverage; consulted on 2026-11-13
- Prompt caching (Claude documentation) - the fields
input_tokens,cache_creation_input_tokensandcache_read_input_tokensof theusageobject and the formula of the total input; consulted on 2026-11-13 - Local runs:
python3 -Ion the four listings (standard library), each twice with identical output; prices, volumes and series invented for the example

Commenti
Caricamento commenti...
Sign in to comment