◈AI Codex
Developer PathStep 9 of 21
← Prev·Next →
Infrastructure & DeploymentHow It Works

Cutting Claude API costs without cutting quality

In brief

The levers that actually move a Claude API bill in late 2026, in order: measure, cache, tune effort, pick the right model, batch, and trim context. Updated for the 5.5 models.

7 min read··

Contents

♡Sign in to save

Claude API costs scale with tokens: everything you send, everything Claude writes, and the thinking it does in between. For most apps, a few decisions make up most of the bill. Here they are, in the order worth trying.

Last checked: November 2, 2026. Prices are per million tokens (input / output). Check claude.com/pricing before you plan around them.

Model Input / output Cache read
Claude Fable 5.2 $8 / $40 $0.20
Claude Opus 5.5 $4 / $20 $0.20
Claude Sonnet 5.5 $2 / $10 $0.10
Claude Haiku 5.5 $0.10 / $0.50 (up to 100K-token prompts) $0.01

Start with measurement

You cannot cut what you cannot see. Log token usage per route before you change anything:

from collections import defaultdict

PRICES = {  # $ per million tokens: (input, output, cache read)
    "claude-fable-5-2": (8, 40, 0.20),
    "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),
}

cost_by_route = defaultdict(float)

def record(usage, route: str, model: str):
    inp, out, cached = PRICES[model]
    cost = (
        usage.input_tokens * inp
        + usage.output_tokens * out
        + (usage.cache_read_input_tokens or 0) * cached
    ) / 1_000_000
    cost_by_route[route] += cost

Cache writes cost a little more than normal input, so this is a close estimate, not an invoice. Run it for a week. A few routes usually make up most of the cost. For exact numbers, use the Usage and Cost reports in the Claude Console. To pull those numbers into your own dashboard, grouped by model, workspace or API key, use the Usage and Cost Analytics API (beta since October 29, 2026, with an Admin API key). Its data can lag by up to a day, so keep your own logging for same-day checks.

The changes that matter most

1. Prompt caching

If you resend the same long system prompt, tool list or document on every request, cache it. Cache reads cost 10% of normal input or less (2.5% on Fable 5.2). This is usually the biggest single saving, and it does not change output quality at all.

The catch: caching matches the start of the request exactly. Keep stable content first and anything that changes (timestamps, user questions) at the end.

2. Effort

Every current model has an effort setting (low, medium, high, xhigh, max). It controls how much the model thinks, and thinking is billed as output. Lower effort means fewer tokens, fewer tool calls and shorter answers.

response = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=16000,
    output_config={"effort": "low"},  # chat, lookups, simple sub-tasks
    messages=[{"role": "user", "content": question}],
)

Try a strong model at lower effort before switching to a weaker model. It often keeps quality and costs less. Defaults differ: Sonnet 5.5 defaults to high, while Opus 5.5 and Haiku 5.5 default to medium.

3. The right model for each route

Most apps mix easy and hard work:

  • Haiku 5.5 for classifying, extracting, tagging and formatting. It is a twentieth of Sonnet's price on short prompts and now has the same 1M context and thinking.
  • Sonnet 5.5 for most generation, Q&A and agents.
  • Opus 5.5 or Fable 5.2 for hard reasoning where a better answer is worth paying for.
def choose_model(task_type: str) -> str:
    if task_type in ("classify", "extract", "format"):
        return "claude-haiku-5-5"
    if task_type in ("plan", "review", "hard_reasoning"):
        return "claude-opus-5-5"
    return "claude-sonnet-5-5"

Two cautions. Caches belong to one model, so routing across many models loses cache reuse. And measure cost per finished task, not per request: a cheap call that needs a retry is not cheap. Check every routing change against your evals.

4. Batch for anything that can wait

Nightly reports, bulk tagging and document analysis do not need an instant answer. The Batch API takes 50% off both input and output, and it stacks with caching.

batch = client.messages.batches.create(
    requests=[
        {
            "custom_id": f"doc_{i}",
            "params": {
                "model": "claude-haiku-5-5",
                "max_tokens": 1024,
                "messages": [{"role": "user", "content": doc}],
            },
        }
        for i, doc in enumerate(documents)
    ]
)

Results can come back in any order, so match them by custom_id.

5. Send less context

Long conversations get more expensive with every turn, because you resend the whole history. Options, from simplest:

  • Start a new conversation when the topic changes
  • Drop old tool results you no longer need (context editing)
  • Let the API summarize old turns for you (compaction)
  • Only send the parts of a document that matter, rather than the whole file

6. Keep answers short when short is enough

Output costs five times as much as input. Ask for the length you need ("in two sentences", "return JSON only"), and use structured outputs when you just need data back. Set max_tokens high enough that answers are not cut off, since a cut-off answer usually means a paid retry.

What rarely helps

  • Squeezing words out of prompts. You save a little input and often lose quality.
  • Switching providers just for price. New evals, new prompts and new failure modes usually cost more than the per-token saving.
  • Tuning output length before caching. A big system prompt sent thousands of times a day costs far more than the answers.

A one-hour audit

Look at last week's usage and ask:

  1. Which routes resend the same long prompt? Cache them.
  2. Which routes run at high effort but do simple work? Lower it.
  3. Which routes could run on Haiku 5.5? Test them against your evals.
  4. Which jobs could wait a few hours? Batch them.
  5. Which conversations grow without limit? Trim or compact them.

Most apps find large savings in the first pass without any loss in quality.

Official training on this: Building with the Claude API (67 lessons · 9 hr) · Tokens and embeddings on Claude Academy, free.

Related tools

Next in Developer Path · Step 10 of 21

Continue to the next article in the learning path

Next article →

Weekly brief

For people actually using Claude at work.

Each week: one thing Claude can do in your work that most people haven't figured out yet — plus the failure modes to avoid. No tutorials. No hype.

No spam. Unsubscribe anytime.

What to read next

Picked for where you are now

All articles →