How to Reduce AI Coding Costs 40-60% with Model Tiering
▶ Watch on YouTube & subscribe to The Stack Underflow
If your coding agent is routing every single task — intent classification, file summarization, quick linting, response formatting — through your most expensive model, you are paying flagship prices for grocery-run work. The spread is not small: on the current Anthropic API, Claude Haiku 4.5 costs $1 per million input tokens and $5 per million output tokens; Claude Sonnet 4.6 costs $3 and $15; Claude Opus 4.8 costs $5 and $25 (docs.anthropic.com/pricing, 2026). That is a 5x price gap between the cheapest and middle tier, and up to 25x on output tokens between Haiku 4.5 and the new Opus-class models. Run a 100,000-call workload through the wrong tier by default and you are leaving hundreds of dollars a month on the table.
The fix is model tiering — a routing discipline where each task type is matched to the model tier that meets its quality floor without exceeding it. Industry production audits land consistently at 40–60% total spend reduction, with no measurable quality degradation on routed tasks. Some pipelines that also stack prompt caching and batch processing on top report 60–80% cuts (Requesty engineering blog, 2026; Augment Code routing guide, 2026). This tutorial traces the mechanism, gives you the current numbers, and shows you how to instrument it so you can see the savings in real time.
The one-sentence version: Most tasks an AI coding agent performs don’t require a frontier model — routing them to cheaper tiers halves your bill while leaving output quality untouched on those tasks.
The pricing reality in 2026: five tiers, not one
The Anthropic model family has expanded well beyond the three-tier mental model most teams still carry. As of mid-2026, the active (non-deprecated) lineup looks like this (docs.anthropic.com/pricing, 2026):
Model Input ($/MTok) Output ($/MTok) Cache Read ($/MTok)
─────────────────────────────────────────────────────────────────────────
Claude Haiku 4.5 $1.00 $5.00 $0.10
Claude Sonnet 4.5/4.6 $3.00 $15.00 $0.30
Claude Opus 4.5/4.6/4.8 $5.00 $25.00 $0.50
Claude Fable 5 $10.00 $50.00 $1.00
A few things stand out. First, the Opus 4.x family (4.5, 4.6, 4.8) is now significantly cheaper than Opus 4.1, which was deprecated at $15/$75 per MTok. The 4.x generation repriced the flagship tier to be more accessible. Second, cache reads are charged at 10% of the base input price across all models — the same multiplier regardless of tier. That means caching amplifies the savings from tiering rather than competing with it. Third, the Batch API shaves another 50% off both input and output tokens for asynchronous work, bringing Haiku 4.5 to $0.50 input / $2.50 output per MTok.
Note: Opus 4.7 and later use a new tokenizer that may consume up to 35% more tokens for the same fixed text (Anthropic docs, 2026). Factor this into any like-for-like cost comparison between old and new Opus models.
The routing pattern: task to tier
The core insight: not all tasks an agent performs require the same cognitive depth. Break a typical agent session down by task type and the right tier becomes immediately obvious.
TASK TYPE TIER REASON
─────────────────────────────────────────────────────────────────────
Intent classification Haiku 4.5 Capability-floor task
File/directory summarization Haiku 4.5 Pattern matching, not reasoning
Structured data extraction Haiku 4.5 Template completion
Lint-fix application Haiku 4.5 Simple transformation
Code review (simple) Haiku 4.5 Known heuristics
Multi-file refactoring Sonnet 4.6 Sustained coherence needed
Code generation from spec Sonnet 4.6 Workhorse inference
Routine debugging Sonnet 4.6 Context + pattern
Test generation Sonnet 4.6 Generation quality matters
Architecture decisions Opus 4.8 Deep reasoning required
Race-condition debugging Opus 4.8 Multi-hypothesis search
Complex multi-step planning Opus 4.8 Orchestration quality
Novel API design Opus 4.8 Frontier needed
The Augment Code routing guide (2026) measured a real multi-agent session at 104K input / 60K output tokens. Run uniformly through Opus 4.6: $2.02. With three-tier routing, routing file ops and quick edits to Haiku 4.5 and implementation to Sonnet 4.6: $0.98. That is a 51% reduction on a single session, matching the 40–60% range reported across production deployments.
The rule: efficient by default, escalate only when the task earns it. Most of what an agent does in a day is not genius-level work. It is competent, high-volume, pattern-matching work — exactly where smaller models earn their keep.
What the numbers actually look like
The math at scale makes the case concretely. Assume 100,000 agent calls per month — a reasonable figure for a team actively using AI coding tools:
Scenario Avg cost/call Monthly spend
─────────────────────────────────────────────────────────────────────
All calls → Opus 4.8 ~$0.014 ~$1,400
Three-tier routing (70/20/10) ~$0.005 ~$500
Tier routing + prompt caching ~$0.003 ~$300
Tier + caching + Batch API ~$0.002 ~$200
Savings vs. uniform Opus: 64-86%
The 70/20/10 distribution — 70% of volume to Haiku, 20% to Sonnet, 10% to Opus — is a common empirical finding across production AI agent workloads (Requesty engineering blog, 2026). It is not a prescription; your actual distribution depends on what your agent does. Log your calls, tag them by task type, and measure your own ratio before applying the framework.
| Cost lever | Savings range | Stacks with others? |
|---|---|---|
| Model tiering (routing) | 40–60% | Yes |
| Prompt caching (cache reads) | 30–90% on input | Yes |
| Batch API (async tasks) | 50% flat | Yes |
| Combined (all three) | 60–86% total | — |
Why quality does not drop on routed tasks
The obvious concern when you hear “cheaper model” is degraded output quality. The answer hinges on a distinction between two types of problems.
Capability-floor problems ask: can the model do the task at all? Classification, extraction, formatting, and simple transformations are capability-floor problems. The floor for these tasks is low. Claude Haiku 4.5 clears it comfortably. The cheaper model is not “worse” at these tasks in any meaningful sense — it is above the floor, and above-the-floor is all you need.
Reasoning-depth problems ask: how far can the model reason before it loses track? Architecture decisions, complex debugging, and multi-hypothesis planning are reasoning-depth problems. Here, Opus 4.8’s extended reasoning and deeper context integration do matter. Routing a reasoning-depth problem to Haiku would produce visibly degraded output. That is not a failure of the routing strategy — it is a failure to classify the task correctly.
The skill is matching the task category to the model, not blindly applying the cheapest option. Routing is not “use a cheaper model.” It is “use the right model for the actual problem type.”
Stacking this with prompt caching
Prompt caching lets the API reuse previously processed portions of your prompt across calls, charging cache reads at 10% of the base input price instead of 100%. The two mechanisms — tiering and caching — compound, not compete.
The cache pricing structure (docs.anthropic.com/pricing, 2026):
Cache operation Multiplier Duration
─────────────────────────────────────────────────
5-minute cache write 1.25× Refreshed on each hit
1-hour cache write 2.0× Refreshed on each hit
Cache read (any model) 0.10× Same duration as write
On a Haiku 4.5 call where 4,000 tokens of system prompt are cached: the uncached cost would be $0.004 per call ($1/MTok × 4K tokens). With a cache hit, it drops to $0.0004. For a system prompt that stays constant across thousands of calls, this alone can eliminate most of the input cost at the Haiku tier.
Important: as of February 2026, caches are isolated per workspace within an organization on the Claude API, Claude Platform on AWS, and Microsoft Foundry. If you split traffic across multiple workspaces, each workspace maintains its own cache — shared prefixes between workspaces no longer result in cache hits (Anthropic docs, 2026). Review your workspace architecture if you use multiple workspaces for the same agent fleet.
Minimum cacheable token length for the models most relevant to agent cost optimization: Haiku 4.5 requires 4,096 tokens to trigger caching; Sonnet 4.5/4.6 requires 1,024; Opus 4.8 requires 1,024. Sub-threshold requests process normally without error, but also without caching.
Observability: seeing the savings in real time
You cannot optimize what you cannot see. The OpenTelemetry GenAI semantic conventions define a standard way to instrument LLM calls in agent pipelines (opentelemetry.io, 2026). For cost tracking, the key span attributes are:
Span attribute What it measures
──────────────────────────────────────────────────────────────────────
gen_ai.request.model Which model tier handled the call
gen_ai.usage.input_tokens Total input tokens (includes cached)
gen_ai.usage.output_tokens Output tokens
gen_ai.usage.cache_read_input_tokens Tokens served from cache
gen_ai.usage.cache_creation_tokens Tokens written to cache
gen_ai.client.operation.duration Latency histogram
The span hierarchy for a multi-agent coding workflow follows a nested structure: a top-level invoke_agent span wraps child chat spans (one per LLM call) and execute_tool spans (one per tool call). This lets you trace cost per agent role, per task type, and per model — the three dimensions you need to validate that routing is working as expected.
Instrument every LLM call with these attributes, tag calls with a task_type label from your routing logic, and you get a real-time cost dashboard that shows exactly which task categories are burning budget and whether the routing is holding.
How to apply this right now
-
Audit your calls before you route. Log every LLM call your agent makes for one week. Tag each call with a task type (classification, summarization, generation, planning, review). Measure your current distribution across task types. This is your baseline — you need it to verify that routing is actually reducing spend, not just moving costs around.
-
Start with static routing, not a meta-model. The simplest implementation is an
if/elsebranch before the API call: is this a structured extraction? Use Haiku 4.5. Is this multi-file code generation? Use Sonnet 4.6. Is this an architectural decision? Use Opus 4.8. Static routing has zero latency overhead and is trivially auditable. Add dynamic complexity-based routing only after you have measured that the static approach leaves significant money on the table. -
Add prompt caching to your system prompt first. Every agent has a system prompt that repeats on every call. Wrap it in a cache breakpoint and the cache starts paying for itself after the first cache hit. For a 5-minute TTL, one hit breaks even; for a 1-hour TTL, two hits break even. At high call volume, this is free money.
-
Move non-interactive tasks to the Batch API. Code review, test generation, and documentation tasks that do not block the developer can run asynchronously via the Batch API at 50% off. Combine Haiku 4.5 batch pricing ($0.50 input / $2.50 output per MTok) with prompt caching and you reach the economics of the fourth row in the table above.
-
Instrument with GenAI semantic conventions before you ship. Add OpenTelemetry spans to every LLM call — at minimum
gen_ai.request.model,gen_ai.usage.input_tokens, andgen_ai.usage.output_tokens. These three attributes let you calculate per-call cost, verify routing decisions, and catch token-hungry prompts before they become a line item.
Common misconceptions
“Cheaper models are just worse — full stop.” For reasoning-depth tasks like architectural decisions or complex debugging, Opus delivers measurably better results. For capability-floor tasks like intent classification, file summarization, and structured extraction, Haiku 4.5 is sufficient — it is above the capability floor, which is all that matters. The task type and the model tier need to be evaluated together, not in the abstract.
“Routing is too complex to implement.” At its simplest, routing is an if/else branch before your API call. You do not need a meta-classifier or an ML-based router to see the savings. Start with explicit task-type tags in your agent code and route statically. A meta-model router makes sense only at very high volume where static rules fail to capture task complexity variation.
“The 40-60% savings figure only applies to huge workloads.” The percentage savings is a function of your task distribution, not raw volume. A team spending $200/month on AI coding could see $80–$120 back. The absolute savings scale with spend; the ratio is stable across volume levels.
“Quality loss from routing is invisible and insidious.” When tasks are correctly matched to tiers, production audits consistently show no measurable quality degradation. The risk of invisible quality loss is real only when routing is done without task analysis — i.e., sending everything to the cheap tier without asking whether the task requires deeper reasoning. Red-team your routing logic: run a sample of each routed task through both the assigned tier and the tier above it, and compare outputs. If the cheaper model produces equivalent results, the route is correct.
Frequently asked questions
How do I know which tasks to route to which tier?
Start with an audit: log every LLM call your agent makes, tag it with a task type, and review the outputs from your current model. Then ask for each task category: would a less capable model have produced an output that was good enough? “Good enough” is a quality floor question, not a perfection question. Classification, extraction, and formatting almost always route down. Planning, architecture, and novel code generation almost always stay at the top tier.
Does the 40-60% savings estimate hold for my specific workload?
It depends on your task distribution. The 40-60% range comes from production workloads where the majority of calls are capability-floor tasks. If your agent is primarily doing deep architecture work, the distribution shifts and savings shrink. If your agent spends most of its time on extraction and summarization, savings could exceed 60%. Measure your own distribution before projecting savings.
What if I am using a provider other than Anthropic?
The routing principle applies universally. OpenAI ships GPT-4o Mini alongside GPT-4o; Google ships Gemini Flash alongside Gemini Pro. Every major provider has a sub-$1 input tier and a frontier tier with a 10x or larger gap. The specific model capabilities differ by provider, but the economic logic — route capability-floor tasks to the cheapest sufficient tier — is universal.
Should I ever use Opus as my default?
If your agent is primarily doing tasks that genuinely require frontier-level reasoning — extended multi-step planning, subtle concurrency bug diagnosis, novel API design — then yes, Opus 4.8 may be appropriate as the default for that specific pipeline. But most general-purpose coding agents do not fit that profile. Start with Sonnet 4.6 as your default and escalate to Opus only on explicit triggers from your task classifier.
How does prompt caching interact with model tiering?
They compound. If you cache your system prompt and route to Haiku 4.5 for extraction tasks, cache reads are charged at $0.10 per MTok (10% of the $1.00 base Haiku rate). The 90% discount on cached tokens stacks on top of the already-discounted Haiku tier. The result is that a heavily cached Haiku workload can cost less than a tenth of the same workload running on Opus without caching.
How do I know if my prompt caching is actually working?
Check the cache_read_input_tokens and cache_creation_input_tokens fields in the API response’s usage object. If both are zero after the first call, caching did not engage — usually because the prompt is below the minimum cacheable length for that model (4,096 tokens for Haiku 4.5 and Sonnet 4.5; 1,024 tokens for Sonnet 4.6 and Opus 4.8), or because the cache_control parameter was not placed on the correct content block.
Where this fits in the series
This tutorial is episode 6 of the “Hidden Cost of AI Coding” series, which works through every cost lever in AI coding systems from the ground up. Episode 5 attacked repeated context through prompt caching — covered in depth in Prompt Caching: Anthropic vs OpenAI. The context mechanics that make caching possible are traced in How the Context Window Works and Bigger Context Windows, Worse Memory.
The next episode covers context engineering — the discipline that has quietly replaced prompt engineering as the primary lever for agent quality and cost control. That tutorial at Context Engineering as a Discipline closes the series.
For the agent-level patterns that determine which tasks your orchestrator assigns to which sub-agent — and therefore which tier handles them — see Multi-Agent Patterns That Actually Work and Subagent Isolation and Context Rot.
For observability infrastructure to verify routing is working, see Agent Observability.
Browse all tutorials to work through the full series in order.
Found this useful? The deep version lives on YouTube — new breakdowns of how AI dev tools actually work, weekly.
Subscribe on YouTube →