LLM API Costs: What Drives Them and How to Cut Them
LLM API costs are driven by four things: the model you pick, how many tokens you send and receive, how often you call it, and how much of your traffic hits cache or gets wasted on retries and dead ends. Most teams overspend not because the per-token price is high, but because they don't measure any of these four levers until the invoice arrives.
If you're trying to figure out why your bill looks the way it does, or how to plan a budget before you ship a feature, the answer isn't "switch to a cheaper model." It's understanding where the tokens actually go, then optimizing the parts that matter.
What You're Actually Paying For
Every LLM API charges per token, split into input and output, usually with output priced 3-5x higher than input. A "token" is roughly 4 characters of English text, so a 1,000-word prompt is about 1,300 tokens.
Costs come from three places:
- Input tokens — your prompt, system instructions, conversation history, and any retrieved documents or tool results you inject.
- Output tokens — the model's response, including any tool calls, reasoning, or structured JSON it generates.
- Overhead — retries after timeouts, redundant context sent on every turn of a conversation, and calls that fail validation and get resent.
Conversation history is the silent budget killer. If your app resends the full chat transcript on every turn (which most do, because the API is stateless), a 20-turn conversation can cost 10x more in cumulative input tokens than the first message alone.
How to Estimate Your Real Spend
Before optimizing, get a baseline. Multiply average tokens per request by requests per day by 30, then apply the model's per-million-token rate for input and output separately.
daily_input_tokens = avg_input_tokens * requests_per_day
daily_output_tokens = avg_output_tokens * requests_per_day
monthly_input_cost = (daily_input_tokens / 1_000_000) * input_price * 30
monthly_output_cost = (daily_output_tokens / 1_000_000) * output_price * 30
Do this per feature, not just per app. A summarization endpoint and a chat assistant have wildly different token profiles, and lumping them together hides which one is actually expensive.
Where the Waste Usually Is
Oversized system prompts. Teams paste entire style guides, tool schemas, and few-shot examples into every request, even for simple queries. If your system prompt is 2,000 tokens and your average user message is 50 tokens, you're paying 40x overhead on every call.
No caching for repeated context. If multiple requests share a long, unchanging prefix (a system prompt, a document, a set of instructions), sending it fresh every time multiplies cost for no benefit. Prompt caching, when the provider supports it, can cut repeated-context costs significantly.
Verbose output when you only need a fact. Asking a model to "explain your reasoning" or return prose when you actually need a single field wastes output tokens, which are the expensive half of the bill. Constraining output format (JSON, short answers, max tokens) is one of the highest-leverage cost fixes available.
Retrying on transient errors without backoff. A naive retry loop that resends the full prompt on every 429 or timeout can double or triple effective spend during a bad network period.
Using a large model for small tasks. Classification, extraction, and short rewrites rarely need your most capable model. Routing simple tasks to a smaller or cheaper model tier and reserving the expensive one for genuinely hard reasoning is standard practice at scale.
Concrete Ways to Cut LLM API Costs
- Trim system prompts to what's actually used. Audit them quarterly; unused instructions and stale examples accumulate.
- Cap output length with a max_tokens setting appropriate to the task instead of leaving it unbounded.
- Summarize or truncate conversation history instead of resending the full transcript once it passes a length threshold.
- Batch non-urgent work where the provider offers a discounted batch/async tier for latency-tolerant jobs.
- Cache deterministic responses at the application layer for identical or near-identical requests (FAQs, repeated lookups).
- Set per-key or per-feature budget alerts so a bug in a retry loop doesn't turn into a five-figure surprise.
- Track cost per request, not just total spend, so you can see which feature or customer segment is driving the bill.
That last point matters more than it sounds. Aggregate monthly spend tells you almost nothing about why it went up. Per-request and per-endpoint breakdowns tell you exactly which prompt to fix.
Turning Existing Claude Access Into a Metered API
If you're already paying for Claude and want to build against it as an API without separately provisioning and managing platform billing, SubToAPI turns your existing access into a standard HTTPS API with application keys (sub_live_...), streaming, tool use, and usage metadata per request. That per-request metadata is exactly what you need to see token counts by endpoint and catch a runaway prompt before it becomes a pattern.
Plans are flat per-seat pricing — Solo at €9, Team at €19/seat, Scale at €49/seat — with a free trial at signup, so cost tracking is a fixed line item rather than a variable one tied to raw token volume. You can see request and response shapes in the docs, get started with the quickstart, and check the messages and streaming references before wiring it into an existing app.
The Bottom Line
LLM API costs aren't a fixed tax you accept — they're a function of prompt size, output length, model choice, and how much redundant context you're pushing through the pipe. Measure per-feature spend first, fix the top three offenders (usually system prompt bloat, unbounded output, and full conversation replay), and re-measure. Most teams find 30-50% of their spend disappears without any change to the actual model or the user experience.
Questions
Is a cheaper model always the answer to high LLM API costs? No. Switching models helps only if the cheaper model handles your task well enough; otherwise you pay for retries and lower quality. Fix prompt size and output length first, then evaluate whether a smaller model still meets your accuracy bar.
Does prompt caching actually reduce costs meaningfully? Yes, when a large chunk of your prompt (system instructions, a document, tool schemas) repeats across requests unchanged. The savings scale with how much of your token volume is that repeated prefix versus unique per-request content.
How do I catch cost spikes before the monthly invoice? Set per-key or per-feature budget alerts and track cost per request in near real time, not just aggregate monthly totals. A retry loop or a prompt regression usually shows up in daily numbers days before it shows up on the bill.