Prompt optimisation for cost and quality is the discipline of getting the best possible answers from a language model for the lowest possible token spend. Every word in a prompt costs money, and every reasoning step costs more. The central question is how to cut the bill without cutting the quality, and the short answer is to shorten what the model reads, cache what repeats, batch what can wait, and route each request to the cheapest model that can handle it.
Most teams overspend on prompts by a wide margin, and most of the waste is invisible. A system prompt that grew by accretion, a few-shot block that nobody has pruned, a chain of thought applied to a task that does not need it: each one quietly adds tokens to every call.
Key takeaways
- Prompt optimisation for cost and quality means cutting tokens without cutting accuracy, and every change must be measured against a quality baseline.
- Prompt caching, batch APIs and model routing are the largest levers; all three major providers price batch work at half the standard rate.
- Shortening prompts, trimming few-shot examples and removing chain of thought where it is not needed are the cheapest wins.
- Output tokens cost more than input tokens and are harder to cache, so cap answer length.
- Optimise per task, not per prompt: the same technique can save money on one workload and damage quality on another.
How the bill is actually built
An API bill is built from four price lines: input tokens, output tokens, cache reads, and, on some providers, cache writes. Input tokens are everything you send: system prompt, examples, conversation history and the current question.
Output tokens are everything the model generates, including reasoning steps before the answer. Cache reads are the discounted price for reusing a stored prompt prefix, and cache writes are the small premium some providers charge to store it.
The two lines that matter most are input and output, and they are not equal. Output tokens are typically priced several times higher than input tokens, and they are generated one at a time, so they also drive latency.
A 500-token answer costs far more than a 50-token one, even if the inputs are identical. That is why the cheapest optimisation is often to ask for less: a shorter answer, a structured output, or a hard length cap.
Start by measuring. Log tokens per request, split into input and output, and cost per request by task.
Most teams discover that a small number of tasks drive most of the spend. For the estimation side of this work, see our guide to estimating LLM spend before you ship. Best for: any team that can log token usage per task and wants the spend to follow the value.
Shorten the prompt before anything else
The cheapest optimisation is deleting words. System prompts accumulate instructions over time: a rule added for a bug in March, a format note from a pilot in June, a warning that no longer applies.
Read the prompt as a stranger would, delete anything that does not change the output, and test the shorter version on a real test set. Most prompts can lose a third of their length without any measurable quality change.
Few-shot examples are the next target. Each example costs tokens on every call, and teams routinely keep examples that no longer teach anything. Remove them one at a time, measuring accuracy after each removal, and stop when accuracy drops.
Three examples usually teach as much as eight. The same logic applies to conversation history: summarise or truncate it instead of sending the full transcript every time.
Be careful with what you cut. Instructions that prevent a specific failure mode must stay, even if they look verbose, and removing them will show up as a quality regression rather than a saving. Cut by measurement, not by instinct. Best for: mature prompts that have grown by accretion and have never been pruned.
Prompt caching: pay once for the repeated prefix
Prompt caching lets a provider reuse a long prompt prefix across many requests instead of processing it fresh each time. When many requests share the same system prompt, examples or document, the provider stores that prefix and charges a fraction of the normal input price to read it. On Anthropic models, cached input is typically priced at about 10% of the base input price, with a premium of around 1.25 times the base price to write the cache.
Caching works best when the shared prefix is long and stable. A system prompt of 2,000 tokens that is identical across a million requests is an ideal candidate; a short prompt that changes every time is not.
The prefix must match exactly, so put the stable content first and the variable content last. A single varying word at the start can break the cache for every request.
Cache lifetimes matter. Most providers keep a cache entry for a few minutes to a few hours, so a workload with bursts of similar requests benefits more than one with a steady trickle.
If requests are spread thinly, the cache may expire between calls and you pay the write premium for nothing. Measure the hit rate before assuming the saving. Best for: high-volume workloads with a long, stable system prompt or a shared reference document.
Batch APIs: half price for work that can wait
Batch APIs process requests asynchronously, typically within 24 hours, at a substantial discount. OpenAI launched its Batch API in April 2024 at a 50% discount on synchronous prices, and Anthropic and Google offer the same 50% discount. The trade is time for money: results arrive hours later instead of seconds, which suits anything the user is not waiting for.
The workloads that fit are easy to recognise: nightly classification of a day’s tickets, bulk summarisation, evaluation runs, data labelling, and any pipeline that produces a report rather than an answer. Interactive work never fits, because the user is waiting. Split the workload honestly: real-time for what the user sees, batch for everything else.
Batch and caching can combine on some providers, which stacks the discounts. Anthropic, for example, allows prompt-caching discounts inside batch jobs. Check the stacking rules for your provider first, because the rules differ. Best for: bulk, offline workloads where a result tomorrow is as good as a result now.
Model routing: the cheapest model that can do the job
Model routing sends each request to the cheapest model that can handle it, instead of sending everything to the flagship. A simple classification goes to a small, fast model; a hard reasoning task goes to the large one. The saving is large because the price gap between model tiers is wide, and most real workloads are mostly easy requests with a minority of hard ones.
Routing can be rule-based or model-based. Rule-based routing uses the task type, the input length or a keyword to pick the model, which is simple and predictable.
Model-based routing uses a small classifier, or the small model itself, to judge whether the request needs escalation. Start with rules, because they are transparent and easy to debug, and add a classifier only when the rules cannot capture the difference between easy and hard.
The risk is misrouting: a hard question answered badly by a small model costs more in user trust than it saves in tokens. Measure the routing decision itself, not just the cost.
Log how often the small model is used, how often its answers are escalated, and whether quality on routed traffic matches the flagship. For more depth, see our guide to LLM model routing systems. Best for: mixed workloads where most requests are easy and a minority are genuinely hard.
Comparing prompt optimisation levers
| Lever | Typical saving | Effort | Quality risk | Best workload |
|---|---|---|---|---|
| Shorten prompts and examples | 10 to 30% of input tokens | Low | Low if measured | Any mature prompt |
| Prompt caching | Up to 90% off cached input | Low | None | Long stable prefixes |
| Batch APIs | 50% off all tokens | Low | None, only slower | Offline bulk work |
| Model routing | 50 to 90% on easy traffic | Medium | Medium, misrouting risk | Mixed easy and hard traffic |
| Cap output length | Large on verbose tasks | Low | Low with structured output | Summaries and classifications |
| Remove chain of thought | 50 to 75% of output tokens | Low | High on reasoning tasks | Simple, checkable tasks |
The safest savings come first: shortening, caching and batching cost little quality and little effort. Routing and chain-of-thought removal save more but carry real quality risk, so they need measurement. The right order is to take the safe savings first, bank them, and then test the risky ones one at a time against a quality baseline.

The quality baseline: how to know a saving is real
No optimisation counts until it survives a quality check. Build a test set of fifty to a hundred real inputs with known-good answers, and run every optimisation against it. A change that keeps the score is a saving, and a change that drops the score is a cost, whatever the token numbers say.
Score with more than one measure. Accuracy on the test set is the first, but also check format compliance, since a shorter prompt can produce sloppier output, and check the failure modes, since a routing change can introduce a new class of error. For generative tasks without a single right answer, use a judge model or human review on a fixed sample, so results are comparable across changes.
Finally, watch the tail. Averages hide the failures that matter: a routing change that saves 60% overall but fails every hard case is a bad trade. Report the worst-case quality alongside the average, and set a floor below which no optimisation ships. Best for: teams that want savings they can defend, not savings that quietly degrade the product.
Prompt optimisation checklist
- Token usage and cost are logged per task, split into input and output.
- A test set of fifty to a hundred real inputs exists, with known-good answers.
- The system prompt has been pruned, with every deletion tested against the baseline.
- Few-shot examples are trimmed to the smallest set that holds accuracy.
- Prompt caching is enabled where the shared prefix is long and stable.
- Offline work runs through a batch API instead of synchronous calls.
- Routing sends easy requests to cheaper models, with escalation measured.
- Output length is capped, with structured output where the format allows it.
Frequently asked questions
What is prompt optimisation for cost and quality?
It is the practice of reducing token spend while holding answer quality steady, using shorter prompts, caching, batching, routing and output caps. Every change is measured against a quality baseline so savings never come at the expense of accuracy.
How much can batch APIs actually save?
OpenAI, Anthropic and Google all price batch work at 50% of synchronous rates, for results returned within about 24 hours. The saving applies to input and output tokens, and on some providers it stacks with prompt caching.
Does prompt caching cost anything?
Yes, on some providers there is a premium to write the cache, typically around 1.25 times the base input price, while reading cached tokens costs a small fraction of the base price. Caching pays off when the same prefix is reused many times before it expires.
Will a smaller model hurt quality?
It can, which is why routing must be measured. Send easy requests to the small model and hard ones to the large model, log the escalation rate, and check that quality on routed traffic matches the flagship.
What should I optimise first?
Start with the safe levers: prune the prompt, trim the examples and enable caching. Then move the offline work to batch APIs.
Test routing and chain-of-thought removal last, one at a time, against the quality baseline. For the broader cost picture, see our guide to LLM cost optimisation.







