The Claude API bills by token, and the Opus, Sonnet, and Haiku tiers differ in both unit price and the tasks they suit. Looking only at "how much per million tokens" makes it easy to choose wrong: what really determines the bill is the input-to-output ratio, cache hit rate, retry count, and the model's ability to get a task right the first time.
This article does not hard-code unit prices. Instead, it gives a reusable method for comparing cost: how the three tiers divide the work, what the bill consists of, why the same call volume can cost several times more, how to budget from real logs, and the order in which to reduce cost. Actual unit prices are subject to Anthropic's official documentation and the on-site model pricing.
Note: Anthropic and Claude are trademarks of their respective owners. Model versions, context limits, and prices change; this article uses common versions as of October 2026. Check the official pages again before procurement.
1. How Opus, Sonnet, and Haiku divide the work
| Tier | Current representative model | Positioning | Suitable tasks | Cost level |
|---|---|---|---|---|
| Opus | Claude Opus 5.5 | Strongest reasoning and long-horizon tasks | Complex code, architecture review, multi-step agents | High |
| Sonnet | Claude Sonnet 5.5 | Balance of capability and speed | Everyday coding, customer support, document processing | Medium |
| Haiku | Claude Haiku 5.5 | Low latency, high concurrency | Classification, extraction, rewriting, routing | Low |
Model names iterate; do not memorize them for procurement. Rely on model pricing and the official model list. If an older project still uses Sonnet 5 or Haiku 4.5, confirm the lifecycle and migration cost before deciding whether to upgrade.
A common mistake is "use Opus everywhere." Opus can actually be cheaper for complex tasks because it gets them right the first time; using Opus for simple classification spends money where it is not needed. The right approach is to layer by task, not to choose models by team preference.
2. The bill has five components
| Billing item | When it occurs | Cost impact | Control |
|---|---|---|---|
| Input tokens | System prompts, message history, tool definitions, documents | Grows linearly with context | Retrieval, summaries, trimming history |
| Output tokens | Generated content and thinking | Usually higher than input | Limit max_tokens, structured output |
| Cache writes | First write of a cache prefix | Carries a write premium | Cache only stable, reused content |
| Cache reads | Prefixes that hit the cache | Usually clearly below input | Stable prefixes, fixed tool order |
| Batch processing | Non-real-time tasks | Usually discounted | Send labeling, summaries, offline analysis through Batch |
Breaking one request down, the cost formula is:
Cost per request =
uncached input tokens × input unit price
+ cache write tokens × cache write unit price
+ cache read tokens × cache read unit price
+ output tokens × output unit price
Only when this formula flows into request logs can you answer "what does this feature cost per month?" Looking only at the console's total bill makes it hard to identify which project or request type is burning money.
3. Why the same million tokens produce different bills
| Scenario | Typical token structure | Main cost | Optimization direction |
|---|---|---|---|
| Customer-support bot | Much input, moderate output | Message history resent repeatedly | Summaries plus caching |
| Document classification | Moderate input, short output | Documents read repeatedly | Batch processing plus Haiku |
| Code agent | Both input and output large | Tool results and thinking | Retrieval, effort, caching |
| Long-form generation | Short input, long output | Output unit price | Segmented generation plus max_tokens |
The differences usually come from five places:
- Input-to-output ratio: customer support and long-form generation have completely different structures and cannot be estimated with the same average.
- Cache hit rate: fixed system prompts and tool definitions can be reused; timestamps or random IDs that change every time will invalidate the cache.
- Retry count: resending after a 429 or 529 increases request volume; the billing rules for failures and retries are subject to the bill.
- Model tier: Opus and Haiku differ by a wide cost margin; a mismatch can multiply the budget.
- Context length: stuffing the whole document in every turn accumulates input cost with each round.
4. Run a reproducible cost comparison
Do not decide based on a feeling that "Sonnet is good enough." Run a comparison on a batch of real tasks:
- Choose 20–50 real tasks covering simple, medium, and complex levels, and write down acceptance criteria.
- Use
count_tokensto record input tokens for each request; read output tokens from the response'susage. - Run the same batch through Opus, Sonnet, and Haiku, recording quality scores and manual rework counts.
- Include retries, cache hits, and batch discounts in the per-task cost.
- Decide based on "cost per completed, acceptable task," not the list price per million tokens.
import os
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ["ANTHROPIC_API_KEY"],
base_url="https://ai.zhongshangqihang.com", # Model names follow the on-site pricing page
)
messages = [{"role": "user", "content": "Extract these contract clauses into JSON: ..."}]
for model in ["claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5"]:
count = client.messages.count_tokens(model=model, messages=messages)
resp = client.messages.create(
model=model,
max_tokens=512,
messages=messages,
)
print(model, count.input_tokens, resp.usage.output_tokens)
This code counts tokens only; it does not calculate money. Multiply by the actual unit price for your account, read from model pricing. Do not reuse a screenshot from several months ago.
5. The order for reducing cost
- Enable caching first: keep system prompts, tool definitions, and knowledge-base prefixes fixed, and verify real hits with
cache_read_input_tokens. - Then reduce input: have RAG return only relevant chunks, summarize message history, and stop stuffing the entire knowledge base into context.
- Limit output: set a reasonable
max_tokensand require JSON or fixed fields, cutting pleasantries and repeated explanations. - Send offline work through Batch: labeling, summaries, and classification that do not need real-time responses should use batch processing first.
- Route by model: send simple tasks to Haiku and complex tasks to Sonnet or Opus; assign by task difficulty, not team habit.
- Tune effort: use a lower thinking depth for simple tasks and raise it for complex ones; do not use one setting for everything.
- Monitor and alert: review usage by project, set budget caps, and review the consumption ranking weekly.
Do not reverse the order. Do caching and input governance first, then consider a cheaper model; otherwise you are only making wrong answers cheaper.
6. How to manage budgets and bills
- One key per project, with a budget cap and alerts per project.
- Reconcile monthly by three dimensions — project, model, and scenario — to find the fastest-growing calls.
- Record savings from caching, batch processing, and model routing separately; otherwise you cannot prove the optimization worked.
- Teams that need RMB payment and invoices can use a domestic AI gateway for unified billing; specific prices, exchange rates, and invoice rules are subject to model pricing.
FAQ
Is Opus always more expensive than Sonnet?
By unit price, usually yes, but not necessarily by "cost per acceptable task." A complex task run repeatedly on Sonnet with manual rework may cost more than one Opus call. Compare on your own evaluation set, not just the list price.
How much can caching save?
It depends on prefix reuse and hit rate. Cache reads are usually clearly below the input price, but cache writes carry a premium; a prefix that is too short may not be cacheable, and content that changes every time will not hit.
What tasks suit the Batch API?
Non-real-time, delay-tolerant labeling, summaries, classification, and bulk extraction; not online customer support or interactions that need an immediate response. Batch processing usually has a discount, but you must accept queuing and delayed results.
Why is the bill higher than estimated?
Common omissions include message history, tool definitions, images, retries, cache writes, and long outputs. Match request IDs against usage logs to locate the difference.
How can teams in mainland China settle in RMB?
You can call Claude through an AI gateway that offers RMB top-ups and invoices, with unified billing across models. Available models, prices, and invoice rules are subject to model pricing.
Next steps
First create a test key at the ZSQH AI Gateway, run a batch of real tasks through both Haiku and Sonnet, record tokens and quality, and then choose your primary model. Model availability and prices are subject to model pricing.
Related reading:
