Build a Cost Model for the System
How to build a monthly cost model for an LLM system: the parts of the bill, the numbers behind them and the levers that move it, for your AI interview.
In short
A cost model adds up every part of an AI system's bill: input and output tokens, retries, search, tool loops and fixed costs, multiplied by the real volume. Then it tests the levers, such as caching, batch processing and routing, to see which one moves the total most.
12 min readIntermediateCommon · estimateFacts checked 27 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
A cost model adds up every part of the bill for one month of an AI system. I start with the calls, add the retries, then price the input, cached and output tokens, plus search and the fixed lines. With made-up prices, a call-centre copilot with 180,000 calls a month comes to about five thousand dollars. Then I test the levers, like caching and routing, which means picking the right model for each call, to see which one moves the total most.
A cost model is the sum I write down before launch, so nobody is surprised by the bill. Every line is one part of the work: input tokens, cached input, output tokens, retries, tool loops, search, and the fixed costs like the search index and nightly tests. Each line is the volume times the price per unit, and the price comes from the provider's pricing page on the day I check it.
I start with one call and then count the calls. Take a call-centre copilot at a telecom firm, with 180,000 calls a month, 5 percent of them retried, and 60 percent of the input read from cache. With made-up prices, the base month comes to about five thousand dollars, and the model tokens are about half of that. A 60 percent increase in calls lifts the total about 30 percent, because the fixed lines stay the same.
Then I test the levers. Caching the repeated start is a big one, because a cache read costs a fraction of the normal input price. Batch processing is half price for work that can wait a day. Routing simple calls to a smaller model cuts the cost per token. I check each one against quality, so the cheaper answer is still a good one.
Last, I compare the model with the real bill every month and set a spending cap, because one open endpoint can be used to run up the cost. A model that nobody checks against the real bill goes stale quickly.
What is a cost model, in plain words?
A cost model is a sum you write down before launch. It lists every part of the bill, works out what one unit of work costs, and multiplies by the work you expect each month.
A hospital finance team does the same for a ward: staff hours, medicines, beds and cleaning, each with its own driver. In an AI system the unit is the token, a small piece of text that the model reads and writes. The model charges for every token, in and out. So a call-centre copilot that reads 4,000 tokens of rules and transcript per call pays for every one of them.
“A cost model helps segment expenses and estimate and forecast the total cost of ownership, including infrastructure, support, and implementation.”
Microsoft Azure Well-Architected Framework
“You cannot optimize what you cannot see.”
AWS Well-Architected Framework
Key words
- Token
- A small piece of text. The model bills for every token it reads and every token it writes.
- Cached input
- Repeated text, like the same rules on every call, that the provider keeps ready and bills at a lower rate.
- Retry
- Sending a call again after a bad reply or a timeout. The new call is billed too.
- Cost driver
- The part of the bill that grows fastest as the volume grows.
Which parts make up the bill?
What one call and its extras add to
One agent call
a copilot reply to a caller
Tokens billed
Input tokens
rules, transcript, policy text
Cached input
repeated start, read cheaply
Output tokens
the summary and reply
Extra bills
Retries
a bad reply is sent again
Tool loops
each tool call adds a model turn
Policy search
a lookup for every question
Monthly bill
all lines added up
- 1Each call starts the token bill: the words sent in and the words sent back.
- 2Retries, tool loops and search add their own lines, often more than people expect.
- 3The token lines go into the monthly bill.
- 4The extra lines go into the same bill, so nothing is left out.
Input tokens
The rules, the call transcript so far and the policy passages that search pulled in.
Cached input
The same start on every call, kept ready by the provider and billed at a lower rate.
Output tokens
The summary and the suggested reply. In the example prices, output costs five times input per token, so long replies drive the bill.
Retries
A bad reply or a timeout sends the call again, and you pay for the new call too.
Tool loops
Each tool call can send the model back for another turn, with its own input and output.
Search and fixed costs
A lookup for every question, plus the search index, logs and nightly tests every month.
How do you turn the parts into one monthly number?
- 1
Count the work
Calls per month, plus the share that gets retried. A retry is a real call, so it counts.
- 2
Measure the tokens
Input, output and cached input for a typical call. Take them from logs, not from a guess.
- 3
Price each part
Tokens times the price per million, from the provider's pricing page on the day you check it.
- 4
Add the fixed lines
The search index, logs and nightly tests do not grow with each call, so add them once.
- 5
Run three scenarios
A base month, a peak month, and one lever switched off, so you can see what moves the bill.
Here it is in plain Python. The telecom copilot is made up, and so are the prices. The structure is what matters.
# A made-up call-centre copilot at a telecom company: the monthly bill for the whole system.
PRICE_IN, PRICE_OUT = 3.00, 15.00 # made-up dollars per million tokens
CACHE_READ = 0.10 # cached input is billed at 0.1 times the base input price
PROMPT, OUTPUT = 4000, 500 # tokens per call: rules and transcript in, summary out
CALLS = 180_000 # calls answered in a month
RETRY = 0.05 # 5% of calls are sent again after a bad reply or a timeout
SEARCH = 0.0004 # made-up dollars per sent call for the policy search
FIXED = 2500 # made-up dollars a month: search index, logs, nightly tests
def bill(calls, cached_share):
sent = calls * (1 + RETRY)
prompt = PROMPT * (cached_share * CACHE_READ + (1 - cached_share))
model = sent * (prompt * PRICE_IN + OUTPUT * PRICE_OUT) / 1_000_000
return round(model, 2), round(model + sent * SEARCH + FIXED, 2)
model, total = bill(CALLS, 0.6)
print("Base month: model", model, "total", total)
print("Peak month, 1.6 times the calls:", bill(CALLS * 1.6, 0.6)[1])
print("Caching switched off:", bill(CALLS, 0.0)[1])
print("Cost per call, base month:", round(total / CALLS, 4))Output
Base month: model 2460.78 total 5036.38 Peak month, 1.6 times the calls: 6558.21 Caching switched off: 6261.1 Cost per call, base month: 0.028
This model leaves out one cost: writing the cache. Anthropic says cache writes on a 5-minute cache cost 1.25 times the base input price, so a cache that is rewritten often costs more than this shows. Add that line once the hit rate is measured from logs.
- Base
180,000 calls, 60% cached
Total $5,036. Model tokens are $2,461 of it.
- Peak
1.6 times the calls
Total $6,558. Calls rise 60 percent, the total about 30 percent, because the fixed lines stay flat.
- Lever off
Caching switched off
Total $6,261. Turning caching off adds $1,225 to the bill.
Cost per call in the base month is about 3 cents. If the copilot needs a person to finish some calls, also divide the bill by the calls that were solved. That gives the cost per solved case, which is the number a manager can act on.
Which lever moves the number most?
Each lever changes the bill in a different way. Test each one with your own numbers, because the answer depends on how much of the work is repeated text, how much can wait, and how simple the calls are.
“cutting costs by 50 percent and increasing throughput.”
Anthropic, on its Batch API
“Cache read tokens are 0.1 times the base input tokens price”
Anthropic, on prompt caching
Send each call to the cheapest model that can do it
Incoming call
a question about a bill
Pick a model
easy or hard, by simple rules
Small model
most routine calls
Large model
hard or risky calls
Answer sent
cheapest model that passed
- 1Each call arrives with its question attached.
- 2Routine calls go to the small model, which costs less per token.
- 3Hard or risky calls go to the large model.
- 4The small model's answer goes out after the same checks.
- 5The large model's answer goes out after the same checks.
Cache the repeated start
Rules and tool definitions repeat on every call. The cache reads them back at a fraction of the normal price.
Batch what can wait
Nightly summaries and test runs do not need an answer in seconds. OpenAI's batch service costs 50 percent less and completes each batch within 24 hours.
Route easy calls down
Routine calls go to a smaller model that costs less per token. Check quality on a test set before you switch.
Trim the prompt
Send only the policy passages the call needs, not the whole handbook.
Cap the loops
Stop tool loops after a fixed number of steps, so one call cannot run on forever.
How do you keep the cost model honest over time?
AWS calls cost optimisation a continual process, not a one-off. Track the real bill every month, compare it with the model, and fix the driver that moved.
Put a budget and a spending cap on every key and every user. OWASP's 2026 list, under Unbounded Consumption, describes Denial of Wallet, where attackers run up the bill of a pay-per-use AI service and the provider carries the cost. A public endpoint with no cap is an open bill.
Tip
In an interview, a cap plus a monthly check against the real bill shows more care than a perfect first estimate.
What does the interviewer want to hear?
A strong answer covers
- Starts from units: calls, tokens, retries and the fixed lines.
- Names caching and batch as levers, and says to check their prices on the pricing page.
- Uses a peak month and a switched-off lever, not one number.
- Measures cost per solved case, so cost and quality sit in one number.
- Puts a spending cap and a rate limit on every public endpoint.
- Compares the model with the real bill every month.
Common traps
Trap"Token prices are tiny, so the bill will be small."
BetterTokens add up fast at scale. Multiply by calls, retries and the peak month before you call it small.
Trap"We will use the biggest model so quality is safe."
BetterThe biggest model costs the most per token. Route the easy calls down and check quality with a test set.
Trap"The provider's pricing page is the whole model."
BetterThe page gives unit prices only. Volume, retries, tools and the fixed lines decide the bill.
Can you spot the wrong line in a cost model?
Copilot cost model
Which line gets the units wrong? Prices are per million tokens.
Quick check
A call-centre summariser runs 40,000 times a night on yesterday's transcripts, and nobody waits for the result. Which option is the cheapest way to run it?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
Learn it in depth
Last updated on 27 November 2026
Planning the cost of an AI system before you build it?
Venkat designs and builds AI products and agents, including the UI and the system behind it. Book a short call and say what you need. No promises and no numbers until we have looked at your volumes.