DEV Community

Mohamed Abidi
Mohamed Abidi

Posted on AI-assisted

Claude API cost: I priced one AI agent on every model

Every Claude pricing page gives you the same thing: a table of dollars per million tokens. Sonnet 5.5 is $2 in and $10 out. Fine. But nobody ships "a million tokens". You ship a support agent, a coding assistant, a RAG endpoint, and you want to know what it will cost next month.

The per-token price doesn't answer that, because the number that decides your bill isn't on the price list: how many tokens your app sends per request, and how fast that number grows.

So let's price one concrete agent, step by step, on every current Claude model. Then we'll see where the money actually goes, and which two settings change the answer.

  • A 5-step support agent at 30,000 conversations a month costs $3,690 on Sonnet 5.5, $7,380 on Opus 5.5, $18,450 on Fable 5.1 and $184.50 on Haiku 5.5.
  • 88% of that is input tokens, not the answer: every step re-sends the system prompt, the tools and everything said so far.
  • Prompt caching cuts the same bill by 61–67% (Sonnet: $3,690 → $1,289). Model choice moves it 100×.

How does Claude API pricing work?

Every request is billed on two counts: the tokens it reads (input) and the tokens it writes (output). Output costs 5× input on every current Claude model. Here are the list prices, in USD per million tokens, from Anthropic's pricing page, checked October 14, 2026:

Model Input Output Cached read
Claude Fable 5.1 $10 $50 $0.25
Claude Opus 5.5 $4 $20 $0.20
Claude Sonnet 5.5 $2 $10 $0.10
Claude Haiku 5.5 $0.10 $0.50 $0.01

Two discounts sit on top: prompt caching (repeated input billed at the "cached read" price) and the Batch API (50% off everything, for work that can wait up to 24 hours).

That table is all a price list can tell you. The rest depends on your app.

The example: a 5-step support agent

Say you run a support agent. A user asks a billing question, and the agent works through it in 5 model calls: look up the account, fetch the invoice, check the refund status, and so on. These numbers are an illustration; swap in your own.

  • System prompt + tool definitions: 6,000 tokens
  • The user's question: 200 tokens
  • Each step, the model writes 300 tokens (a tool call or the answer)
  • Each tool returns 2,000 tokens (JSON from your billing API)
  • Volume: 1,000 conversations a day, so 30,000 a month

The trap is that an agent doesn't send "the new stuff" on each call. The Messages API is stateless, so every call re-sends the whole conversation so far:

calls = [6_200 + 2_300 * step for step in range(5)]
# [6200, 8500, 10800, 13100, 15400]

input_tokens = sum(calls)   # 54,000 per conversation
output_tokens = 5 * 300     # 1,500 per conversation
Enter fullscreen mode Exit fullscreen mode

The fifth call reads 15,400 tokens to write 300. Across the conversation, input outweighs output 36 to 1.

Vintage travel-poster illustration of three pack-laden donkeys climbing a winding mountain path above a turquoise lake, representing the growing context carried through successive AI agent calls.

What does it cost per month on each Claude model?

Multiply: 54,000 input tokens × 30,000 conversations = 1.62 billion input tokens a month. 1,500 output tokens × 30,000 = 45 million output tokens.

Model Input Output Monthly total Per conversation
Claude Fable 5.1 $16,200 $2,250 $18,450 $0.615
Claude Opus 5.5 $6,480 $900 $7,380 $0.246
Claude Sonnet 5.5 $3,240 $450 $3,690 $0.123
Claude Haiku 5.5 $162 $22.50 $184.50 $0.006

Input is 87.8% of the bill on every model, because the input/output price ratio is the same 5× across the lineup. If you've been trimming your answers to save money, you've been optimizing the 12%.

The spread between models is the other lesson: Fable 5.1 costs exactly 100× Haiku 5.5 for the same traffic. Whether Haiku can actually resolve your billing questions is a question for your eval set, not the price list. But if it passes on even half your traffic, routing that half is the biggest saving available.

To check this table, I entered one conversation as one "request" (54,000 input, 1,500 output, 30,000 a month) into this Claude API cost calculator, which prices every model side by side. A spreadsheet works too; the formula is below.

Why is the Claude API so expensive?

It usually isn't the price per token. It's three things that multiply it:

  1. Re-sent context. Every agent step re-reads the system prompt, the tool schemas and every earlier tool result. In the example, the same 6,000-token system prompt is billed 5 times per conversation, 150,000 times a month.
  2. Fat tool results. The 2,000-token tool result is the biggest line in the example. Raw JSON from an API carries IDs, timestamps, null fields and nested metadata the model never uses, and it stays in the context for every later step.
  3. Hidden output. Extended thinking is billed as output tokens. A model that "thinks" for 2,000 tokens before a 300-token answer bills 2,300 output tokens at the output price.

One more, which catches people comparing models: Claude 4.7 and later use a tokenizer that produces about 30% more tokens for the same text. A lower price per token on a newer model can still mean a similar bill. Count a real prompt on the model you'll use before you compare.

What does prompt caching change?

Prompt caching bills a repeated prompt prefix at the cached-read price. In an agent loop, almost everything is a repeated prefix: call 3 starts with everything call 2 sent.

With a cache marker at the end of each call (and enough traffic that the shared 6,000-token system prompt stays warm), each conversation reads 44,600 tokens from cache and writes only the new 9,400. Cache writes cost 1.25× input on the 5-minute cache, so I've included them (calculators that leave writes out, including the one above, show a slightly lower number):

Model Without caching With caching Saved
Claude Fable 5.1 $18,450 $6,109.50 67%
Claude Opus 5.5 $7,380 $2,577.60 65%
Claude Sonnet 5.5 $3,690 $1,288.80 65%
Claude Haiku 5.5 $184.50 $71.13 61%

On Sonnet 5.5, a cached read costs $0.10 per million tokens against $2 uncached, 95% off. What's left of the bill is mostly cache writes and output.

Caching has rules that can silently turn it off (a timestamp in the system prompt, a reordered tool list, a user who comes back after 6 minutes). That's tomorrow's post in this series. For a cost estimate, the point is simpler: an uncached agent estimate is roughly 3× too high in this scenario, so don't kill a project on it.

Vintage gouache illustration of a stone granary containing stacked grain sacks beside terraced green fields and a turquoise lake. A farmer carries one new sack toward the granary, symbolizing cached context being reused instead of processed again.

The threshold that changes the cheapest model

Haiku 5.5 has a long-context tier: prompts over 100,000 input tokens are billed at $0.50 input and $2.50 output, 5× its normal price. Other current Claude models bill their full context window at standard prices.

Five steps never get close. But agents that loop (coding agents, research agents) do. In the example, the context grows 2,300 tokens per step, so step 42 is the first call over 100,000 tokens. From there, every Haiku call costs 5× more, and the gap to Sonnet shrinks from 20× to 4×.

If your agent runs long, either keep the context under the threshold (summarize or drop old tool results) or price Haiku at its long-context rate.

Your own formula

Log the usage object every response returns, then price it:

PRICES = {  # USD per 1M tokens, Sonnet 5.5
    "input": 2.00,
    "output": 10.00,
    "cache_read": 0.10,
    "cache_write": 2.50,  # 5-minute write = 1.25× input
}

def request_cost(usage) -> float:
    return (
        usage.input_tokens * PRICES["input"]
        + usage.output_tokens * PRICES["output"]
        + usage.cache_read_input_tokens * PRICES["cache_read"]
        + usage.cache_creation_input_tokens * PRICES["cache_write"]
    ) / 1_000_000
Enter fullscreen mode Exit fullscreen mode

input_tokens in the response counts only the uncached part, so the four fields add up without double counting. Sum request_cost per conversation and you have the number that matters: cost per resolved task, not cost per token. The field names are in the Messages API reference.

Is the Claude API free, or included in Claude Pro?

No to both. The API is pay-as-you-go per token; new accounts may receive trial credit. Claude Pro and Max subscriptions cover the Claude apps, and API usage is billed separately (Claude plans).

What to do Monday morning

  1. Log usage for 100 real conversations and compute average input and output tokens per conversation, not per call.
  2. Price that on two models: the one you use and the next one down. Run your eval set on the cheaper one.
  3. Turn on prompt caching and check that cache_read_input_tokens is most of the input from the second call on.
  4. Look at your largest tool result and cut the fields the model never reads.
  5. If any run goes past ~40 steps, check where its context crosses a pricing threshold.

What does one task cost in your app, and how many model calls does it take? I'm curious how far real agents are from the 5-step example.

Top comments (0)