LLM Costs

How to Calculate LLM API Token Costs: Developer's Guide (2026)

Predicting your LLM API bill requires understanding token math. This guide walks through the exact formulas for calculating costs across OpenAI (GPT-6), Anthropic (Claude 5.5), and Google (Gemini 4) APIs, including prompt caching discounts, batch pricing, and monthly projections.

Interactive LLM Cost Calculator

Want to calculate your exact parameters and operational expenses? Run the calculations locally inside your browser.

Launch LLM Cost Calculator

1. The Basic Token Cost Formula

Monthly Cost = (Input Tokens × Input Price / 1,000,000) + (Output Tokens × Output Price / 1,000,000).

For example, sending 10M input tokens and receiving 2M output tokens through GPT-6.1 Sol ($2.00 input, $10.00 output): (10,000,000 × $2.00 / 1,000,000) + (2,000,000 × $10.00 / 1,000,000) = $20.00 + $20.00 = $40.00 per month.

On flagship GPT-6 Astra ($10/$50), that same volume costs $100 + $100 = $200 per month. On historical GPT-5.5 ($3/$12), that same volume cost $30 + $24 = $54 per month.

2. Factoring in Prompt Caching

If your app sends repeated system prompts or documentation, prompt caching slashes input costs. OpenAI GPT-6 provides cached inputs at $0.10/M for Sol and $0.01/M for Luna. Anthropic Claude 5.5 provides cache reads at $0.10/M on Sonnet 5.5. Adjusted formula: Cached Cost = (Fresh Input × Full Price) + (Cached Input × Discounted Price) + (Output × Output Price).

3. Batch API Pricing (50% Savings)

Both OpenAI and Anthropic offer batch processing APIs at 50% off standard rates for non-real-time jobs (content generation, data extraction, eval pipelines). For GPT-6.1 Sol, batch pricing drops to $1.00/MTok input and $5.00/MTok output.

4. Estimating Monthly Token Volume

To estimate monthly tokens:

  • Chatbot: ~2,000 tokens per turn × total conversation turns.
  • Document summarization: ~1,500 tokens per page × total pages processed.
  • Code generation: ~3,000 tokens per request (higher due to syntax tokenization).
  • Multiply by daily/monthly active users to get total projected volume.

5. Cost Optimization Strategies (New & Historical)

Reduce API bills without sacrificing reasoning quality:

  • Route high-volume classification and routing to GPT-6 Luna or Claude Haiku 5.5 ($0.10/MTok).
  • Delegate software engineering and RAG synthesis to Claude Sonnet 5.5 or GPT-6.1 Sol ($2.00/MTok).
  • Reserve flagship models (GPT-6 Astra, Claude Fable 5.2) for complex autonomous decisions.
  • Leverage prompt caching for all system prompts and codebase indexes.

Frequently Asked Questions

Are input tokens and output tokens priced differently?

Yes. Output tokens are typically 3x to 5x more expensive than input tokens because generating text requires sequential autoregressive computation, whereas processing input tokens is executed in parallel.

How do I count tokens before sending a request?

Use a tokenizer library like tiktoken (for OpenAI o200k) or our free AI Token Calculator before dispatching API calls to prevent billing surprises.

What are reasoning tokens and how are they billed?

Reasoning models like Claude Fable 5.2 and OpenAI GPT-6 with extended thinking generate internal chain-of-thought tokens that are billed at output token rates. Budgeting for thinking tokens is critical for autonomous agent pipelines.