Home › Blog › LLM Cost Optimization: The Complete Guide

LLM Cost Optimization: The Complete Guide

By Victor, founder of apicuts

Your LLM bill comes down to four things: how many tokens you send, how many you get back, which model handles them, and how often you pay for the same work twice. This guide covers every lever, in the order that usually pays off first.

Quick answer

Measure cost per request for each route first. Then take the free wins (prompt caching, batch APIs for work that can wait, trimming input and output), and only then the tradeoffs (smaller models, lower reasoning effort). Protect the result with a cost check after every deploy.

What drives the bill

Step 1: Measure before you change anything

Log the usage data from every response with the route name and model, then work out cost per request for each route. Use the token counter to size prompts and the LLM cost calculator to see what a change is worth at your volume.

Step 2: Take the free wins

These lower the bill without touching output quality:

Step 3: Then the tradeoffs

These can save more but can affect quality, so test each one against your evals:

Step 4: Keep it cut

A single prompt change can undo your savings. Cost regression protection compares cost per request after every deploy and flags the release that made it jump.

Where to start

LeverBest forQuality risk
Prompt cachingLong prompts reused across requestsNone
Batch APIsEvals, backfills, nightly jobsNone (slower results)
Output limitsVerbose replies and JSONLow
Model routingClassification, extraction, taggingMedium: test with evals
Lower reasoning effortRoutine chat and simple tasksMedium: test with evals

Provider-specific steps: OpenAI, Anthropic and Google Gemini.

Want us to find your 20%?

Book a free 15-minute API cost teardown. Bring last month's provider usage and we'll show you your biggest waste and the first fix we'd ship.

Get My Free 15-Minute API Cost Teardown

Frequently asked questions

What is LLM cost optimization?

Lowering what you pay for large language model APIs without making answers worse: sending fewer tokens, paying less per token, and not paying twice for the same work.

Which lever usually saves the most?

It depends on the app. Apps that resend long system prompts or documents usually gain most from prompt caching; apps with lots of background work gain most from batch APIs.

How long does LLM cost optimization take?

Finding the waste is usually the slow part. apicuts targets one working day from kickoff to a tested pull request, and guarantees at least 20% lower cost per request.

Related