Claude API Cost Per Million Tokens Calculator
How to calculate Claude API cost per million tokens
The fastest way to estimate Claude API cost is a simple formula: (input tokens / 1,000,000 × input price) + (output tokens / 1,000,000 × output price). Anthropic prices every Claude model per million tokens, and input and output tokens are billed at different rates — output is always more expensive because generation is more compute-intensive than reading a prompt.
If you just want a number, here's the short version: a typical chat exchange (500 input tokens, 300 output tokens) on Claude 3.5 Sonnet costs roughly $0.006. A long document summarization job (50,000 input tokens, 2,000 output tokens) on the same model costs roughly $0.18. Below is the full breakdown, the formula you can reuse, and a worked calculator script so you don't have to redo the math every time your prompt length changes.
Claude model pricing per million tokens
Anthropic publishes pricing per model, and it changes occasionally, so always confirm current numbers on Anthropic's official pricing page before budgeting a production workload. As a reference point, the pricing tiers typically look like this:
| Model | Input (per 1M tokens) | Output (per 1M tokens) | |---|---|---| | Claude 3 Opus | $15.00 | $75.00 | | Claude 3.5 Sonnet | $3.00 | $15.00 | | Claude 3.5 Haiku | $0.80 | $4.00 | | Claude 3 Haiku | $0.25 | $1.25 |
The spread between the cheapest and most expensive model is roughly 60x on input and 60x on output. This is why model selection matters more than almost any other cost lever — before you optimize prompts or caching, check whether you're even using the right model for the task.
The calculation in practice
Say you're building a support assistant that processes 10,000 requests per day, each with 800 input tokens (system prompt + context) and 250 output tokens (the reply).
Daily token volume:
- Input: 10,000 × 800 = 8,000,000 tokens
- Output: 10,000 × 250 = 2,500,000 tokens
On Claude 3.5 Sonnet:
- Input cost: 8 × $3.00 = $24.00
- Output cost: 2.5 × $15.00 = $37.50
- Total: $61.50/day, or roughly $1,845/month
Switch the same workload to Claude 3.5 Haiku:
- Input cost: 8 × $0.80 = $6.40
- Output cost: 2.5 × $4.00 = $10.00
- Total: $16.40/day, or roughly $492/month
That's a 3.7x cost reduction just from picking a cheaper model, assuming it still meets your quality bar. Running this comparison before launch — not after the first invoice — is the entire point of a cost calculator.
A reusable calculator script
Instead of doing this math by hand every time, keep a small script around. This is generic and works for any token-based LLM pricing, not just Claude:
function estimateCost({ inputTokens, outputTokens, inputPricePerM, outputPricePerM }) {
const inputCost = (inputTokens / 1_000_000) * inputPricePerM;
const outputCost = (outputTokens / 1_000_000) * outputPricePerM;
return {
inputCost,
outputCost,
totalCost: inputCost + outputCost
};
}
const result = estimateCost({
inputTokens: 800,
outputTokens: 250,
inputPricePerM: 3.00, // Claude 3.5 Sonnet input
outputPricePerM: 15.00 // Claude 3.5 Sonnet output
});
console.log(result);
// { inputCost: 0.0024, outputCost: 0.00375, totalCost: 0.00615 }
Multiply totalCost by expected daily or monthly request volume and you have a budget line item. If you want to model multiple scenarios quickly (different models, different token counts, different volumes), wrap this in a loop over an array of pricing configs and print a comparison table — it takes about ten minutes to build and saves hours of guessing later.
Why token counts are harder to predict than price
The pricing side of the calculation is easy — the hard part is knowing your actual token counts before you ship. A few things that inflate token counts in ways people don't expect:
- System prompts and tool definitions count as input tokens on every single request, even if the user's message is one sentence.
- Conversation history sent back on each turn multiplies input cost linearly with conversation length — a 20-turn conversation can cost far more than 20x a single-turn request because of the included history.
- Retrieved context (RAG chunks, documents, search results) is often the biggest line item and the easiest to overlook when estimating.
The fix for most of these is prompt caching, which lets you reuse large static blocks (system prompts, tool schemas, reference documents) across requests without paying full input price every time. It's worth checking how your provider implements this — it can cut input costs significantly for workloads with repeated context, though the exact savings depend on cache hit rate.
Where SubToAPI fits
If you're already paying for Claude access and want to turn it into a billable, meterable API for your own product, SubToAPI gives you application API keys (sub_live_...), streaming, tool use, and usage metadata per key so you can see exactly how many tokens each customer or feature consumes — which is the real input you need for any cost calculator, not just estimated averages. Plans start at Solo (€9), Team (€19/seat), and Scale (€49/seat), with a free trial at signup. Check current details on /pricing, or get started with the /docs/quickstart guide.
Tracking actual usage per key, rather than guessing from benchmarks, is what turns a cost calculator from a planning exercise into an operational budget tool.
questions
Does Claude price input and output tokens the same? No. Output tokens are consistently priced higher than input tokens across every Claude model — typically 4-5x the input rate — because generating text requires more compute per token than reading a prompt.
How do I count tokens before making a request? Most SDKs expose a token-counting utility, or you can estimate roughly 4 characters per token for English text. For exact billing, check the usage metadata returned with each API response rather than relying on estimates.
Is a cost-per-million-tokens calculator enough to budget a production app? It's a good starting point, but real budgets need actual volume data — requests per day, average conversation length, and cache hit rate — multiplied against the per-token price, not just a single-request estimate.