Claude token calculator

Claude 4 Cost Calculator

Estimate Anthropic Claude 4 API costs for coding agents, long-context analysis, RAG answers, and automation workflows. The calculator uses provider JSON rules so pricing changes can be refreshed without editing page templates.

Model rule Claude Sonnet 4
Input / 1M $3
Output / 1M $15

Anthropic pricing rule

Claude Sonnet 4 Token Cost Calculator

Updated 2026-05-29

Estimated API cost

$0.045
Input
$0.03
Cached input
$0.00
Output
$0.015
Per 1,000 requests
$45.00

Cost Per Million Tokens

Model Input Cached input Output Context
Claude Sonnet 4 $3 $0.3 $15 200,000 tokens
Claude Opus 4 $15 $1.5 $75 200,000 tokens
Claude Haiku 3.5 $0.8 $0.08 $4 200,000 tokens

GPT vs Claude Pricing Snapshot

Claude Sonnet 4 $3 in / $15 out
Claude Opus 4 $15 in / $75 out
Claude Haiku 3.5 $0.8 in / $4 out

How Claude API Pricing Works

Claude API costs are estimated from base input tokens, cache write or cache hit tokens, and output tokens. This MVP uses base input, cached input, and output pricing because those are the fastest signals for cost-sensitive search intent.

Claude Cost Drivers

Claude costs increase when prompts include long files, retrieved knowledge base chunks, multi-message conversation history, or repeated agent state. Output-heavy tasks such as drafting, coding, and analysis reports can also dominate the invoice.

Cache behavior is especially important for Claude workloads that reuse a large system prompt, schema, policy, or repository context across many requests.

Best Use Cases To Model

  • Long-context document analysis
  • RAG answers over large knowledge bases
  • Agent workflows with repeated tool context
  • Code review and software engineering tasks
  • Enterprise automation with stable prompts

Pricing source: Anthropic pricing page. Last local rule update: 2026-05-29. Estimates exclude taxes, discounts, long-context beta premiums, and tool-specific charges.

FAQ

Which Claude 4 model does this page use?

The default calculator uses Claude Sonnet 4 because it is the common high-performance Claude 4 option for developer workloads. The pricing table also includes Claude Opus 4.

How do cached Claude tokens affect cost?

Cache hits are billed at a lower rate than base input tokens. Cache writes can be higher than normal input, so high-repeat workloads should track both write and hit behavior.

Is the 1M context beta included?

This MVP tracks the standard context pricing rule. Long-context beta pricing can be added as a separate rule once the SEO experiment expands beyond the three starter pages.

How should I estimate Claude cost for an agent?

Estimate the average tokens per step, the expected number of steps per task, and the final response length. Multiply the per-step cost by the average number of model calls.

Is Claude Sonnet 4 cheaper than Claude Opus 4?

Claude Sonnet 4 is usually cheaper per token than Claude Opus 4. Opus can still be useful when higher reasoning quality reduces retries, manual review, or failed agent loops.