Reduce token usage per call without hurting quality
Reduce token usage per call by trimming system prompts, cutting few-shot examples, capping output and using compact JSON, then testing quality before you ship.
Updated
To reduce token usage, send fewer tokens in each call and ask the model to write fewer. The main levers are a shorter system prompt, fewer few-shot examples, a sensible output cap, and compact JSON. Each change is cheap to try, and each one can hurt output quality, so measure every change on a test set before it goes live.
How do you reduce prompt tokens?
Start by measuring what you send. Most prompts carry the same block of rules, a long list of edge cases, and old instructions nobody removed. Count the tokens in the system prompt and the user message separately. Your provider’s token counter gives exact numbers.
Then trim:
- Remove rules the model already follows by default. Test each rule by deleting it and checking the score.
- Merge repeated instructions. Two paragraphs that say the same thing cost twice.
- Replace long explanations with short, direct instructions.
- Put stable text at the front of the prompt and use prompt caching, so repeated prefixes bill at a lower cache rate. Check your provider’s pricing page for cache rates, since vendors price them differently.
Prompt compression is the same idea, automated. Tools that summarize or drop words from a prompt can save tokens, but they are lossy. A compressor can remove a negation or a unit, and the model then answers a different question. Treat compressed prompts like any other change: run them against the test set and compare scores. For a production prompt that stays fixed, hand trimming usually wins, because you can see exactly what you removed.
Do few-shot examples increase cost?
Yes. Every example in the prompt is input tokens, and you pay for them on every call. Hypothetical, with round numbers: ten examples of 300 tokens each add 3,000 input tokens to every request. At Claude Opus list price of $4 per million input tokens, those 3,000 tokens cost $0.012 per call, or $12,000 per million calls. At Claude Haiku list price of $0.10 per million input tokens, the same 3,000 tokens cost $0.0003 per call.
Examples still help when the model misses a format or a rule. Keep the one or two that cover the hard cases, and drop the ones that repeat the easy path. Score the task with zero, one and three examples. Many tasks need fewer than you expect.
Fine-tuning moves the examples out of the prompt. A fine-tuned model learns the task from training data, so the prompt can stay short. Score the trained model on the same fixed test set as the long prompt it replaces, so you know the shorter call kept the quality. Training also has a fixed cost, so it pays off on a narrow task at high volume. For low volume, a short prompt with a few examples is usually the cheaper choice.
What max tokens setting reduces cost?
The max tokens setting caps how many output tokens the model can generate. You pay for generated output, so a cap stops a runaway answer from running up the bill. Output costs more than input on most APIs. Claude Opus lists at $20 per million output tokens, against $4 per million input tokens.
A cap does not make the model shorter. Hypothetically, if the model would write 800 tokens and the cap is 300, the reply stops at 300 tokens and is incomplete. Truncated JSON fails to parse. Set the cap from the largest answer you need, with some headroom, then ask for brevity in the prompt. The prompt keeps answers short, and the cap catches the rare long one.
Check the stop reason in your code. If a response stopped because it hit the limit, log it, and either treat it as an error or retry with a higher cap. Silent truncation is the failure most teams miss.
Is JSON output adding token overhead?
Yes, in two ways. Keys repeat on every object. Hypothetically, a list of 50 records repeats the same field names 50 times. Pretty-printed JSON adds spaces and newlines, and those are tokens too.
- Use short, stable key names when the consumer allows it. Document the schema so nobody has to guess what a key means.
- Ask for minified JSON with no extra whitespace.
- Request only the fields your code uses. Hypothetically, a reply with twelve fields, where your code reads three, pays for nine fields nobody reads.
- Use a schema or structured output, so the model cannot wrap the object in prose. Fewer parse failures also mean fewer retries, and each retry is a full call you pay for again.
Shorter keys can make a prompt harder for the model to follow, so test them like any other change. For more on this, see making LLM JSON output reliable.
How do you know output quality held?
A token cut only saves money if the answers still pass, so record the score and the input token count for each prompt variant on the same fixed set of real calls, and keep the shorter prompt only if the score holds. The full method is in how to build a test set.
Cutting tokens is the wrong first fix in some cases. If the task is hard and the answers need full context, the prompt may need to stay long. If the bill comes from long chat histories or retries rather than the prompt itself, look at those first. The guide to reducing LLM API costs covers the wider set of levers, and the guide to testing an LLM on your own data shows how to build the test set.
Want to see where your own tokens go? Own Weights offers a free AI cost audit. It reads your code as text on your own machine, uploads nothing, and lists each AI call, its model, estimated cost, and checks such as missing output limits and missing prompt caching. You can run the audit yourself, or book a call and we will go through the numbers with you.
Questions
how to reduce token usage
Cut what goes into the call and what comes out of it. Shorten the system prompt, remove examples the model does not need, cap output at the size of your largest useful answer, and request JSON with only the fields your code reads. Check each change against a fixed set of real cases before it ships.
do few-shot examples increase cost
Yes. Examples sit in the input, so you pay for them on every call. Keep the few that cover hard cases, remove the ones that repeat the easy path, and score the prompt again to confirm nothing dropped.
max tokens setting to reduce cost
A max tokens setting limits generated output, which stops a runaway answer from billing you. It does not shorten a normal answer, and a cap set too low truncates the reply, so set it above your longest needed answer and check for truncated responses in code.
json output token overhead
Repeated key names, pretty-printing and extra fields all count as output tokens. Ask for minified JSON with only the fields you read, and use a schema so the model does not wrap the object in prose.
prompt compression
Prompt compression removes words or summarizes text to cut input tokens. It can save tokens, but automated compression can drop a negation or a unit, so score the compressed prompt against your test set before you use it.