LLM Token Economics and Pricing

LLM cost is dominated by token count — input plus output, multiplied by per-token rates that differ by model and by direction. Most teams think they understand the math and then discover their actual bill is 5–10× larger than estimated, usually because of caching they didn't get and outputs they didn't constrain.

This page is the working accounting and the levers that move the bill substantially.

The pricing structure, as of 2026

Major commercial APIs price in dollars per million tokens. Approximate ranges (subject to shifts):

ClassExampleInput (/M) | Output (/M)Cached input
FrontierClaude Opus, GPT-5$15-20$75-100~10% of full input
Mid-tierClaude Sonnet, GPT-4$3-5$15-25~10% of full input
SmallClaude Haiku, GPT-mini$0.20-0.50$1-2~10% of full input
Open weightsLlama, Mistral self-hosted(your hardware)(your hardware)(your cache)

Three takeaways:

  1. Output is 4-5× the price of input. Limiting output length is the single biggest cost lever for verbose tasks.
  2. Cached input is ~10× cheaper than fresh input. Cache hit rate dominates cost on long-prompt workloads.
  3. Mid-tier is 10-20× cheaper than frontier. Most production traffic should be on mid-tier; reserve frontier for tasks where the quality gap pays.

Counting tokens, briefly

Tokens are not characters or words. A token is a chunk of text from a tokenizer's vocabulary — roughly 4 characters or 0.75 words on average for English. Code, especially symbol-heavy code, often tokenizes more finely (~3 chars/token). Other languages vary more.

Practical rule: 1000 tokens ≈ 750 English words ≈ 4000 characters. Useful estimating constant; off by ±20%.

For exact counts, every provider ships a tokenizer:

Don't estimate when actual counts matter (cost forecasting, context-window enforcement). Tokenize.

Prompt caching: the biggest single lever

Both Anthropic and OpenAI cache prompt prefixes. Once cached, subsequent requests with the same prefix re-use the cache at ~10% of the per-token cost. Cached prompts also process faster (lower latency).

The cache key is exact-match on the prefix. Three implications:

  1. Put stable content at the start of the prompt. System prompt → tool definitions → few-shot examples → user query. Stable parts on the left are cacheable.
  2. Volatile content at the end. Timestamps, user IDs, request-specific data. If you put current_time=... in the system prompt, you've broken caching for everyone.
  3. Batch requests with shared prefixes. Agent tools / RAG retrievals with the same system prompt benefit hugely from cache.

A typical agentic system with a 4000-token system prompt and tool definitions can hit 90%+ cache rate on a hot topic. Without caching, the same workload might cost 5-10× more.

Anthropic charges a small premium for the first cached request (≈25% above input price); subsequent cached reads are ~10% of input price. Net win above ~2-3 cache hits.

Caching is feature-flagged for users to opt into in some APIs; turn it on; design your prompts to maximise hit rate; track cache rate as a first-class metric.

Output limits: the second biggest

LLM output cost is per token generated. A request that returns 5000 tokens of detailed prose costs 5× one returning 1000.

Levers:

The classic trap: "the model gave me a verbose answer" → "set max_tokens lower" → answer gets truncated mid-thought. The right fix is usually clearer prompting, not lower max_tokens.

Model routing: cheap for cheap, expensive for hard

Most production traffic doesn't need the biggest model. A typical pattern:

Heuristics that work:

Done well, model routing cuts costs 30-70% with negligible quality drop. Done poorly, the routing logic itself becomes the bottleneck.

Batch APIs

OpenAI, Anthropic, and most providers offer batch APIs at ~50% the price of synchronous calls. Submit a JSONL file of requests; results come back within 24 hours.

Right for:

Wrong for:

Most teams underuse batch APIs. If your batch backfill workload is ≥10% of total LLM spend, moving it to batch is a no-effort 50% reduction on that slice.

Self-hosting trade-off

Self-hosting an open-weights model (Llama, Mistral) eliminates per-token charges but adds infrastructure cost.

Rough break-even (varies wildly with traffic shape):

Self-host wins when:

API wins when:

A cost dashboard

Track these per-model, per-day:

Alert on:

Without these, prompt regressions silently triple your bill before the finance team notices. With them, you catch within a day. See AgentObservability.

Common cost mistakes

Where the puck is moving

Further reading