How Are LLM API Tokens Priced? A Cost Breakdown and Guide to Cutting Costs
A practical, provider-neutral framework for understanding how LLM API tokens are priced and for keeping spend under control. It explains how input, output, and cached tokens are billed and why, shows how to turn a price sheet into per-task and effective cost, and lays out six engineering levers—budgeting, input/output optimization, tiered model routing, call governance, and monitoring—for cutting token costs without sacrificing quality.
Introduction: Unit Price Is Just the Starting Point, the Bill Is the Destination
When a new generation of large models launches, developers usually start by discussing the price sheet: how much inputs, outputs, and cache hits cost, and how many times higher they are than the previous generation. But if you’re searching for things like “how are LLM API tokens priced,” “how to reduce token costs,” or “how to choose a model and plan,” you’ll find that deciding based on unit price alone tends to lead to misleading conclusions:
- “Expensive” is a relative measure. Pricing strategies, promotional cycles, and billing conventions differ across providers, so comparing a single price sheet often gives unreliable conclusions.
- Unit price doesn’t translate directly into cost. Actual spend depends on how many tokens you use, how inputs and outputs are balanced, whether caches hit, and how many times you retry failures. The same price sheet can correspond to completely different bills for different workloads.
- Capability differences change the cost structure. A more capable model may reduce retries, cut manual corrections, and shorten task chains, so the actual cost per task can end up lower.
So this article doesn’t judge whether any specific service is “worth it.” Instead, it offers a general framework: break price into calculable cost items, translate cost back into business metrics, then optimize each item through engineering. The interfaces and parameters here are illustrative; actual capabilities are governed by each provider’s official documentation.
How Are LLM API Tokens Priced? The Billing Logic for Three Token Types
Most mainstream services bill “by token.” A token is the basic unit the model uses to process text and isn’t equivalent to a character count: English usually maps several characters to one token, while Chinese often needs one or more tokens per character. Billing generally splits into three types, and the price differences have clear reasons rooted in inference mechanics.
Input tokens (prefill): When processing the prompt, the model runs a single forward pass over all input tokens, which can be massively parallelized with high compute utilization. Longer inputs use more memory, but the per-token processing cost stays relatively controllable, so input prices are usually lower.
Output tokens (token-by-token generation): When generating a response, the model produces tokens autoregressively—each new token requires another forward pass based on everything generated so far, with the bottleneck coming more from memory bandwidth. Generating the same number of tokens, output consumes noticeably more service time, so output unit prices are generally several times the input price. Reasoning models deserve special attention on output: they generate a “thinking” segment before the answer, and that thinking is billed as output too, so on slightly complex problems the output volume can grow several-fold.
Cached tokens (prefix reuse): Many services cache repeated prefixes (fixed system prompts, tool definitions, long background material) and charge a discounted price on a subsequent hit. But caching has clear boundaries:
- Writing to the cache may incur a one-time premium;
- Caches are usually valid only for a limited time (TTL, commonly a few minutes to tens of minutes);
- Most services require the prefix to reach a minimum length (e.g., 512 or 1024 tokens) before caching kicks in;
- The cache key is usually a hash of the prefix content, model, and other parameters, so any change causes a miss;
- Only an exactly identical prefix can hit.
The TTL, minimum prefix length, and cache-key composition above should be confirmed against the provider’s documentation. There may also be tiered pricing (the unit price jumps once input exceeds a length), batch discounts (offline batch processing is cheaper but with looser latency), and multimodal conversion (images and audio are first converted to tokens before billing).
| Type | Inference stage | Parallelism | Typical relative unit price | Optimization direction |
|---|---|---|---|---|
| Input tokens | Prefill | High | Baseline (1×) | Trim prompt, compress retrieval, reuse stable prefixes |
| Output tokens | Token-by-token generation | Low, serial | Several times input | Cap output length, structured output, control thinking depth |
| Cached tokens | Reuse on hit | — | Discounted input price | Keep prefix stable, maximize hit rate |
Note: relative unit prices are illustrative; actual prices follow each provider’s published rates.
How Do You Calculate Task Cost from a Price Sheet? A Cost Modeling Method
Once you have the prices, you can estimate the cost of a single call with this formula:
Single-call cost ($)= uncached input tokens / 1,000,000 × input price+ cached input tokens / 1,000,000 × cache price+ output tokens / 1,000,000 × output price
In a real system, one business task often requires multiple calls (intent recognition, retrieval rewriting, generation, verification) plus retries on failure. If the probability of a single failure is p, the expected number of calls to succeed with independent retries is 1/(1−p): at p=20% cost inflates 1.25×, and at p=50% it doubles outright.
Metrics closer to business reality are task cost and effective cost:
Task cost = total call cost / successful tasksExpected manual-correction cost = failure rate × correction rate × cost per correctionEffective cost = pure call cost + expected manual-correction cost
Where failure rate = 1 − first-pass success rate, and correction rate = the proportion of failed tasks that need human intervention. The examples below only illustrate the calculation method.
Table 1: Per-call cost for two hypothetical options (unit price in $ per million tokens)
| Option | Input price | Output price | Cache-hit price | Uncached input | Cached input | Output | Per-call cost |
|---|---|---|---|---|---|---|---|
| A (standard model) | 4 | 16 | 0.4 | 2,000 | 8,000 | 500 | $0.0192 |
| B (reasoning model) | 20 | 100 | 1 | 2,000 | 8,000 | 1,500 | $0.198 |
Item-by-item check:
- Option A: input 2,000×4÷10⁶=$0.008, cache 8,000×0.4÷10⁶=$0.0032, output 500×16÷10⁶=$0.008, total $0.0192.
- Option B: input 2,000×20÷10⁶=$0.04, cache 8,000×1÷10⁶=$0.008, output 1,500×100÷10⁶=$0.15, total $0.198.
Both options use the same number of input tokens. For Option A the input side totals about $0.0112 (uncached $0.008 + cache-hit $0.0032), and the 8,000 cached tokens cost only $0.0032. Option B, meanwhile, hits $0.15 on output alone—nearly 8× Option A’s entire cost; and within Option B, raising output from 500 to 1,500 tokens (at its unit price of 100) adds $0.1 by itself. Output tokens are the biggest cost variable.
Now at the task level (assuming one call completes one deliverable):
| Metric | Option A | Option B |
|---|---|---|
| Per-call cost | $0.0192 | $0.198 |
| First-pass success rate | 70% | 92% |
| Failure rate | 30% | 8% |
| Expected calls (1÷success rate) | ≈1.43 | ≈1.09 |
| Pure call cost | ≈$0.027 | ≈$0.215 |
Adding manual correction (correction rate 30%):
| Correction-cost scenario | Option A effective cost | Option B effective cost |
|---|---|---|
| $0.5 per time | 0.027+0.30×0.30×0.5≈$0.072 | 0.215+0.08×0.30×0.5≈$0.227 |
| $1.5 per time | 0.027+0.30×0.30×1.5≈$0.162 | 0.215+0.08×0.30×1.5≈$0.251 |
Option A is far cheaper per token, but because it retries and fails more, the gap narrows considerably: as correction cost rises from $0.5 to $1.5, Option B’s disadvantage relative to Option A shrinks from about 3.2× to about 1.5×. Further calculation shows that when the cost of a single manual correction exceeds about $2.85, the two have equal effective cost, and beyond that Option B is actually cheaper—while in reality human intervention usually costs far more than that. Task success rate and human-intervention rate matter more than unit price.
As for subscription plans, the “plan price × X times usage” marketing exists because the unit price derived from a plan is usually far lower than pay-as-you-go. But the equivalent-usage range assumes different input/output ratios: the higher the output share, the smaller the equivalent usage. To judge whether it’s worth it, convert your expected usage into tokens and check item by item:
- Monthly input/output token ratio (the higher the output share, the less worthwhile the plan);
- Total quota included in the plan and the equivalent-usage range;
- Whether quota expires monthly or carries over;
- Whether there’s rate limiting (RPM/TPM) and how overage is billed;
- Whether cache hits are billed separately and whether they count toward quota.
Convert these into “actual price per million tokens” and compare against pay-as-you-go.
How Do You Reduce Token Costs? Six Actionable Levers
4.1 Budget First: You Can’t Control What You Can’t Estimate
Most services ship a companion tokenizer. In production you should read the actual usage returned in responses; the local library is only for pre-launch estimation:
# Requires install: pip install tiktoken# cl100k_base is for illustrative estimation only; the target model's tokenizer# may differ. In production, rely on the actual usage returned in the response,# and account for cache costs separately.import tiktokendef estimate_cost(prompt, completion, price):enc = tiktoken.get_encoding("cl100k_base")in_tokens = len(enc.encode(prompt))out_tokens = len(enc.encode(completion))cost = (in_tokens * price["input"] + out_tokens * price["output"]) / 1_000_000return {"input_tokens": in_tokens, "output_tokens": out_tokens, "cost": round(cost, 6)}PRICE = {"input": 4.0, "output": 16.0} # illustrative unit price: $ per million tokens
Calibrate estimates against actual response usage regularly; when the deviation stays above a threshold, check the tokenizer version or how requests are constructed.
4.2 Input Optimization: Make the Prompt “Lighter”
Trim templates (remove redundant examples and irrelevant fields); compress retrieved content (rerank for relevance, then summarize or extract snippets instead of stuffing whole documents into context); reuse prefixes (put stable content first and keep it byte-for-byte identical, put volatile content later—never concatenate the current date or random IDs into the system prompt, or the prefix changes every time); for long conversations, use rolling summaries and keep only recent turns verbatim.
4.3 Output Optimization: Cap the Most Expensive Part
Set a max_tokens limit; use structured output with constraints like a JSON Schema; for long-form work, “outline first, then write in sections”; for reasoning models, choose a thinking-effort tier (low/medium/high) by task complexity instead of over-engineering simple tasks; with streaming responses, stop early once the result meets your acceptance criteria to save tokens never generated.
4.4 Tiered Routing: Give Simple Tasks to Small Models
Route by tiers—“rules → small model → large model”—sending format conversion and classification/tagging to low-cost options and escalating to bigger models only for complex reasoning. Agent-style apps especially need guardrails:
def complete(messages, tools=None):resp = llm.chat(model="light", messages=messages, tools=tools)if resp.need_escalation: # let the lightweight model decideresp = llm.chat(model="pro", messages=messages, tools=tools)return respdef with_budget(messages, budget):cost = 0.0for _ in range(MAX_STEPS): # cap the agent's max stepsif cost >= budget: # budget guardrailreturn {"status": "budget_exceeded"}r = llm.chat(messages=messages)cost += r.usage.input * PRICE["input"] / 1e6cost += r.usage.output * PRICE["output"] / 1e6if r.done:return r
If you let the model decide whether to call a tool at every step, the task can loop and tokens keep accumulating, so set both a max-step count and a budget cap.
4.5 Call Governance: Reduce Waste
Generate an idempotency key per request to prevent duplicate submissions from causing duplicate calls; retry by tier—use exponential backoff only for recoverable errors like rate limits and timeouts, and don’t retry parameter errors or content-moderation rejections; route offline tasks through batch endpoints and merge small requests; add result caching for identical or similar requests, with sensible expiry based on how often the underlying knowledge updates.
4.6 Monitoring and Alerting: Make Cost Observable
Log the request ID, business scenario, model tier, input/cache/output tokens, whether the cache hit, latency, and success for each call, and configure alerts with thresholds and remediation actions:
- Sudden daily cost spike: e.g., day-over-day increase over 50% sustained for 10 minutes—investigate abnormal calls or loop logic;
- Cache-hit rate drops sharply: e.g., down more than 20 percentage points day-over-day—check whether the prompt prefix was modified;
- Average output length rises: e.g., up 30% from baseline—check for missing output-length constraints;
- Failure rate spikes: failed retries can multiply cost several-fold, so locate the cause immediately.
Conclusion
“A generation’s output unit price rising several-fold” is just a price-level signal; it’s a prompt to re-evaluate your cost structure, not a simple verdict of expensive or cheap. What really determines the bill is how token usage is distributed, whether caches hit, how many retries occur, whether tasks are right on the first try, and how much needs human backup. Rather than argue over which price sheet is lower, do three things: build a cost model from business data to compute task cost; benchmark capabilities on the same sample set to verify that cost cuts don’t come at the expense of quality; and bake budget, cache, routing, and monitoring into the system so cost stays controllable over time. When task cost is calculable, comparable, and optimizable, model selection shifts from “guessing prices” to “reading the data.”
