LLM API Pricing 2026: Claude, OpenAI, Gemini Compared
# LLM API prices change quarterly. This 2026 comparison of Claude, OpenAI GPT, and Gemini covers input/output pricing, cache pricing, batch discounts, and the hidden costs teams miss until the bill arrives.
LLM pricing has fallen 80% since 2023, but picking the wrong model for your workload still means overpaying by 10–50×. This comparison covers the models that matter in production in 2026 — with real pricing, hidden costs, and the decision logic to pick the right one.
2026 Pricing Reference
All prices in USD per million tokens (input / output).
Anthropic Claude
| Model | Input | Output | Cache read | Cache write | Context | |-------|-------|--------|-----------|------------|---------| | Claude Haiku 4.5 | $0.80 | $4.00 | $0.08 | $1.00 | 200K | | Claude Sonnet 4.6 | $3.00 | $15.00 | $0.30 | $3.75 | 200K | | Claude Opus 4.8 | $15.00 | $75.00 | $1.50 | $18.75 | 200K |
OpenAI GPT
| Model | Input | Output | Cache read | Context | |-------|-------|--------|-----------|---------| | GPT-4o mini | $0.15 | $0.60 | $0.075 | 128K | | GPT-4o | $2.50 | $10.00 | $1.25 | 128K | | GPT-5 | $10.00 | $40.00 | — | 128K | | o3 mini | $1.10 | $4.40 | — | 200K |
Google Gemini
| Model | Input | Output | Cache | Context | |-------|-------|--------|-------|---------| | Gemini 2.0 Flash | $0.10 | $0.40 | $0.025 | 1M | | Gemini 2.5 Pro | $1.25 | $10.00 | $0.31 | 1M |
Prices as of June 2026. Verify at each provider's pricing page — these change frequently.
The Real Cost Formula
Sticker price × tokens is only part of the bill:
function realMonthlyAICost(params: {
monthlyRequests: number;
avgInputTokens: number;
avgOutputTokens: number;
model: string;
cacheHitRate: number; // 0–1
batchFraction: number; // 0–1 of requests using batch API
}): number {
const pricing: Record<string, { in: number; out: number; cacheRead: number; cacheWrite: number }> = {
"claude-haiku": { in: 0.80, out: 4.00, cacheRead: 0.08, cacheWrite: 1.00 },
"claude-sonnet": { in: 3.00, out: 15.00, cacheRead: 0.30, cacheWrite: 3.75 },
"claude-opus": { in: 15.00, out: 75.00, cacheRead: 1.50, cacheWrite: 18.75 },
"gpt-4o": { in: 2.50, out: 10.00, cacheRead: 1.25, cacheWrite: 0 },
"gpt-4o-mini": { in: 0.15, out: 0.60, cacheRead: 0.075, cacheWrite: 0 },
"gemini-flash": { in: 0.10, out: 0.40, cacheRead: 0.025, cacheWrite: 0 },
};
const p = pricing[params.model];
const reqs = params.monthlyRequests;
const inM = params.avgInputTokens / 1_000_000;
const outM = params.avgOutputTokens / 1_000_000;
const cacheHits = reqs * params.cacheHitRate;
const cacheMisses = reqs * (1 - params.cacheHitRate);
const inputCost = (cacheMisses * inM * p.in) + (cacheHits * inM * p.cacheRead);
const outputCost = reqs * outM * p.out;
const cacheWriteCost = cacheMisses * inM * p.cacheWrite * 0.25; // first 25% triggers write
// Batch discount: 50% off (where available)
const batchDiscount = params.batchFraction * (inputCost + outputCost) * 0.5;
return inputCost + outputCost + cacheWriteCost - batchDiscount;
}
Scenario: Customer Support Bot
10,000 conversations/month, avg 1,500 input + 300 output tokens, 70% cache hit rate:
| Model | Monthly cost | |-------|-------------| | Gemini Flash | $5 | | GPT-4o mini | $8 | | Claude Haiku | $20 | | GPT-4o | $120 | | Claude Sonnet | $150 | | Claude Opus | $650 |
Verdict: Gemini Flash or GPT-4o mini. Claude Haiku if you need better instruction following.
Scenario: Technical Documentation Q&A
5,000 queries/month, avg 8,000 input (docs) + 500 output tokens, 85% cache hit (docs change rarely):
| Model | Monthly cost (no cache) | With 85% cache | |-------|------------------------|----------------| | Claude Haiku | $360 | $70 | | Claude Sonnet | $1,320 | $260 | | GPT-4o | $1,030 | $285 |
Verdict: Prompt caching is massive for doc-heavy workloads. Claude Haiku with caching often beats GPT-4o-mini without caching.
Scenario: Code Generation Agent
1,000 tasks/month, avg 3,000 input + 2,000 output tokens (long outputs), no cache benefit:
| Model | Monthly cost | Pass rate | Cost per working output | |-------|-------------|-----------|------------------------| | GPT-4o mini | $5 | 70% | $7 | | Claude Haiku | $15 | 75% | $20 | | Claude Sonnet | $90 | 92% | $98 | | GPT-4o | $65 | 88% | $74 |
Verdict: GPT-4o for code generation — better pass rate at lower cost than Sonnet for typical code tasks. But validate this with your specific codebase and evaluation criteria.
Hidden Costs
1. Retry tokens: If your success rate is 80% and you retry failures, add 25% to your token budget.
2. Evaluation calls: LLM-as-judge costs money. At 5% sampling + 500 tokens per eval + Haiku: adds ~$0.002/request.
3. Embedding calls: For RAG systems, add $0.02/M tokens for text-embedding-3-small. 1M documents × 500 tokens = $10 to index.
4. Prompt development waste: Teams spend 50–200K tokens on failed prompt experiments. Not on the invoice but real money.
5. Context window underutilization: Paying for a 200K context window but only using 5K on every call means you might be better on a cheaper per-token model.
Batch API for Non-Real-Time Work
OpenAI and Anthropic both offer ~50% batch discounts for async processing:
// Anthropic batch API — 50% off, results within 24 hours
const batch = await anthropic.messages.batches.create({
requests: documents.map((doc, i) => ({
custom_id: `doc-${i}`,
params: {
model: "claude-sonnet-4-6",
max_tokens: 500,
messages: [{ role: "user", content: `Summarize: ${doc}` }],
},
})),
});
// Poll for results
const results = await anthropic.messages.batches.results(batch.id);
Use batch for: nightly data processing, bulk document indexing, evaluation runs, non-urgent summarization.
Model Selection Decision Tree
Cost sensitivity: extreme → Gemini Flash
Quality requirement: highest → Claude Opus
Long context (>128K): required → Claude or Gemini
Coding tasks: primary → GPT-4o or Claude Sonnet
Chat/support: primary → GPT-4o mini or Claude Haiku
Structured output: critical → Claude Sonnet (best instruction following)
Provider lock-in: avoid → maintain fallback chain across 2+ providers
FAQ
Should I lock to one provider? No — all major providers have outages and rate limits. Implement a fallback chain (primary: Claude Sonnet → fallback: GPT-4o → emergency: Haiku). See Model Routing in Production.
Are there free tiers worth using in production? Gemini's free tier (generous limits) works for prototyping. Groq's free tier for Llama is fast for experimentation. For production, pay for rate limits and SLAs — free tiers have unpredictable throttling.
How often do prices change? Major providers update pricing every 1–3 months. Set a calendar reminder to check quarterly. Subscribe to provider newsletters — price drops usually come with capability improvements.
Does output token pricing matter more than input? For chat/Q&A: output is 5–10× more expensive per token, but input is typically 3–10× more tokens. They often balance out. For generation-heavy tasks (writing, code): output cost dominates.
How do I forecast costs before launch? Run 100–500 representative requests, measure average tokens per request, multiply by projected volume. Add 30% buffer for retry overhead and traffic spikes.