Compare Prices
ProvidersModelsCompareCalculatorsGuides
Tokens & Pricing6 min readUpdated 2026-11-25

LLM Tokens & API Pricing Explained

How BPE tokenization, input vs. output multipliers, 1M+ context windows, and prompt caching actually determine your monthly LLM API bill.

Key Takeaways
  • 1,000 English words roughly equals 1,300–1,350 BPE tokens, while JSON, TypeScript, and non-Latin text consume significantly more tokens per character.
  • Output tokens typically cost 3x to 5x more than input tokens, and hidden reasoning tokens count as output tokens on reasoning models.
  • Prompt caching reduces repeated system prompt and RAG context input costs by 75% to 98% when prefixes remain byte-identical.

1. What a Token Actually Is (and Why Characters Lie)

Large language models do not read text character-by-character or word-by-word. Instead, they split input into subword chunks called tokens using Byte Pair Encoding (BPE) or SentencePiece vocabularies. Modern OpenAI models (GPT-6.2 Astra, GPT-6.2 Sol, GPT-6 Luna) use the o200k_base vocabulary of 200,000 tokens, whereas Claude 5.5, Gemini 4, DeepSeek V4, and Qwen4 Max ship their own trained tokenizers.

In plain English prose, 1 token averages roughly 4 characters, or about 0.75 words. That heuristic breaks down quickly in real engineering workloads. Indented JSON payloads, UUID strings, stack traces, and minified HTML often average only 2.2 to 3.0 characters per token because punctuation and whitespace splits trigger frequent token boundaries.

Non-English text also varies dramatically by tokenizer. A larger multilingual vocabulary like o200k_base or DeepSeek V4's tokenizer packs common CJK, Spanish, and French subwords more efficiently than legacy 50K-token vocabularies, but you should still measure representative payloads locally before committing to a model tier.

  • Plain English prose: ~1.33 tokens per word (approx. 4.0 chars/token).
  • TypeScript / Python code: ~1.6–2.0 tokens per word due to symbols and indentation.
  • Verbose JSON logs: up to 40% higher token count than compact YAML or CSV.

2. Input vs. Output Pricing & Hidden Reasoning Tokens

Every commercial LLM API bills input tokens (your system prompt, tool schemas, conversation history, and user message) separately from output tokens (the completion streamed back). Output generation is memory-bandwidth bound during autoregressive decoding, so providers price output tokens 3x to 5x higher than input tokens.

For example, Claude Sonnet 5.5 and GPT-6.2 Sol both bill $2.00 per 1M input tokens and $10.00 per 1M output tokens (a 5x ratio), Claude Opus 5.5 bills $4.00/$20.00 per 1M, and frontier tiers like Claude Fable 5.2 and GPT-6.2 Astra bill $8.00/$40.00 per 1M. Meanwhile, Grok 4.7 bills $2.00/$6.00 per 1M (a 3x ratio) and DeepSeek V4 Pro bills $0.79/$1.56 per 1M. In multi-turn chat agents where history grows every turn, input volume dominates; in code-generation or document-drafting pipelines, output volume dominates.

When calling reasoning models such as GPT-6.2 Astra, Claude Fable 5.2, Gemini 4 Neon, or DeepSeek V4 Pro, internal chain-of-thought tokens are billed at the output token rate even when they are summarized or hidden from the final message. Always inspect `usage.completion_tokens_details.reasoning_tokens` (or equivalent provider fields) during load testing.

// Quick monthly cost formula for any LLM endpoint
const inputCost  = (dailyRequests * avgInputTokens  * 30 / 1_000_000) * inputPricePer1M;
const outputCost = (dailyRequests * avgOutputTokens * 30 / 1_000_000) * outputPricePer1M;
const monthlyTotalUSD = inputCost + outputCost;

3. Prompt Caching: The Highest-Leverage Cost Optimization

If your application sends a 4,000-token system prompt plus 15 MCP/function tool definitions on every user request, you are paying repeatedly for identical prefix tokens. Prompt caching stores the computed KV-cache state of that static prefix on the provider's GPU cluster and bills subsequent cache hits at a fraction of normal input pricing.

Anthropic discounts cache reads by 95% on Claude Sonnet 5.5 ($0.10/1M vs. $2.00/1M) and Claude Opus 5.5 ($0.20/1M vs. $4.00/1M), OpenAI discounts cached input by 95% on GPT-6.2 Sol ($0.10/1M vs. $2.00/1M), and DeepSeek V4.1 Flash discounts cache hits automatically by 98% ($0.003/1M vs. $0.15/1M) without explicit cache-control headers.

  • Keep static instructions, tool schemas, and few-shot examples at the very top of your prompt.
  • Place dynamic timestamps, user IDs, and retrieved RAG chunks at the end so you do not bust the cache prefix.
  • Check minimum cacheable prefix thresholds (typically 1,024 tokens for OpenAI/Anthropic).

4. 1M+ Context Windows vs. Effective Cost

A 1,000,000+ token context window is now standard across Claude Sonnet 5.5 (1M), GPT-6.2 Sol (1.05M), Gemini 4 Neon (1M), Gemini 3.8 Flash (1M), Qwen4 Max (1M), and DeepSeek V4 Pro (1M)—and Grok 4.20 even stretches to 2M tokens. Still, massive context does not mean you should stuff an entire monorepo into every prompt. At $2.00 per 1M input tokens, a single 500K-token call costs $1.00 before generating a single output word—and prefill latency rises sharply.

Use targeted retrieval, file summaries, or our free LLM Token Counter and API Cost Calculator to benchmark prompt sizes before deploying automated loops or background cron agents.

More Developer Guides

All guides