/ Guides / Cost calculation

How to calculate LLM API costs

Input tokens · output tokens · cache · monthly usage

The cost calculator gives you the answer directly; this guide explains the principles, steps and common mistakes behind it, so you can recompute any vendor's price list yourself. All worked examples use Reflex Hub's single data source (models.json) with official sources and verification dates you can check step by step. The complete rules for how we compile and present pricing data are in the pricing methodology.

1. What determines API cost

Mainstream LLM APIs bill by token usage. A monthly bill decomposes into four terms:

· Call count: how many requests you make per day;
· Input tokens: the content sent per request (system prompt, conversation history and the user's input all count);
· Output tokens: the content the model generates per request;
· Unit prices: input and output are billed separately per 1M tokens at different rates; some vendors add a cache-hit price and peak/off-peak rates.

Scope: this article covers pay-as-you-go chat/reasoning APIs billed by tokens. Subscription bundles, per-call billing (some image/video endpoints) and reserved capacity follow their own billing documents.

2. Price units and multi-currency handling

Prices are quoted per 1M tokens, consistent with official vendor pricing pages. A token is the smallest unit of text a model processes: roughly 1–2 tokens per Chinese character and about 1 token per English word, depending on each vendor's tokenizer. Mind the conversion: vendors quote "price per 1M tokens", while a single request is usually far below a million — divide by 1,000,000 first.

Original currencies are preserved: Chinese vendors (DeepSeek, GLM, Kimi, Qwen, Hunyuan, MiniMax, MiMo, Step) list prices in CNY; OpenAI / Anthropic / Google models are listed in USD. For comparison and estimation, USD prices are converted to CNY at a reference rate (the CFETS central parity rate, with the rate date shown) — indicative only. This site never disguises a $ list price as ¥ and never compares raw numbers across currencies.

3. The formula

Compute input and output separately, then add:

· Input cost = calls × input tokens per call ÷ 1,000,000 × input price
· Output cost = calls × output tokens per call ÷ 1,000,000 × output price
· Total cost = input cost + output cost

The input price may not be a single value: the portion that hits context cache is billed at the lower cache-hit price, so:

· Effective input price = hit rate × cache-hit price + (1 − hit rate) × cache-miss price

For time-based priced models (e.g. DeepSeek), first determine whether the request lands in a peak or off-peak window — the unit prices differ. Models without a published cache price have no cache-hit price to apply and must be billed at the miss price — unknown is not zero.

4. Context-length tiers

Some models bill by per-call input length: MiniMax M3, for example, charges the lower tier for inputs ≤512K (input ¥2.1 / output ¥8.4 per 1M tokens) and jumps to the higher tier above 512K (¥4.2 / ¥16.8); Claude Haiku 5.5 splits at a 100K prompt length into $0.1 / $0.5 tiers. Pick the tier from your per-call input length first, then apply the formula.

Unpublished tiers are never back-filled: the >272K long-context tier rates for GPT-6 Luna and GPT-6.1 Sol are not published on the official pricing pages — estimates in that range must honestly return "cannot estimate"; borrowing the lower tier's price would produce a falsely low number. This site's calculator and comparison pages refuse to estimate unpublished tiers.

In common businesses where a single input stays below the lower-tier ceiling (most chat, RAG and agent workloads are far below 100K–512K), tiers do not affect the result; only whole-document injection needs a tier-boundary check first.

5. A reproducible worked example

The table below walks through every step with a real model whose data is complete (including a published cache price). All values come from this site's single data source models.json; the model page carries the official source and verification date:

Model & source GLM-5.3 (Alibaba Cloud Model Studio · Zhipu (direct)), list prices: input ¥8 / output ¥28 / cache hit ¥2 per 1M tokens; official source, verified 2026-10-28
Step 1: effective input price30% × ¥2 + 70% × ¥8 = 6.2 CNY/1M tokens
Step 2: input cost100 calls/day × 30 days × (2000 ÷ 1,000,000) × 6.2 = ¥37.20
Step 3: output cost100 calls/day × 30 days × (800 ÷ 1,000,000) × ¥28 = ¥67.20
Step 4: total¥104.40 / month (list-price estimate, not an actual invoice)

To verify: substitute the table's values into the section-3 formula by hand, or open the cost calculator, select the same model and use the same parameters (100 calls/day · 2,000 input · 800 output · 30% hit rate) to compare results.

6. Cache read-write and peak/off-peak prices

Cache-hit price: when a request shares a prefix with previous requests, vendors allow it to hit the context cache, and the hit portion is billed at a cache price well below the standard input price. Keeping a stable system prompt and document prefix raises the hit rate. Only models with a published cache price get this discount; this site bills unpublished models at the miss price and never assumes a cache discount.

Cache write fees are an easily overlooked charge: some vendors bill cache writes separately (e.g. GPT-6 Luna's 30-minute tier at $0.125/1M tokens, Anthropic's 5-minute tier from $0.125). Write fees couple with retention duration and usage assumptions, so example monthly costs on this site exclude them; each model profile notes them separately.

Peak/off-peak pricing: take DeepSeek as an example — peak hours (weekdays 9:00–12:00 and 14:00–18:00, Beijing time) bill at standard rates, while all other times (nights, lunch hours, weekends and public holidays) bill at about half. Scheduling deferrable batch jobs into off-peak windows is a deterministic cost reduction. This site's calculator and comparison pages compute example monthly costs at the off-peak basis by default and say so on the page.

7. From per-call cost to monthly estimates

Monthly estimate = daily calls × 30 days × per-call cost. Three assumptions need your real business numbers:

· Call count: use average daily requests from logs, not peaks;
· Input per call: count the system prompt, conversation history and the current input together — input grows with turns in multi-turn chats;
· Output per call: long-form generation can produce far more output than input, and output is usually priced higher.

Example monthly costs on this site's comparison pages fix 100 calls/day, 2,000 input / 800 output tokens per call, off-peak rates and a 30% cache hit rate. They exist for horizontal comparison only — they are not your actual bill.

8. Common mistakes

· Mistake 1: input and output cost the same. Output is usually 2–4× the input price; pricing by input alone severely underestimates;
· Mistake 2: treating unknown prices as zero. An unpublished cache price does not mean caching is free — pricing it at zero fabricates a low cost;
· Mistake 3: comparing raw numbers across vendors. Tier boundaries and discount strategies differ; normalize first — list prices, same tier, same usage assumptions;
· Mistake 4: ignoring the output share. Summarization and writing workloads are often output-dominated — raise the output weight in your estimate;
· Mistake 5: treating an estimate as an invoice. Free tiers, resource packs and tiered pricing can all push the real bill below the list-price estimate — or above it once free quotas run out. Estimates are for budgeting and comparison only.

9. Data sources and verification

Reflex Hub maintains model prices and specs in a single data source, models.json; every record carries an official source link and a "last verified" date (verifiedAt), and the footer aggregates all sources. Price-verification time ≠ page-content update time: when a price is re-verified without changes, the page and sitemap dates stay unchanged (full semantics in the pricing methodology). We re-check items individually, but two limitations remain: values the vendor has not published (e.g. some context windows) stay marked undecided rather than invented; and prices change as vendors adjust them — when reusing an example from this article, confirm the current price on the corresponding official page.

10. Next steps

· Plug in your real usage and estimate monthly costs per model in the cost calculator;
· Browse per-model pricing and spec profiles in the model library (a USD-priced example: the GPT-6 Luna profile);
· Torn between two candidates? Compare them line by line with model comparison, e.g. DeepSeek V4.1 Flash vs GLM-5.3-Flash;
· For whole-market price differences at fixed assumptions, read the pricing comparison guide;
· For business-scenario estimation (chatbot / RAG / coding agent), read the cost scenarios guide;
· All guides: guide directory.