How Anthropic API billing actually works
Updated 2026-07-15
Anthropic bills the API per token: one rate for input, a higher rate for output, and separate rates for prompt cache writes and reads, all drawn from prepaid credits. Most surprise bills come from output tokens and re-sent conversation history, not the headline input price.
Quick answer: what you are actually charged for
Anthropic charges for the Claude API per token, prepaid. You buy credits in the developer console, and every request draws down that balance across three meters: input tokens (everything you send), output tokens (everything the model generates, including thinking tokens), and prompt cache traffic (writes bill at 1.25x the input rate, reads at 0.1x). There is no subscription for the API itself, and a Claude Pro or Max subscription does not include API credits. Output is the expensive meter. Claude Sonnet 4.6 lists at $3.00 per million input tokens and $15.00 per million output tokens, a 5x gap. Claude Opus 4.7 lists at $5.00 in and $25.00 out. If your bill is higher than expected, check output volume and conversation history growth before anything else.
The three meters: input, output, and cache tokens
Input covers more than the user's message. The system prompt, the full conversation history, tool definitions, tool results, and images all count as input tokens on every request that includes them. Output covers everything the model writes back, and on reasoning-capable models that includes thinking tokens you may never display to a user. Prompt caching is the third meter and the one most teams leave unused. You mark a stable prefix (a long system prompt, a document, a fixed tool list) with a cache_control breakpoint. The first request pays a write premium of 1.25x the input rate for the default 5-minute cache; every request that reuses the prefix within the window reads it back at 0.1x. A 1-hour cache is also available at a 2x write rate. Below is the full rate card for the two flagship Claude models at official list prices.
| Meter | What counts | Sonnet 4.6 | Opus 4.7 |
|---|---|---|---|
| Input tokens | System prompt, history, message, tools, images | $3.00 / 1M | $5.00 / 1M |
| Output tokens | Model responses, including thinking tokens | $15.00 / 1M | $25.00 / 1M |
| Cache write (5 min) | First write of a cached prefix, 1.25x input | $3.75 / 1M | $6.25 / 1M |
| Cache read | Reuse of a cached prefix, 0.1x input | $0.30 / 1M | $0.50 / 1M |
A worked example: one chatbot, one day
Take a support chatbot on Claude Sonnet 4.6 at official rates: 10,000 requests per day, each carrying a 2,000-token system prompt plus 1,500 tokens of history and user message, answered with a 500-token reply. The table shows the same workload with and without the system prompt cached. Without caching the day costs $180.00, about $5,400 a month. Caching the system prompt (assuming around 300 cache expirations a day on the 5-minute window) cuts it to roughly $128 a day, about $3,840 a month. Note what did not move: output cost. Caching only touches input, which is why output discipline matters more than any other single lever.
| Line item | Tokens per day | Rate per 1M | Daily cost |
|---|---|---|---|
| Input, no caching | 35,000,000 | $3.00 | $105.00 |
| Output, no caching | 5,000,000 | $15.00 | $75.00 |
| Total without caching | 40,000,000 | $180.00 | |
| Cache writes (system prompt) | 600,000 | $3.75 | $2.25 |
| Cache reads (system prompt) | 19,400,000 | $0.30 | $5.82 |
| Uncached input (history + message) | 15,000,000 | $3.00 | $45.00 |
| Output | 5,000,000 | $15.00 | $75.00 |
| Total with caching | 40,000,000 | $128.07 |
Why Anthropic bills surprise teams
Four patterns account for most "why is the bill several times the estimate" conversations. 1. Output is 5x input, and thinking counts as output. Estimates anchor on the input rate because it is the number quoted first. But long answers, verbose formatting, and extended thinking all bill at the output rate. A model that reasons for 3,000 tokens before answering in 500 bills 3,500 output tokens for what looks like a short reply. 2. History is re-billed on every turn. The API is stateless, so each turn re-sends the entire conversation as input. A chat averaging 20 turns does not cost 20x a single turn; it costs far more, because turn 20 carries the previous 19 turns as input. Input cost grows roughly with the square of conversation length unless you trim or summarize. 3. Subscriptions and API credits are separate. Claude Pro and Max cover the Claude apps, not the API. Teams assume the subscription absorbs API traffic, then discover the console has been quietly drawing from a prepaid balance with auto-reload enabled. 4. Everything in the request is input, and attribution is hard. Tool definitions, tool results, images, and system prompts bill as input on every request that includes them. Spread that across several API keys, environments, and features without per-key logging, and nobody can say which feature spent the money until the invoice lands.
Anthropic vs OpenAI billing, side by side
Both providers meter the same way: per token, separate input and output rates, prepaid credits by default. The differences that matter for your bill are in cache mechanics and spend controls. The practical divergence is caching. OpenAI applies prompt caching automatically with no write fee and a discount on the cached portion. Anthropic makes you place cache_control breakpoints yourself, charges a write premium, and pays it back with far cheaper reads at 0.1x the input rate. For workloads with long stable prompts, Anthropic caching done correctly is the stronger lever; done wrong (a timestamp in the system prompt, an unstable tool list), it silently never hits and you pay full price plus write premiums.
| Billing detail | Anthropic | OpenAI |
|---|---|---|
| Unit of billing | Per token, separate input and output rates | Per token, separate input and output rates |
| Payment model | Prepaid credits; usage tiers raise rate limits | Prepaid credits by default |
| Prompt caching | Explicit cache_control; write 1.25x, read 0.1x | Automatic; discounted cached input, no write fee |
| Cache lifetime | 5 minutes default, 1 hour at 2x write rate | Managed for you, typically minutes to an hour |
| Batch discount | 50% off via the Batches API | 50% off via the Batch API |
| Reasoning tokens | Thinking tokens billed as output | Reasoning tokens billed as output, not shown in the reply |
| Spend controls | Workspace spend limits, optional auto-reload | Project budgets and alerts |
How to estimate your Anthropic API cost before shipping
Every API response includes a usage object with exact input_tokens and output_tokens, plus cache_creation_input_tokens and cache_read_input_tokens when caching is active. That object is the ground truth. Client-side tokenizers built for other providers undercount Claude tokens, so do not estimate with them. The procedure: send a handful of representative requests, read the usage object, and average the counts. Then apply the formula: cost = (input_tokens / 1,000,000 x input rate) + (output_tokens / 1,000,000 x output rate), plus the cache write and read terms if you cache. Multiply by expected daily volume, and for multi-turn products add growth headroom because history pushes input up every turn. Anthropic also exposes a count_tokens endpoint if you want counts before sending anything.
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Summarize this ticket: ..."}]
}'
# Response includes the ground truth for your cost model:
# "usage": {"input_tokens": 2412, "output_tokens": 486,
# "cache_read_input_tokens": 0, "cache_creation_input_tokens": 0}Five ways to reduce your Anthropic API bill
The fifth tactic is where a gateway earns its place. APIsRouter is an OpenAI-compatible gateway that logs model, input tokens, output tokens, and exact dollar cost per request, per API key, so each feature or environment gets its own key and its own line in the usage view. It lists Claude Sonnet 4.6 at $2.40 input and $12.00 output per million tokens and Claude Opus 4.7 at $4.00 and $20.00, 20% below official list, billed pay as you go with no subscription; a first top-up at /topup is doubled. Pointing an existing OpenAI SDK integration at it is a two-line change:
- Cache your long, stable prefixes. A system prompt or document that repeats across requests bills a tenth of the input rate on every cache read after the first write.
- Trim history and cap max_tokens. Summarize or drop old turns instead of re-sending them, and set max_tokens to what the task needs so a runaway answer cannot bill thousands of extra output tokens.
- Route by task, not by habit. Reserve Opus for the steps that need it and push bulk classification, extraction, and drafts to cheaper models such as deepseek-v4-flash or glm-5.
- Batch anything asynchronous. The Batches API processes requests within 24 hours at half price, ideal for backfills, evals, and nightly jobs.
- Put per-key cost visibility in front of your traffic. Most billing surprises are attribution problems: nobody can say which feature or customer spent the money until the invoice arrives.
from openai import OpenAI
client = OpenAI(
api_key="sk-APIsRouter-...",
base_url="https://api.apisrouter.com/v1",
)
response = client.chat.completions.create(
model="claude-sonnet-4-6",
messages=[{"role": "user", "content": "Summarize this ticket: ..."}],
)
# Token counts come back on every response; the gateway console
# additionally records the exact cost of this request under this key.
print(response.usage.prompt_tokens, response.usage.completion_tokens)FAQ
How does Anthropic API billing work?
You prepay for credits, and each request deducts cost based on tokens: input at one rate, output at a higher rate, and prompt cache writes and reads at 1.25x and 0.1x the input rate. Rates differ by model, and usage tiers unlock higher rate limits as your cumulative spend grows.
Does Claude Pro or Max include API credits?
No. Subscriptions cover the Claude apps; the API is billed separately from a prepaid credit balance in the developer console. Budgeting API traffic against a subscription is one of the most common causes of an unexpected bill.
Why is my Anthropic API bill so high?
The usual causes, in order: output tokens (5x the input rate, and thinking tokens count as output), conversation history re-sent and re-billed on every turn, and unattributed traffic across multiple keys. Pull per-request usage logs before switching models; it is common to find one endpoint or one prompt responsible for most of the spend.
How do I set a spending limit on the Anthropic API?
In the Anthropic Console you can set workspace spend limits and control whether credits auto-reload. Set a hard limit per workspace and disable auto-reload for experiments. A prepaid gateway balance also acts as a natural ceiling, because requests stop when it runs out instead of billing past your budget.
How much does the Claude API cost per request?
Multiply your token counts by the model rates. A request with 2,000 input tokens and 500 output tokens on Claude Sonnet 4.6 costs 2,000/1M x $3.00 plus 500/1M x $15.00, about $0.0135 at official rates. The same request on Claude Opus 4.7 is about $0.0225.
Does prompt caching actually reduce Anthropic API costs?
Yes, when requests share a stable prefix above the minimum cacheable size (roughly one to four thousand tokens depending on the model). Cache reads bill at a tenth of the input rate, so a reused system prompt drops from $3.00 to $0.30 per million tokens after the 1.25x write. It does nothing for output tokens, which caching cannot touch.