How to see what each Claude API request costs

By NeverPayTwice · November 14, 2026 · 6-minute read

Short answer: Anthropic's usage and cost reports give totals, grouped by model, API key or workspace and split into minutes, hours or days. They don't show what one request cost. To know that, read the usage block that comes back with every response. It has four kinds of input, each with its own price: new input, 5-minute cache writes, 1-hour cache writes and cache reads.

Below: what each field means, the two details that make totals come out wrong, the formula, and a tested Python function.

What Anthropic's usage reports show (and don't)

Anthropic's Usage and Cost Analytics API (GET /v1/organizations/analytics/usage and /cost) reports token counts and cost for your organization. You can group the totals by model, workspace, API key, service tier and a few other fields, and split them into 1-minute, 1-hour or 1-day buckets. It needs an Admin API credential, and an individual Console account has to set up an organization first. The Console's Usage and Cost pages show similar totals.

That is good for a monthly picture. It can't tell you that the request your app sent at 14:02 for one customer cost $0.0124. For that you need the numbers that come back with the response.

Where the per-request numbers are

Every Messages API response has a usage block:

FieldWhat it counts
input_tokensNew input that was neither written to nor read from the cache
cache_creation_input_tokensInput written to the cache on this request
cache_creationThe same writes split by how long the cache lasts: ephemeral_5m_input_tokens and ephemeral_1h_input_tokens
cache_read_input_tokensInput read from the cache
output_tokensEverything the model generated, thinking included
output_tokens_detailsthinking_tokens: how much of the output was reasoning

Two details matter for cost, and they work the opposite way from OpenAI's API:

The prices you need

Anthropic prices everything per million tokens. Cache writes are priced from the model's input price: 1.25 times for the default 5-minute cache, 2 times for the 1-hour cache. Cache reads have a price of their own, and it isn't the same multiple of the input price for every model:

ModelInputCache readOutput
Claude Opus 5.5$4$0.20 (0.05×)$20
Claude Sonnet 5.5$2$0.10 (0.05×)$10
Claude Haiku 5.5 (prompts up to 100K tokens)$0.10$0.01 (0.1×)$0.50
Claude Fable 5.2$8$0.20 (0.025×)$40
Claude Opus 4.8$5$0.50 (0.1×)$25

Anthropic's standard rates, USD per million tokens, from its pricing page on November 14, 2026. Prices change; keep them in one place in your code and check the page when you update. Some things change the price of a request: the Batch API halves it, US-only inference (inference_geo: "us") adds 10%, fast mode has its own rates, Haiku 5.5 costs more for prompts over 100,000 tokens, and web search is charged per search on top of tokens. If your bill is higher than you expected, here are nine things to check.

The formula

5-minute writes = cache_creation_input_tokens − 1-hour writes
cost (USD)      = ( input_tokens × input price
                  + 5-minute writes × input price × 1.25
                  + 1-hour writes × input price × 2
                  + cache_read_input_tokens × cache-read price
                  + output_tokens × output price ) ÷ 1,000,000

A tested Python function

It returns None for a model you haven't priced, so a missing price is never silently counted as zero. (Download it, or get it with the other scripts on GitHub.)

PRICES = {
    # model: base input, cache read (hit), output -- USD per 1M tokens
    "claude-opus-5-5":   {"input": 4.00, "cache_read": 0.20, "output": 20.00},
    "claude-sonnet-5-5": {"input": 2.00, "cache_read": 0.10, "output": 10.00},
    "claude-haiku-5-5":  {"input": 0.10, "cache_read": 0.01, "output": 0.50},
}
WRITE_5M, WRITE_1H = 1.25, 2.0


def split_usage(usage):
    """Token counts, one per price, from a usage block."""
    writes = usage.get("cache_creation_input_tokens") or 0
    write_1h = (usage.get("cache_creation") or {}).get("ephemeral_1h_input_tokens") or 0
    return (usage.get("input_tokens") or 0, max(0, writes - write_1h), write_1h,
            usage.get("cache_read_input_tokens") or 0, usage.get("output_tokens") or 0)


def request_cost(model, usage, prices=PRICES):
    """Dollar cost of one request, or None if the model has no price in `prices`."""
    p = prices.get(model)
    if p is None:
        return None
    new_in, w5, w1h, read, out = split_usage(usage)
    return (new_in * p["input"] + w5 * p["input"] * WRITE_5M + w1h * p["input"] * WRITE_1H
            + read * p["cache_read"] + out * p["output"]) / 1_000_000

With the official Python SDK, response.usage.to_dict() gives you the usage block as a dictionary and response.model the model name. Log both with the request ID (response._request_id) and you have a receipt for every call.

Worked example on Claude Sonnet 5.5: 1,200 new input tokens, 2,000 written to the 5-minute cache, 10,000 read from the cache and 400 output tokens (150 of them thinking) cost (1,200 × 2 + 2,000 × 2 × 1.25 + 10,000 × 0.10 + 400 × 10) ÷ 1,000,000 = $0.0124. The thinking tokens are already in the 400.

We tested the function on seven usage blocks across seven models, including the 1-hour cache and reasoning output. It gives the same cost as NeverPayTwice's own engine every time.

Things that quietly add up

Or let something record it for you

NeverPayTwice is a small app we make. Its live meter sits on your own computer between your code and the API: set ANTHROPIC_BASE_URL=http://127.0.0.1:8098/anthropic and every request is passed through unchanged and recorded with its tokens (cache writes and reads split out), cost and request ID. It never blocks or changes a request, and API keys are never stored. It flags every time you paid again for a request you had already bought, and keeps a receipt for each one. It also works with OpenAI, Google Gemini and compatible APIs. Mac, Windows or Linux, $9 one time.

See the receipts and repeat-charge detection with sample data first, no sign-up.

Try the demoGet NeverPayTwice · $9

Sources: Anthropic's Messages API reference (the usage object), pricing page and Usage and Cost Analytics API, checked November 14, 2026. Prices and field names can change; check the current pages if something doesn't match.