Claude Code is an AI coding assistant that runs your local terminal and IDE directly against the Anthropic API using your own API key. What you pay depends on which model you route to (Haiku, Sonnet, or Opus) and how aggressively you use prompt caching.
Token model: what Claude Code sends per session
A typical Claude Code session includes:
System prompt (~3,000–6,000 tokens) — instructions, CLAUDE.md, tool definitions. This is cached after the first turn at 90% off.
Conversation history — all prior turns in the session. Grows linearly; older turns are cached.
Tool call outputs — bash output, file reads, grep results. Can spike on large file reads.
Output tokens — Claude's response. Usually 200–800 tokens per turn.
Cost per session by model (typical 20-turn coding session)
Model
Input $/MTok
Output $/MTok
~Cost (no cache)
~Cost (heavy cache)
Haiku 4.5
$1
$5
$0.04–0.12
$0.01–0.04
Sonnet 4.6
$3
$15
$0.15–0.45
$0.04–0.12
Opus 4.7
$15
$75
$0.75–2.25
$0.18–0.60
Claude Code defaults to Sonnet 4.6 for most tasks. A typical day of moderate use (5–8 sessions) with Sonnet runs $0.50–2.00. Heavy all-day sessions with Opus can reach $5–15/day.
What drives cost up
Large file reads (reading a 1,000-line file = ~800 tokens per read)
Long bash output captured as tool results
Long conversation context without /compact
Using Opus when Sonnet would suffice
What drives cost down
Prompt caching — Claude Code automatically caches the system prompt and conversation turns. After the first request, 60–80% of input tokens are cache hits at 10% price.
/compact command — summarises long sessions into a short context, resetting the billing window
Scoped prompts — "edit only this function" vs "look at the whole repo"
Model routing — Haiku for quick edits, Sonnet for normal tasks, Opus only for complex reasoning
Measure your actual sessions
Claude Code logs a cost summary at the end of each session. To see the exact token breakdown, cost, and how much caching saved you, paste the log into the free Claude Code Cost Calculator. It breaks out cache hits vs live tokens and shows how switching models would change the bill.
Frequently asked questions
How do I see how much my Claude Code session cost?
Claude Code prints a cost summary at the end of each session. For a detailed breakdown including cache savings and per-model comparison, paste the session log into the Claude Code Cost Calculator at claude-cost-calc.vercel.app.
Can I set a daily spend limit for Claude Code?
Anthropic's console lets you set monthly spend limits per API key. For daily limits, wrap your Claude Code invocations in a script that checks a running total against the Anthropic Usage API before each session.
Does Claude Code use my API key or Anthropic's?
Claude Code uses your own Anthropic API key. You pay Anthropic directly at the listed per-token rates. There is no additional Claude Code subscription fee beyond the Pro plan ($20/month) which includes usage credits.
How much does prompt caching save in a typical Claude Code session?
Substantial. The system prompt (CLAUDE.md, tool definitions) is cached after turn 1 and reused for the rest of the session at 10% price. On a 20-turn session, caching reduces the effective input cost by 60–80%. The Cost Calculator shows this breakdown explicitly.