HOW IS LLM API PRICE CALCULATED
All major providers count in tokens, not characters or words. A token is a piece of text about 3-4 characters for English and noticeably shorter for Russian and code. Practical guideline: Russian text tokenizes worse than English, often 1.5-2 times more tokens for the same meaning. This is the first source of budget underestimation for Russian-speaking teams.
The tariff always consists of two rates per million tokens (per 1M):
- Input — everything you sent: system prompt, dialog history, RAG context, tool definitions.
- Output — what the model generated. This also includes “reasoning” tokens (reasoning/thinking), even if you don’t see them.
The key rule that breaks beginners’ intuition: output is 4-5 times more expensive than input. Therefore a long prompt with a short answer is cheaper than a short prompt with a wall of text on output. You need to count both ends, not just “request size”.
FULL TOKEN COST TABLE 2026
Below — indicative rates per 1M tokens for flagship and working models as of mid‑2026. Claude family numbers are exact (taken from Anthropic’s current price list); for other providers — order of magnitude based on community measurements, always check the specific rate on the provider’s pricing page, as they change often. Fresh model and tool releases are tracked in the REDDYX catalog.
| Model | Class | Input $/1M | Output $/1M | Context |
|---|---|---|---|---|
| Claude Opus 4.8 | flagship | $5.00 | $25.00 | 1M |
| Claude Sonnet 5 | working | $3.00 | $15.00 | 1M |
| Claude Haiku 4.5 | cheap/fast | $1.00 | $5.00 | 200K |
| GPT-класс флагман | flagship | ~$2.5-5 | ~$10-20 | 128K-400K |
| GPT-класс mini | cheap | ~$0.15-0.6 | ~$0.6-2.4 | 128K+ |
| Gemini Pro-класс | working | ~$1.25-2.5 | ~$5-10 | 1M-2M |
| Gemini Flash-класс | cheap/fast | ~$0.1-0.4 | ~$0.4-1.6 | 1M |
| Open-weight (self-host) | self-hosted infra | цена GPU/час | цена GPU/час | depends |
What is immediately visible from the table:
- The difference between the cheap and top tier is about 50-100x. Model choice matters more than any prompt micro‑optimization.
- Within a single provider, the smaller model is usually 3-5 times cheaper than the larger one for the same type of task.
- A giant context (1M tokens) sounds impressive, but filling it completely is a one‑time expense of many dollars just for input.
WHY OUTPUT IS MORE EXPENSIVE AND WHERE REASONING TOKENS ARE HIDDEN
Generating each output token is a separate model pass, so output is more expensive: the provider pays for compute line by line. Input, by contrast, is processed in a single parallel pass (prefill) and is cheaper.
In 2026 there is a separate trap — reasoning tokens. Models with extended thinking (adaptive thinking in Claude, o‑series in GPT, thinking modes in Gemini) generate an invisible chain of reasoning before the final answer. You often don’t see it in the UI, but you pay for it at the output rate. On a difficult task, “thinking” can consume more tokens than the answer itself. If your budget is leaking — first check whether a high effort/reasoning setting is enabled where a direct answer would suffice.
How to quickly estimate request cost
Don't guess by characters — count tokens via the provider's token counter API. Python example for Claude (OpenAI and Google have their own equivalents):
from anthropic import Anthropic
client = Anthropic()
resp = client.messages.count_tokens(
model="claude-opus-4-8",
messages=[{"role": "user", "content": open("prompt.txt").read()}],
)
input_tokens = resp.input_tokens
price_in = 5.00 # $/1M input, Opus 4.8
price_out = 25.00 # $/1M output
expected_output = 800 # estimate expected response length
cost = (input_tokens / 1_000_000) * price_in \
+ (expected_output / 1_000_000) * price_out
print(f"input: {input_tokens} tok")
print(f"оценка стоимости запроса: ${cost:.5f}")
Important: don't use tiktoken for non-OpenAI models — it undercounts by 15-20% on regular text and more on code and Russian. Each provider has its own tokenizer.
THREE LEVERS THAT ACTUALLY CUT THE BILL
1. Prompt caching — up to -90% on input
If you have a large stable prefix (system prompt, documentation, few-shot examples) that repeats from request to request, enable prompt caching. The first request writes the cache (markup ~1.25x on the written portion), subsequent ones read it at ~0.1x the base input rate. Savings on repeated context — up to 90%.
The main cache rule: it's prefix matching. Any byte change at the start of the prompt (date, UUID, unsorted JSON) invalidates the cache further down the text. Keep volatile data at the end of the request, not in the system prompt.
2. Batch mode — -50% on everything
If the task doesn't require real-time response (dataset labeling, mass summarization, offline processing) — run it through Batch API. 50% discount on all tokens. Most batches complete within an hour, ceiling usually 24 hours. For background processing this is the cheapest way to go.
3. Choosing the right model for the task
Classification, field extraction, short 'yes/no' answers — that's work for the cheap tier (Haiku, Flash, mini). Running the flagship on 'determine review sentiment' — burning money 10-50x faster than needed. Take the flagship where correctness matters more than price: complex code, long agent chains, analysis.
- Cheap model + good prompt often beats expensive model on simple task.
- Cache + batch on cheap model — combined savings easily exceed -80% vs naive flagship usage.
SELF-HOST VS API: WHEN YOUR OWN INFRA IS CHEAPER
Open-weight models (Llama, Qwen, Mistral, DeepSeek and derivatives) can be run yourself. Then 'token price' turns into GPU-hour price. Rough threshold from community measurements: while volume is under several tens of millions of tokens per day and load is uneven — API is almost always cheaper and simpler (you don't pay for idle GPU). Your own infra starts winning at large stable volume, data privacy requirements, or when you need fixed latency without someone else's rate limits.
Don't forget the hidden cost of self-host: DevOps, updates, monitoring, hardware downtime. The sticker price of '$0 per token' is deceptive.
BUDGET CALCULATION CHECKLIST BEFORE LAUNCH
- Run real prompts through token counter — don't guess by characters.
- Estimate average response length and multiply by output rate. This is usually the main expense item.
- Check if reasoning/thinking is enabled — and whether it's needed for this task.
- Move stable context into cacheable prefix.
- Move everything possible to cheap tier and/or batch.
- Calculate cost per 1000 requests, not per one — that shows the real scale.
New cheap models and open-weight releases appear every week — convenient to catch them in the REDDYX catalog, where fresh AI/ML tools are collected.
Frequent Questions
Why are output tokens more expensive than input?
Each response token is generated by a separate model pass, whereas the entire input is processed in a single parallel pass. Therefore output costs 4-5x more than input at most LLM API providers.
How much does 1 million tokens cost at Claude?
As of mid-2026: Claude Opus 4.8 — $5 input / $25 output per 1M, Sonnet 5 — $3 / $15, Haiku 4.5 — $1 / $5. Cache and batch mode reduce these amounts further.
How to actually reduce LLM API cost?
Three levers: caching stable prompt prefix (up to -90% on input), batch processing for non-realtime tasks (-50% on everything), and choosing cheap model for simple tasks instead of flagship. Together they give savings beyond -80%.
Can tokens be counted using tiktoken?
Only for OpenAI models. For Claude, Gemini and others, tiktoken underestimates the count by 15-20% and more on code and Russian text. Each provider has its own tokenizer — use its API count_tokens.