Claude & OpenAI API cost calculator
Paste the usage block from a Claude or OpenAI API response (or a whole response, or a line from a Claude Code log) and see what that request cost, split into new input, cache writes, cache reads and output. Or type the token counts yourself.
It handles the two providers' different counting (OpenAI's input total includes cached and written tokens; Anthropic's doesn't), prices each cache write at its own rate, and applies long-prompt prices: Claude Haiku 5.5 over 100,000 tokens, current OpenAI models over 272,000.
How a Claude request is priced
Every response carries a usage block. Anthropic's input_tokens counts only the new, uncached input; the cached parts are reported separately:
| Field | Priced at |
|---|---|
input_tokens | the model's input price |
cache_creation_input_tokens | 1.25× input for the 5-minute cache, 2× for the 1-hour cache (split in cache_creation) |
cache_read_input_tokens | the model's cache-read price (0.05× input on Sonnet 5.5 and Opus 5.5, 0.025× on Fable 5.2, 0.1× on Haiku 5.5 and the 4.x models) |
output_tokens | the output price; thinking is billed as output and is already included |
So a request's full input is input_tokens + cache_creation_input_tokens + cache_read_input_tokens. Pricing input_tokens alone makes a cached request look nearly free. More detail, with a tested Python function: what each Claude API request costs.
How an OpenAI request is priced
OpenAI counts the other way round: input_tokens (Responses API) or prompt_tokens (Chat Completions) includes cached reads and cache writes.
| Part | Priced at |
|---|---|
new input = input − cached_tokens − cache_write_tokens | the model's input price |
cached_tokens | the model's cached-input price (0.05× input on GPT-6.2 Astra and Sol, GPT-6.1 Sol and Terra; 0.1× on most others) |
cache_write_tokens | on GPT-5.6 and later: 1.25× input for the default 30-minute cache, 2.5× for the 12-hour cache (Responses API, split in cache_write_tokens_details) |
output_tokens / completion_tokens | the output price; reasoning tokens are already included |
A request with more than 272,000 input tokens pays the model's long-context prices for every token in it. GPT-5.6 Sol's listed price is promotional until November 30, 2026. More detail, with a tested Python function: what each OpenAI API request costs.
Things this calculator doesn't include
- Batch API: 50% off input and output. Price the request here and halve those parts.
- Regional or multi-region endpoints on Amazon Bedrock or Google Cloud, which Anthropic lists at a 10% premium over global endpoints for Claude 4.5 and later.
- Web search, code execution and other tools with their own per-use charges.
- OpenAI's Fast mode and Batch tier, and data-residency endpoints (OpenAI lists a 10% uplift for regional processing on models released on or after March 5, 2026).
- Prices change. The table in the source of this page shows the date it was checked; if a number differs from Anthropic's or OpenAI's pricing page, the pricing page wins.
Questions people ask
How much does a Claude API request cost?
It depends on four token counts in the response's usage block: new input, cache writes, cache reads and output, each at the model's own price. On Claude Sonnet 5.5, a request with 1,200 new input, 2,000 cache-write, 10,000 cache-read and 400 output tokens costs $0.0124 at list prices (checked November 23, 2026).
Does input_tokens include cached tokens?
No. On the Claude API, input_tokens counts only new, uncached input. Cache writes are reported in cache_creation_input_tokens and cache reads in cache_read_input_tokens, so a request's full input is the sum of all three. Pricing input_tokens alone makes a cached request look almost free.
How much do Claude cache writes and cache reads cost?
Cache writes cost 1.25 times the model's input price for the 5-minute cache and 2 times for the 1-hour cache. Cache reads have each model's own price: $0.10 per million tokens on Sonnet 5.5, $0.20 on Opus 5.5 and Fable 5.2, and $0.01 on Haiku 5.5 for prompts up to 100,000 tokens.
Why does Claude Haiku 5.5 cost more for long prompts?
Haiku 5.5 has two price rows. A request whose prompt is over 100,000 tokens, cache reads and writes included, pays $0.50 per million input and $2.50 per million output instead of $0.10 and $0.50. The higher price applies to every token in that request, not just the part over 100,000.
Are Claude thinking tokens billed?
Yes. Thinking is billed as output tokens at the output price, whether or not you see the thinking text, and it is already included in output_tokens. The calculator prices it as part of output.
Does OpenAI's input_tokens include cached tokens?
Yes, the opposite of Anthropic. OpenAI's input_tokens (or prompt_tokens) includes cached reads and cache writes. New input is the total minus cached_tokens minus cache_write_tokens. On GPT-5.6 and later, cache writes cost 1.25 times the input price for the 30-minute cache and 2.5 times for the 12-hour cache.
Or price every request automatically
NeverPayTwice is a small app we make. Its live meter runs on your own computer, records the usage block of every Claude and OpenAI call as it happens, prices it this way, keeps a receipt with the request ID, and flags anything you paid for twice. It never blocks or changes a request and never stores your API keys. $9.99 to start, then $2.99 a month to keep (your first month is included).
Try it on your own API calls, free for 7 days. No card needed.
Sources: Anthropic's pricing page (model, cache, Haiku 5.5 long-prompt, batch and data-residency prices) and prompt caching guide, checked November 23, 2026. The calculator's code is claude-cost-calc.js (MIT); it matches our tested Python function on every case we ran.