esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

How Do You Cut Cost on a Cloud-Hosted LLM Workload?

Measure first, then cache repeated prompts, batch work that can wait, and route easy calls to smaller models, explained simply for your AI interview.

In short

Measure where the money goes first. Then reuse the repeated start of each prompt, batch the work that can wait, send easy calls to a smaller model, and trim the tokens you send and receive.

13 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.

First I measure what each task costs, because one monthly total hides where the money goes. Then I cut in four ways. I reuse the part of the prompt that never changes, which the provider bills at a fraction of the normal price. Work that can wait goes in a batch, which runs at a discount. Easy calls go to a smaller model. And I trim prompts and cap answers. After each change I check quality against my own tests, so the cheaper answers are still good.

What does cutting cost mean, in plain words?

A hosted model bills by tokens. A token is a small piece of text, roughly a word or part of one. You pay for the tokens the model reads, which is the input, and for the tokens it writes back, which is the output. A busy workload sends much the same prompt again and again, so the bill grows with every repeat.

Think of a claims clerk at an insurer who reads the same 30-page handbook before every claim. Paying for the handbook each time is waste. The clerk could keep it open at the same page and read only the new claim. In an AI claims assistant, the handbook is the repeated prompt and the claim is the new part. The rest of this answer is about keeping the repeats cheap and the work small.

Key words

Token
A small piece of text the model reads or writes, about a word or part of one.
Input and output
What you send the model, and what it sends back. Both are billed.
Prompt cache
The provider's stored copy of a prompt's start, reused when the next request begins the same way.
Batch
Many requests sent together, with results returned later at a lower price.
Model routing
A first step that sends each call to a small or a large model.

Where does the money go, and what do you cut first?

Measure before you cut anything. A single monthly total hides the cause. Split the bill by feature, by model and by input versus output tokens. Then ask two questions: which parts of the prompt repeat on every call, and which work could wait?

Four ways to cut a hosted model bill

Measure cost per task

Split the bill into input and output

Cut what you send

Cache the same start

Reuse a prompt start seen before

Trim prompt and output

Drop repeats, cap answer length

Move and route the work

Batch the waiting work

Nightly jobs, about half the price

Route easy calls

Simple calls to a smaller model

Lower bill, tested answers

Answers still checked by your tests

  1. 1The bill split shows which repeated parts to cache and trim.
  2. 2The bill split shows which work can wait and which calls are easy.
  3. 3Fewer tokens are sent, so every call costs less.
  4. 4Cheaper per call, if your tests pass.
Caching and trimming cut what each call sends. Batching and routing cut what each token or call costs. Every path ends at a lower bill, with answers your own tests still check.

Cloud platforms offer similar levers under their own names, so the ideas carry from one provider to another. Amazon Bedrock, Amazon's own service for hosted AI models, describes its prompt caching as a way to reduce latency (how long a reply takes to arrive) and input token costs. Its prompt routing guide tells you to monitor the available performance and cost metrics.

How does prompt caching cut the bill?

Prompt caching keeps the start of a prompt that the provider has already processed. When the next request begins with the same text, that is a cache hit: the provider reuses the stored work and bills those tokens at a lower rate. The first time a start is stored is a cache write, which costs a little more. OpenAI says a cached input token can be discounted up to 95 percent. Anthropic says a cache hit costs a fraction of the base input token price.

The rule is strict. Only the start can match, so the repeated text must come first, in the same order, and anything that changes must come after it. Anthropic's cache also has a clock. Entries last five minutes by default, and each use refreshes the timer at no extra cost. Writing an entry costs more than a normal read, because a 5-minute cache write is priced above base input tokens.

  • “If content or a relevant setting changes before a breakpoint, the prefix after that change cannot match the existing cache entry.”

    OpenAI, prompt caching

How a cached prompt start is reused

Same on every call

Policy handbook

30,000 tokens, never changes

Cache lookup

Same start found? Read it cheap

This claim

500 new tokens, read fresh

Model answers

Bills each part at its own rate

  1. 1The same start is checked against the cache.
  2. 2A match is read at a fraction of the normal rate.
  3. 3The new claim is billed at the full rate.
The handbook is the same on every call, so the provider can reuse its stored start. The new claim is read fresh each time. The model bills the reused part at the lower rate and the claim at the full rate.

A made-up example, counted in token-units where one fresh token costs 1. A claims assistant at a mid-size insurer sends a 30,000-token policy handbook and a 500-token claim for each of 20,000 claims a day. Without caching, that is 30,500 fresh tokens per claim, or 610 million a day. With caching, the handbook is written at most 288 times a day, once every five minutes. That is a worst case, where the cache goes cold every five minutes. Steady traffic keeps the timer refreshed, so real writes are usually far fewer, and most reads come from the cache. At Anthropic's published rates for most models, checked on 27 November 2026, a 5-minute write costs 1.25 fresh tokens and a read costs 0.10, so the day falls to about 80 million token-units, a cut of 87 percent. The prices are for the arithmetic only, so check your provider's price list.

Python
# Made-up claims assistant: a 30,000-token handbook, a 500-token claim, 20,000 claims a day.
# Made-up numbers: a fresh token costs 1, a cache write 1.25, a cache read 0.10 (Anthropic's multipliers for most models).
HANDBOOK, CLAIM, DAILY = 30_000, 500, 20_000
WRITES = 288          # ceiling: worst case, the cache goes cold every 5 minutes
WRITE, READ = 1.25, 0.10

def no_cache():
    return (HANDBOOK + CLAIM) * DAILY

def with_cache():
    reads = DAILY - WRITES
    handbook = WRITES * HANDBOOK * WRITE + reads * HANDBOOK * READ
    return handbook + CLAIM * DAILY

base, cached = no_cache(), with_cache()
print(f"Without cache: {base:,.0f} token-units a day")
print(f"With cache:    {cached:,.0f} token-units a day")
print(f"Saving:        {1 - cached / base:.0%}")

Output

Without cache: 610,000,000 token-units a day
With cache:    79,936,000 token-units a day
Saving:        87%

Tip

Asked how you would cut a bill with a long shared prompt? Say caching first, then say you watch the cache hit rate in the logs. Keep the date, the user name and any request ID at the end of the prompt, never the top.

What if the work can wait?

A batch sends many requests together, and the provider returns the results later. OpenAI says batch work gets a 50 percent cost discount compared with synchronous APIs, the normal calls that return a reply straight away. Anthropic says its Message Batches API cuts costs by 50 percent and increases throughput, meaning how many requests get done in a set time. The normal endpoint, the address your app calls for a live reply, is the other choice.

  • Live chat bot

    Normal endpoint

    Replies in seconds at the full rate. Keep it for anyone who is waiting.

  • Nightly summaries

    Batch

    About half the price, with results due within a day.

The limits matter. Anthropic says a batch expires if it does not finish within 24 hours, and most batches finish in under an hour. Amazon Bedrock says batch inference is not supported for provisioned models (the ones you buy reserved capacity for), so check your capacity type before you plan a batch job around it.

A made-up case: a call centre wants 40,000 call notes summarised by 8 am. Nobody waits on that job, so it runs as a batch overnight, while the live chat bot stays on the normal endpoint. If a batch expires, the job is sent again, so keep the input files ready for a rerun.

How do you send less work to expensive models?

Many calls in a product are easy: a label, a short extraction, a yes or no. A small, fast model handles those well. Anthropic's model guide suggests starting with a faster, more cost-effective model, then moving up only where your tests show a gap. Routing is the same idea in code: a cheap first step picks the model for each call.

  • “Multimodel strategies pair a lower-cost model with a frontier model so that most tokens are billed at the lower rate.”

    Anthropic, choosing a model

  • “Routes prompts to different foundational models to achieve the best response quality at the lowest cost.”

    Amazon Bedrock, prompt routing

A frontier model is a provider's most capable model, and usually the dearest one to run. Test first. Anthropic's guide says to create benchmark tests specific to your use case, meaning a fixed set of your own real questions with answers you know are good. Then compare accuracy, response quality and edge cases before you change the model. A cheap wrong answer costs more than the tokens it saved.

Trimming is the cheapest saving, because nothing is paid for what is never sent. OpenAI's cost guide says to lower the number of input tokens, aim for shorter outputs, and limit the requests a task needs.

  1. 1

    Drop what repeats

    Cut repeated instructions and old chat turns the model no longer needs.

  2. 2

    Return only what the app uses

    Ask for the fields the screen shows, not the whole record.

  3. 3

    Cap the answer length

    Set a sensible limit for each job, so a rambling reply cannot run up the bill.

  4. 4

    Skip the model when a rule will do

    A date check or a lookup table needs no model call at all.

A made-up example. An online shop's returns bot re-sent the full order history on every message. Trimming it to the open order and the returns policy cut the input on most calls, with no drop in answer quality on the team's test set.

What does the interviewer want to hear?

A strong answer covers

  • Measure first: cost per task, split into input and output.
  • Caching for repeated prompt starts, and why the start must stay the same.
  • Batching for work that can wait, with its 24-hour limit.
  • Routing to smaller models, proven by your own tests.
  • Trimming tokens and calls, with cost per task watched over time.
  • Quality checked after every change, so the cut does not break answers.

Common traps

  • Trap"Switch to the cheapest model and you are done."

    BetterCheaper models can fail on your hard cases. Route by task and check quality after each change.

  • Trap"Add today's date at the top of the system prompt."

    BetterThat changes the start of every prompt, so the cache never hits. Put changing values at the end.

  • Trap"Batch everything to save money."

    BetterBatches can take up to a day and can expire. Keep live users on the normal endpoint.

Can you spot the waste?

Spot the problem

The team's bill jumped after a prompt change. Which line stops the cache from ever hitting?

Quick check

A nightly job summarises 40,000 call notes, and nobody waits for the results. What is the cheapest sensible setup?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q331When do you use batch APIs?9 min
  2. Q336Hosted API vs self-hosted open weights for an enterprise?11 min
  3. Q338How do you cap output length?11 min
  4. Q339Why do output tokens cost more?11 min
  5. Q340How do reasoning tokens affect cost and latency?11 min

Learn it in depth

Last updated on 27 November 2026

Running an AI workload that costs too much?

Venkat designs and builds AI products and agents (the UI and the system behind it), so book a short call and say what you need.