Token Usage Optimisation Guide: Cut LLM Spend Without Losing Quality

Token Usage Optimisation Guide: Cut LLM Spend Without Losing Quality

Token usage optimisation guide is what teams reach for when their language model bill grows faster than their user base. Tokens are the unit that hosted model providers charge for: every word of a prompt and every word of an answer is converted into tokens, and the bill is the count multiplied by the rate. The central question is how to spend fewer tokens without getting worse answers, and the answer is that most token waste is not in the model at all: it is in prompts that carry too much context, conversations that resend the same history, and outputs that run longer than the task needs.

Optimisation therefore starts with measurement. A team that cannot say how many tokens each feature uses, split between input and output, cannot tell whether a change helped. The work that follows is a sequence of small, testable changes: shorten prompts, retrieve less, cache what repeats, route simple work to smaller models, and cap output length. Each change is cheap to try, and each can be checked against a quality test before it ships.

Key takeaways

  • Tokens are the billable unit of hosted language models, counted separately for input and output.
  • Most token waste sits in oversized prompts, repeated history and over-long outputs, not in the model itself.
  • Measure tokens per request and per feature before changing anything, so savings are real and visible.
  • Retrieval, caching, routing and output caps are the four levers that cut tokens fastest.
  • Test quality after every change: a cheaper answer that is wrong is not a saving.

How tokens are counted, and why input and output differ

A token is a piece of a word, roughly three quarters of an English word on average, and providers count input tokens and output tokens separately. Input tokens cover the system prompt, the conversation history, any retrieved documents and the user’s message. Output tokens cover everything the model generates. Output tokens are usually priced higher than input tokens, because generation is the expensive part of the computation, so a long, rambling answer costs more than a long prompt of the same length.

That split shapes where to look first. A system prompt of several thousand tokens is paid on every single request, so trimming it pays off on every call. A conversation that resends its full history grows more expensive with every turn, because the input grows while the user’s new message stays the same size. And an answer with no length limit will keep generating until the model decides to stop, which is often later than the user needs.

Counting tokens is a solved problem for the common models: most providers publish a tokeniser, and a team can count tokens locally before a request is sent. The habit that matters is logging the counts per request, per feature and per model, alongside the cost. A dashboard of tokens per request over time is the baseline against which every optimisation is judged. Best for: any team whose model bill is large enough to matter and that does not yet know which feature spends the most tokens.

Shorten prompts without losing instructions

System prompts grow by accretion. A team adds a rule for one edge case, then another for a tone complaint, then a few examples, and within months the prompt is several thousand tokens long, paid on every call. The first optimisation is an audit: read the prompt, remove rules that no longer apply, merge duplicates, and delete examples that the model already handles without them.

Examples deserve special attention, because they are expensive and often unnecessary. A few well-chosen examples teach a format far better than a dozen, and a model that has seen a task many times may need none at all. Test the prompt with fewer examples on a sample of real requests before deciding.

Instructions should also be written for a model, not for a person. Long explanations of why a rule exists rarely change the model’s behaviour, while a short, direct statement of the rule does. Cut the rationale, keep the rule, and keep the prompt as a list of short, testable instructions rather than prose. For a focused treatment of prompt trimming, see our guide to cutting LLM prompt tokens, which covers the techniques in detail.

Retrieve less: give the model only what the question needs

Retrieval-augmented generation is a common source of token waste. A system that retrieves ten long documents for every question, and pastes all of them into the prompt, pays for nine documents the answer never uses. The fix is to retrieve less and to rank better: fetch a small number of passages, re-rank them by relevance, and send only the top few.

Chunk size matters too. Documents split into very small chunks produce many fragments carrying overlapping text, while very large chunks carry whole sections the question does not need. A chunk that holds one idea, with a short heading, usually gives the best balance of relevance and token cost, and it is worth testing two or three sizes against the same questions.

Compression is the third option. A retrieved passage can be summarised before it is sent to the main model, or the system can answer from a short, structured extract rather than from raw text. This adds a step that costs tokens too, so it only pays when the retrieved material is long and the summary is much shorter.

Cache what repeats and stop paying twice

Many requests repeat work that has already been paid for. The same system prompt, the same few-shot examples and the same retrieved documents appear in request after request, and some providers cache them automatically, charging less for the repeated prefix. Where that automatic caching exists, the practical step is to keep the repeated content at the start of the prompt and keep it stable, so the cache hits.

Exact-match caching is simpler and fully under the team’s control. If a user asks a question that has been answered before, the stored answer can be returned without calling the model at all. This suits support questions, definitions and other repeated queries, and it is worth building for any feature where the same questions arrive daily. Semantic caching goes further, matching questions that are worded differently but mean the same thing, though it needs a similarity threshold and a review of what gets matched, because a wrong match returns a wrong answer.

Conversation history can be cached in a different way: by summarising it. Instead of resending every turn, the system can keep a running summary and send that instead. The summary costs a small amount to produce and to send, and it stops the input from growing with every turn.

Route work to the right model and cap the output

Not every task needs the most capable model. Classification, extraction, formatting and short summaries are often handled well by a smaller model at a fraction of the token cost, while only the hard reasoning tasks need the largest one. Routing needs a classifier or a set of rules that sends each request to the cheapest model that can do it, plus a quality check that catches the requests the small model handles badly and sends them on. For the routing pattern in full, see our guide to AI model routing for cost optimisation, which covers how to route without losing quality.

Output length is the other half of the bill. A model asked to answer a question with no guidance will often produce a long answer, and every extra token is charged. Asking for a short answer, a specific format or a maximum length cuts output tokens directly, and it usually improves the user experience too, because most users prefer a concise answer. The setting that caps output length should be treated as a cost control, not just a style choice, and set per feature rather than left at the default.

Retries are a hidden multiplier. A request that fails and is retried three times costs three times the tokens, and a retry loop with no limit can multiply a bill during an outage. Set a maximum number of retries, add a delay between them, and log every retry so the team can see how much of the token bill is rework. For the wider picture of what drives cost per request, see our guide on what drives LLM cost per request, which breaks down the components and how to lower them.

Comparing token optimisation levers

Lever Tokens saved Quality risk Effort
Trim system prompt Every request Low, if tested Low
Retrieve fewer passages Large on RAG workloads Medium Medium
Prompt prefix caching Repeated content Very low Low
Exact-match answer cache Whole requests Low, if reviewed Medium
Conversation summarising Grows with chat length Medium Medium
Route to smaller models Large per request Medium Medium
Cap output length Output tokens Low Low

The table shows why the order matters. Prompt trimming, caching and output caps are low effort and low risk, so they come first. Retrieval tuning and routing need a quality test set, so they come next, once the baseline is measured. No lever should be applied without measuring the tokens it saves and the quality it preserves, because a saving that degrades answers is a cost in another form.

Hands editing a long document on a laptop, with one passage highlighted
Trimming a long document down to the passages that matter is the same discipline as trimming a prompt: keep what the answer needs, cut the rest.

Token usage optimisation checklist

  • Tokens per request are logged by feature, model and direction, input and output separately.
  • The system prompt has been audited: dead rules removed, examples cut to the few that matter.
  • Retrieval sends only the top-ranked passages, with a tested chunk size.
  • Repeated prompt prefixes are stable and cached, and repeated questions reuse stored answers.
  • Long conversations send a summary instead of the full history.
  • Simple tasks route to smaller models, with a quality check and a fallback.
  • Output length is capped per feature, and answers are asked to be concise.
  • Retries have a maximum count, a delay, and a log the team reviews.
  • Every change is tested for quality before it ships, on real requests.
  • Tokens per request are reviewed weekly, and regressions are investigated, not ignored.

Frequently asked questions

What is a token in a language model?

A token is a piece of a word, roughly three quarters of an English word on average. Providers charge per token, counting input tokens and output tokens separately, with output tokens usually priced higher.

Which token optimisation saves the most money?

It depends on the workload. For chat products, conversation history and long prompts dominate. For retrieval systems, the retrieved documents dominate. For long-form generation, output length dominates. Measure tokens per feature first, and optimise the largest source.

Does shortening a prompt always reduce quality?

Not if it is tested. Dead rules, duplicated instructions and excess examples can usually be removed without any change in quality. The risk comes from cutting instructions the model actually relies on, which is why changes should be tested on real requests before shipping.

Is caching safe for sensitive conversations?

It needs care. Cached answers and cached prompt prefixes can leak one user’s content into another’s request if the cache is shared. Keep caches per user or per tenant where the content is personal, and keep sensitive content out of shared caches entirely.

Should I use a smaller model for everything?

No. Smaller models handle simple, well-defined tasks well, but they fail more often on reasoning, ambiguity and long context. Route by task difficulty, and keep the larger model for the work that needs it.

How do I know an optimisation actually worked?

Compare tokens per request and a quality score before and after the change, on the same set of requests. A change that cuts tokens and holds quality is a win. A change that cuts tokens and drops quality needs to be reverted or reworked.

Latest articles

Scroll to Top