Complete guide to Claude Code pricing in 2026: Pro vs Max plan, API billing, cost per session, how to estimate usage, and tips to reduce Claude Code costs.
Claude Code has two pricing modes: subscription (via Claude.ai) and API billing (via ANTHROPIC_API_KEY). Here's everything you need to know to pick the right option and control costs.
Plan comparison
Plan
Monthly cost
Claude Code usage
Best for
Claude.ai Free
$0
No Claude Code access
Claude.ai chat only
Claude.ai Pro
$20/mo
Limited (1-2h/day typical)
Part-time coding use
Claude.ai Max (5×)
$100/mo
5× Pro rate limits
Full-time developer use
Claude.ai Max (20×)
$200/mo
20× Pro rate limits
Power users / heavy teams
API billing (own key)
Pay per token
Unlimited (rate limits apply)
CI/CD, automation, teams
API pricing (per-token, 2026)
Model
Input (per 1M tokens)
Output (per 1M tokens)
Cache write
Cache read
claude-sonnet-4-6
$3.00
$15.00
$3.75
$0.30
claude-haiku-4-5
$0.80
$4.00
$1.00
$0.08
claude-opus-4-7
$15.00
$75.00
$18.75
$1.50
Real-world cost estimates
Task
Typical tokens
Sonnet cost
Haiku cost
Review a PR (500 line diff)
5K in + 1K out
~$0.03
~$0.008
Fix a bug with file context
20K in + 2K out
~$0.09
~$0.024
Refactor a module (read 10 files)
80K in + 10K out
~$0.39
~$0.104
1 hour interactive session
200K in + 20K out
~$0.90
~$0.24
Full-day heavy use (8h)
1.5M in + 150K out
~$6.75
~$1.80
Set up API billing
# Set your API key (add to ~/.bashrc or ~/.zshrc):
export ANTHROPIC_API_KEY=sk-ant-...
# Claude Code auto-detects the key and uses API billing
claude
# Verify which mode you're using:
# If ANTHROPIC_API_KEY is set → API billing (no subscription limit)
# If not set → uses Claude.ai subscription
Use Haiku for cost savings
# Haiku is 4-10× cheaper than Sonnet for simple tasks:
export ANTHROPIC_MODEL=claude-haiku-4-5-20251001
# Good Haiku use cases:
# - Generate boilerplate code
# - Rename variables/functions
# - Add docstrings/comments
# - Simple bug fixes with clear context
# - CI checks (lint suggestions, test naming)
# Use Sonnet or Opus for:
# - Complex debugging with subtle root causes
# - Architecture decisions
# - Security audits
# - Multi-file refactors with non-obvious dependencies
Leverage prompt caching
# Claude Code automatically benefits from prompt caching when you:
# 1. Read the same files multiple times in a session
# 2. Have a long CLAUDE.md (loaded on every turn)
# 3. Keep the same session open (context accumulates, cache hits increase)
# Caching saves 90% on input tokens after the first read.
# A 100K-token CLAUDE.md + codebase context costs:
# - First read: $0.30 (at Sonnet rate)
# - Cached reads: $0.03 each
# Practical tip: keep sessions open longer instead of restarting.
# Each restart = fresh cache = full input cost again.
# See claude-cost-calc.vercel.app to estimate your costs with caching.
Monitor and cap usage
# Cap output tokens per response (reduces runaway costs):
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=4096
# Disable telemetry in CI (reduces non-essential API calls):
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
# Log token usage per session (pipe --output-format json):
claude --print --output-format json "analyze src/" | jq '.usage | {input: .input_tokens, output: .output_tokens}'
# Set up billing alerts in Anthropic console:
# console.anthropic.com → Settings → Billing → Usage alerts
Claude Code is included with Claude.ai Pro ($20/mo) for light use and Claude.ai Max ($100/mo) for heavier use. Both plans have usage limits. For unlimited or CI usage, you can connect your own Anthropic API key and pay per token: Sonnet 4.6 costs $3/1M input tokens and $15/1M output tokens.
What is the difference between Claude Code Pro and Max?
Pro ($20/mo) includes Claude Code with limited usage — suitable for 1-2 hours per day of interactive coding. Max ($100/mo) has 5× higher rate limits and is designed for full-time developer use (8+ hours/day). Max also gets access to extended context and priority access.
Can I use Claude Code with my own API key?
Yes. Set ANTHROPIC_API_KEY in your environment before running claude. This bypasses subscription limits and bills directly to your Anthropic account at API rates. This is the recommended approach for CI/CD, team automation, and heavy individual use.
How many tokens does a typical Claude Code session use?
A typical 1-hour interactive session uses 100K-500K tokens (input + output combined). At Sonnet 4.6 rates ($3 input / $15 output), that's roughly $0.50-$2.50 per hour via API. Prompt caching can reduce input costs by up to 90% for repeated file reads.
How can I reduce Claude Code API costs?
Use Haiku for simple tasks (10× cheaper), enable prompt caching (up to 90% savings on repeated context), set CLAUDE_CODE_MAX_OUTPUT_TOKENS to cap responses, and restrict large file reads to what's necessary.