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

AI and LLM interview question Q334, Inference, performance and cost. Intermediate, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/how-do-you-cut-cost-on-a-cloud-hosted-llm-workload

## Say it in 30 seconds

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.

## Say it in 2 minutes

Cost on a hosted model comes from tokens, the small pieces of text the model reads and writes. So I start by measuring. I want the cost per finished task, split into input and output, and I want to know which calls are the big ones. A bill that is only one total number hides the answer.

Then I cut in layers. The first is caching. If every call starts with the same 30,000-token policy handbook, the provider can reuse that start at a fraction of the normal price. The second is batching. Work that can wait, like a nightly summary of call notes, can run as a batch for about half the price, finished within a day. The third is routing. Many calls are simple, so a smaller model can handle them, and the big model only sees the hard cases.

The fourth is discipline. I trim the prompt, cap the length of answers and drop calls that add nothing. I also watch the cache hit rate, because a changing date at the top of the prompt quietly stops caching.

Every change gets checked against my own test set, built from real questions the team asks. A cheaper answer that is wrong costs more than the bill it saved, because someone has to fix it by hand.

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

- **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?

*Diagram, Four ways to cut a hosted model bill: 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.*
1. The bill split shows which repeated parts to cache and trim.
2. The bill split shows which work can wait and which calls are easy.
3. Fewer tokens are sent, so every call costs less.
4. Cheaper per call, if your tests pass.

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)

*Diagram, How a cached prompt start is reused: 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.*
1. The same start is checked against the cache.
2. A match is read at a fraction of the normal rate.
3. The new claim is billed 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:

```text
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. **Drop what repeats:** Cut repeated instructions and old chat turns the model no longer needs.
2. **Return only what the app uses:** Ask for the fields the screen shows, not the whole record.
3. **Cap the answer length:** Set a sensible limit for each job, so a rambling reply cannot run up the bill.
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." Better: Cheaper 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." Better: That changes the start of every prompt, so the cache never hits. Put changing values at the end.
- Trap: "Batch everything to save money." Better: Batches 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?

A. Keep the policy handbook first and the new claim last in every prompt.
B. Put today's date and a random request ID at the top of the system prompt.
C. Add one short note that says answer in plain English.
D. Send the list of tool names in the same order on every call.

**Answer:** B. A changing value at the top changes the start of every prompt, so the stored start can never match. Fixed text goes first and changing text, like the claim, goes last.

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

A. A live endpoint, one call per note, all night
B. A batch job due within a day, with live chat kept on the normal endpoint
C. The biggest model, so the job finishes in one pass
D. The job run twice, to be sure

**Answer:** B. Batch work is discounted and nobody is waiting, so a batch fits. The batch can take up to a day, which is why live chat stays on the normal endpoint.

## Can you answer these from memory?

**Flash cards**

- **What is the first step in cutting cost?** Measure the cost per task, split into input and output tokens.
- **What does prompt caching reuse?** The same start of a prompt that the provider has already processed.
- **Why does a changing date at the top hurt?** It changes the start, so the cached prefix never matches.
- **How much can a batch save?** About half, with results within a day. Batches can expire after 24 hours.
- **What is model routing?** Easy calls go to a smaller model and hard ones to a bigger one, checked by tests.
- **What is the cheapest token to pay for?** The one never sent. Trim repeats, cap answers and skip calls a rule can handle.

## Likely follow-up questions

- Q331 When do you use batch APIs? https://designervenkat.online/interview/ai/when-do-you-use-batch-apis
- Q336 Hosted API vs self-hosted open weights for an enterprise? https://designervenkat.online/interview/ai/hosted-api-vs-self-hosted-open-weights
- Q338 How do you cap output length? https://designervenkat.online/interview/ai/how-do-you-cap-output-length
- Q339 Why do output tokens cost more? https://designervenkat.online/interview/ai/why-do-output-tokens-cost-more
- Q340 How do reasoning tokens affect cost and latency? https://designervenkat.online/interview/ai/how-do-reasoning-tokens-affect-cost-and-latency

## Learn it in depth

- [Prompt Caching](https://designervenkat.online/learn/ai-engineering/prompt-caching)
- [Watching cost and speed](https://designervenkat.online/learn/ai-engineering/cost-latency-monitoring)
