LLM token optimization: lower AI API costs, same quality output.
Would you mind paying less for AI and getting the same results?
If your product or team runs on Claude, OpenAI or Gemini APIs, a large part of the bill is usually waste: repeated context, oversized models and prompts nobody has reviewed. I find it and remove it, without making the output worse.
Tell me which models you use, roughly how many calls a month and for what.
On this page
Why AI API costs grow faster than usage
LLM APIs charge per token, for everything you send and everything the model writes back. Most applications send far more than the task needs: the same instructions on every call, long examples, whole documents and the full conversation history. The model's actual answer is often the smallest part of the bill.
Illustration of a typical call. Your real breakdown comes from your usage logs.
Every call re-sends the same long instructions
“Our system prompt is 3,000 tokens and we pay for it on every single request.”
Prompt caching is usually the biggest and fastest saving. Anthropic, OpenAI, Gemini and AWS Bedrock can all cache the repeated start of a prompt and bill it at a fraction of the normal price, but only if the prompt is structured for it: stable parts first, changing parts last.
What I do
- Anthropic prompt caching
- OpenAI cached input
- Gemini context caching
- Bedrock prompt caching
- Prompt structure for cache hits
The biggest model does every task
“We use the top model for everything, including tagging and formatting.”
Classifying, extracting, formatting and short rewrites rarely need the most expensive model. Routing each task to the smallest model that does it well, and keeping the large model for reasoning and writing, cuts costs without anyone noticing a difference in the output.
What I do
- Task-by-task model choice
- Claude, OpenAI and Gemini pricing compared
- Routing simple tasks to smaller models
- Output length limits
Prompts grew for months and nobody owns them
“Every fix added another paragraph. Now nobody dares to touch the prompt.”
Prompts that grow by patching become long, contradictory and expensive. I rewrite them as clear, versioned prompts with a test set, so every change can be checked against real examples before it goes live. That's prompt engineering as maintenance, not magic words.
What I do
- Prompt audit and rewrite
- Versioned prompts
- Test sets from real cases
- Shorter context and examples
The output is inconsistent, so you pay to fix it
“Half the generated texts sound the same, and we re-run the rest until they're usable.”
Every retry and manual fix is a hidden cost. In my own content pipelines I use deterministic variation, anti-repetition lists, structured outputs and a self-check step, so the first answer is the usable one. Fewer retries means fewer tokens and less editing time.
What I do
- Structured outputs (JSON)
- Anti-repetition rules
- Self-check steps
- Fewer retries
Bulk jobs run in real time, at full price
“We generate thousands of product texts overnight through the normal API.”
Jobs that don't need an instant answer, like product descriptions, classifications or translations in bulk, can go through the batch APIs from Anthropic and OpenAI at a discounted price. I move them there and set up the pipeline so results flow back automatically.
What I do
- Batch API setup
- Bulk content pipelines
- Usage and cost tracking
- Python and Claude API
How an LLM cost optimization project works
- 1
Measure
Usage logs and invoices: which calls, which models, how many tokens and where they go.
- 2
Find the waste
Repeated context, oversized models, retries and bulk jobs running at full price, ranked by cost.
- 3
Fix and test
Caching, routing, batching and prompt rewrites, each one tested against real examples.
- 4
Keep it measured
Cost per task tracked over time, so the next prompt change doesn't quietly double the bill.