LLM API pricing seems simple but has hidden complexity. Understanding how you're billed — and where the edge cases are — is the difference between a predictable AI cost structure and bill shock at the end of the month.
The basics: tokens
Every LLM API bills by token. A token is roughly 4 characters or 0.75 words in English. '1,000 tokens' is about 750 words or a typical page of text. Most providers price input and output tokens separately — output tokens are typically 3–5× more expensive because they require more compute to generate.
Tip
Claude tokenizes slightly differently from OpenAI. Use the respective tokenizer (tiktoken for OpenAI, Anthropic's tokenizer for Claude) to get accurate estimates for your content.
Input vs output pricing
Input tokens are what you send to the model (system prompt + conversation history + documents). Output tokens are what the model generates. For a typical chatbot: input is 80–90% of tokens, output is 10–20%. For code generation: output can be 50–70%. Optimising outputs (constraining format, setting max_tokens) is often the highest-leverage cost reduction.
Context window billing
The context window is the maximum total tokens (input + output) the model can handle in one request. Important: the full context is billed as input even if you only added a few new tokens. In a long conversation, every message re-bills the entire conversation history. Truncating old messages is essential for cost control in long conversations.
Prompt caching discounts
Anthropic and OpenAI both offer prompt caching — if the first N tokens of your request are identical to recent requests, they're served from cache at ~10% of normal input pricing. For apps with long, stable system prompts, this is transformative. A 2,000-token system prompt sent 100K times/day: without caching $600/day, with caching $60/day.
Batch API: 50% off for async
All major providers offer batch pricing — 50% off standard rates for requests that can tolerate up to 24-hour turnaround. Batch is perfect for classification, extraction, summarisation, and embedding generation pipelines that run on a schedule. See the ModelStop batch pricing page for a full comparison across providers.
Hidden costs to watch
1. Tool calls / function calling: each tool call result is billed as additional input tokens. 2. Thinking tokens: Claude's extended thinking and o3's reasoning both generate internal tokens you pay for but don't see. 3. Image inputs: typically billed as equivalent tokens (~1,500 tokens/image). 4. Embedding calls: cheap per token but can add up at millions of documents.
Estimating your monthly bill
Formula: (input_tokens × input_price/1M) + (output_tokens × output_price/1M). Multiply by your daily request volume × 30. Add 20% buffer for variance. Use the ModelStop cost calculator to compare models at your projected volume. Set price alerts so you're notified when pricing changes — it happens more often than you'd expect.
Tip
Monitor actual token usage in production vs estimates. Models often generate more tokens than expected when given open-ended prompts. Set max_tokens to cap runaway responses.
