Cut AI costs without losing quality
Key takeaway
The most effective levers for cutting AI costs are choosing the smallest sufficient model, shorter context, caching and batch processing. Every measure must be checked against a fixed test set so that savings do not come at the expense of quality unnoticed.
Lessons in this path
Why cost reduction starts with quality measurement
Almost every cost measure changes behaviour: a smaller model phrases things differently, trimmed context leaves information out, a cache returns an older answer. Without measurement you notice the consequences only when complaints arrive. Before any optimisation, define a test set with realistic requests and scoring criteria and compare cost and quality together.
The main levers at a glance
The effect depends heavily on the use case. The table helps with selection.
| Lever | Suited to | Risk |
|---|---|---|
| Smaller model | Classification, extraction, simple summaries | Weaker performance on complex cases |
| Routing by difficulty | Mixed requests with few hard cases | Misclassifying hard cases |
| Trimming context | Agents, knowledge assistants, long documents | Relevant information missing |
| Provider prompt caching | Recurring long instructions or documents | Low, if supported by the provider |
| Response caching | Frequently identical questions | Outdated or unsuitable answers |
| Batch processing | Tasks without time pressure, such as overnight analysis | Longer waiting time |
An optimisation pass step by step
This is how to approach an existing application.
- Measure cost and quality on the test set as a baseline.
- Break costs down by component: instructions, documents, history, output.
- Tackle the largest component first, for example by trimming or caching.
- Test a smaller model on the test set, with routing for hard cases if needed.
- Activate the change gradually for a share of requests and watch the metrics.
- Document the result and keep the test set for future changes.
Ask the model for shorter, structured outputs when no prose is needed. Output tokens are often more expensive than input tokens.
Self-hosting as a cost lever?
Running open models yourself can be cheaper at high, steady volume, but it requires hardware or reserved cloud capacity, operational expertise and ongoing maintenance. Under fluctuating load, utilisation is often low and cost per request rises. Calculate with full costs and realistic utilisation before citing cost reasons. Often data sovereignty or latency are stronger arguments for self-hosting than cost.
Going deeper: evaluating routing and semantic caching properly
Routing means that an upstream classifier or rule decides which model receives a request. The benefit depends on how well hard cases are recognised. So measure not just average quality but specifically the quality on hard cases. A router that looks good on average but misclassifies every tenth hard case can become expensive in critical processes.
A semantic cache returns stored answers for similar, not just identical, questions. This saves costs but carries two risks: similar questions can require different answers, and cached answers can contain information another user may not see. Use semantic caches only for non-critical, user-independent content and with a short validity period.
Example: a classification agent becomes cheaper
A fictional logistics group classifies tens of thousands of incoming emails by request type every day. The application uses a large model with a long instruction and many examples. A test set of 400 real, anonymised emails serves as the benchmark.
In the first step, the long instruction is reused via the provider’s cache. In the second step, a smaller model is tested: it achieves the same accuracy for standard requests but not for rare ones. The team introduces routing in which uncertain cases go to the large model. Cost per email drops markedly while accuracy on the test set remains stable.
Common mistakes
- Switching models without comparing on a test set.
- Measuring only average quality and overlooking hard cases.
- Using semantic caches for user-specific content.
- Calculating self-hosting with ideal rather than realistic utilisation.
Frequently asked questions
How large should a test set for cost optimisation be?
As rough orientation 50 to a few hundred cases, with deliberately included hard and rare cases. More important than size is that it reflects the real distribution.
Is fine-tuning worthwhile for cutting costs?
Sometimes, if a smaller adapted model can replace a large one. The effort for data, training and maintenance is considerable, however, and should be weighed against simpler levers.
Try it yourself
Break down the costs of one application by component and test one lever on a test set of at least 50 cases.
Check your result
You can quantify both the cost change and the quality change and justify whether the measure will be introduced.