CLAUDE LABJP
FORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as OctoberFORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as October
Articles/API & SDK
API & SDK/2026-04-12Advanced

Intelligent Model Routing with Claude API — Auto-Selecting Sonnet 4.6 and Haiku 4.5 for Optimal Cost and Quality

Build an intelligent routing layer that automatically selects between Claude Sonnet 4.6 and Haiku 4.5 based on request complexity. Covers classifier design, circuit breakers, fallback chains, and cost monitoring for production deployments.

claude-api81model-routingcost-optimization28production111sonnet-4-62haiku-4-52

Premium Article

I've been shipping iOS and Android apps as an indie developer since 2014. Across roughly 50 million cumulative downloads, there was exactly one morning when I felt my chest go cold: the day AdMob's eCPM halved overnight and my monthly revenue dropped from one million yen to mid-five-hundred-thousand. It wasn't the lost income that scared me — it was the realization that a cost curve I'd assumed was compounding upward had quietly slipped out of my control.

I felt that same chill again after wiring Claude API into the automated publishing pipeline for the four Dolice Labs sites (Claude Lab, Gemini Lab, Antigravity Lab, Rork Lab). Sonnet 4.6 is genuinely smart. But pinning every request to Sonnet while writing 16 articles a day pushes the monthly bill up by an order of magnitude. Go the other direction and run everything on Haiku 4.5, and the membership-grade articles start failing article_gate.py more often than they pass.

You can't solve this dilemma by picking one model. The only way out is to classify request complexity upfront and route each call to the cheapest model that still produces acceptable quality — what I'll call intelligent model routing throughout this article. What follows is the pattern I've actually been running for over six months across those four sites plus iOS/Android support bots, written up with the operational gotchas I only discovered in production.

The Cost-Quality Tradeoff You're Ignoring

Let's start with the numbers, because they motivate everything that follows.

As of Q1 2026, Claude Sonnet 4.6 costs roughly 3x as much as Haiku 4.5 per 1M input tokens and 15x as much per 1M output tokens. In a system serving diverse workloads, that difference compounds fast.

A content moderation task—checking if a user comment violates policy—doesn't need Sonnet's extended reasoning. Haiku handles it reliably and responds in 100ms vs. 300ms for Sonnet. You're paying 15x the cost for 3x slower latency.

A creative copywriting task for email marketing? That does need Sonnet. The output quality difference is material. Users notice.

The problem isn't that Sonnet is expensive. It's that you're routing both tasks to the same model. In a mature system with thousands of daily requests, that wastes millions of tokens annually.

Intelligent routing flips the equation. Instead of "use the best model for everything," you ask: "What's the minimal model that solves this specific task reliably?" The answers vary wildly by use case.

How to Classify Request Complexity

Before you can route, you need to know what you're routing. That means classifying incoming requests as either "simple" (Haiku-suitable) or "complex" (Sonnet-necessary).

The classification problem is harder than it sounds. A request that looks simple (three words) might need deep reasoning if it contains jargon or philosophical nuance. A long request might be simple—just verbose.

I've found that a three-layer classifier works well in practice:

Layer 1: Keyword-based routing — The fastest. Certain task types almost always route to one model. "Summarize this" or "extract the key points" rarely needs Sonnet. "Brainstorm campaign ideas" or "debug this code" usually does. A simple regex or string-matching layer catches maybe 40-50% of requests with near-zero cost.

Layer 2: Token count and structural analysis — For requests that don't match known patterns, look at token count (longer ≠ harder, but extreme length correlates with complexity) and structural signals like nested queries or conditional logic. This catches another 30-40%.

Layer 3: Embedding-based classification — For the remaining 10-20% of ambiguous requests, compute an embedding and compare to examples of "simple" and "complex" tasks from your production logs. This is accurate but slower and costs tokens, so use it sparingly.

Most teams I've worked with find that layers 1 and 2 alone handle 80-90% of production traffic correctly. Layer 3 is a nice-to-have for high-value requests where a mismatch is costly.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
A two-tier routing pattern that pins the classifier itself to Haiku, cutting roughly $1,500/month in classification overhead to a quarter.
Real production numbers: 35→50% Sonnet ratio alerting, dedicated half-open health checks, prompt-cache hit rate recovering from 12% → 64%.
Eight operational gotchas not in Anthropic's docs, drawn from running this across four Dolice Labs sites and iOS/Android support bots for 6+ months.
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

API & SDK2026-07-13
Coalescing Concurrent Claude API Calls: Single-Flight Against Duplicate Inference and Cache Stampede
A design for collapsing identical prompts that fire at the same instant into a single upstream Claude call, using single-flight (request coalescing). In-process and distributed implementations, jittered retries, and negative caching, with measured results.
API & SDK2026-05-29
Splitting Claude API prompt cache into 5m and 1h tiers — separate TTLs cut cost and stabilize ops
Anthropic's cache_control supports two TTLs: 5 minutes and 1 hour. Splitting them into a two-tier layout — 1h for static system/tools, 5m for variable few-shot — meaningfully changed both my costs and my on-call life. Here's the design with the numbers I observed.
API & SDK2026-05-05
The Real Cost of Claude API Extended Thinking in Production — ROI Data by Task Type
Three months of measured cost, quality, and speed data for Extended Thinking across five task categories. Learn exactly when extended thinking is worth it—and when it's not.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →