
TL;DR
A practical guide to routing between Claude Opus 5, Sonnet 5, Haiku 4.5, GPT-5.6 Sol/Terra/Luna, and Kimi K3 based on task complexity, cost budget, and latency requirements - with decision frameworks and code examples.
Last updated: July 31, 2026. All prices verified from official pricing pages on July 31, 2026.
GPT-5.6 Luna dropped 80% to $0.20/$1.20 per MTok (July 30). OpenAI cut Luna from $1/$6 and Terra from $2.50/$15 to $2/$12, and renamed Priority Processing to Fast mode (2x pricing, up to 2.5x speed). Full detail in our price-cut analysis.
This changes routing math in two concrete ways:
DeepSeek announced peak/off-peak pricing (July 31). The pricing page now warns that rates will double during peak hours (09:00-12:00 and 14:00-18:00 Beijing Time, UTC+8), effective date to be announced. V4 Flash also updated to version DeepSeek-V4-Flash-0731 with 1M context, 384K max output, and Anthropic-format API support. If you route to DeepSeek, expect peak-hour economics to change when the policy lands, and schedule batch work off-peak.
The era of one model for everything is over. Between Claude Fable 5 at $10/$50 per MTok and DeepSeek V4 Flash at $0.14/$0.28, the cost spread is 178x on input and 178x on output. Using the same model for every task is like buying first-class tickets for every flight - comfortable, but your budget does not survive first contact with production traffic.
Model routing is the practice of sending each request to the cheapest model that can handle it correctly. This post covers the current model landscape, routing strategies by task type, implementation patterns, and a decision framework you can apply today.
A coding agent performs many different operations in a single session. It browses files (trivial), reads documentation (simple), writes boilerplate (medium), debugs a race condition (complex), and occasionally rewrites a core architecture (frontier). Routing each subtask to the right model saves money without sacrificing quality.
Without routing, you have two bad options:
Routing splits the difference. Simple tasks go to cheap models. Hard tasks go to capable models. The savings compound across thousands of agentic steps per day.
All prices verified July 31, 2026 from official pricing pages. See the frontier API pricing tracker for the full table with cache and batch rates.
| Tier | Model | Input/MTok | Output/MTok | Best For |
|---|---|---|---|---|
| Frontier | Claude Fable 5 | $10 | $50 | Max intelligence, long-running agents |
| Frontier | GPT-5.6 Sol | $5 | $30 | Complex reasoning, code generation |
| High | Claude Opus 5 | $5 | $25 | Complex agentic coding, enterprise work |
| Mid | Claude Sonnet 5 | $3 ($2 promo) | $15 ($10 promo) | Best speed/intelligence balance |
| Mid | GPT-5.6 Terra | $2 | $12 | Mid-tier coding tasks (cut 20% July 30) |
| Mid | Kimi K3 | $3 | $15 | Self-hosted open-weight coding |
| Low | GPT-5.6 Luna | $0.20 | $1.20 | Default budget worker (cut 80% July 30) |
| Low | Claude Haiku 4.5 | $1 | $5 | Fastest Claude, simple tasks |
| Budget | DeepSeek V4 Pro | $0.435 | $0.87 | High-volume simple tasks |
| Budget | DeepSeek V4 Flash | $0.14 | $0.28 | Maximum cost efficiency |
The July 30 cuts reordered the low tier: Luna at $0.20/$1.20 is now cheaper than Haiku 4.5 on both input and output, making it the default budget worker for OpenAI shops. DeepSeek V4 Flash remains the absolute floor at $0.14/$0.28, but its announced peak/off-peak pricing (2x during peak hours, date TBD) adds scheduling risk.
These are directional assessments based on published benchmarks and production experience. Not every model shines at every task type.
| Task Type | Models That Handle It Well |
|---|---|
| File read, grep, simple refactors | Haiku 4.5, Luna, V4 Flash, V4 Pro |
| Boilerplate generation, test writing | Sonnet 5, Terra, Kimi K3, V4 Pro |
| Bug diagnosis, code review | Opus 5, Sonnet 5, Terra |
| Architecture design, complex refactoring | Opus 5, Sol, Fable 5 |
| Multi-file orchestration, agentic workflows | Fable 5, Sol, Opus 5 |
| Documentation, explanation | Sonnet 5, Haiku 4.5, Luna |
From the archive
Jul 30, 2026 • 10 min read
Jul 30, 2026 • 8 min read
Jul 30, 2026 • 9 min read
Jul 29, 2026 • 9 min read
The simplest and most effective strategy. Classify each request by complexity and route to the appropriate tier.
Simple (Luna / Haiku 4.5 / V4 Flash):
- Read a file
- Search for a pattern
- Run a linter
- Generate a getter/setter
Medium (Sonnet 5 / Terra / Kimi K3):
- Write a test suite
- Refactor a function
- Generate API route handlers
- Review a PR for style issues
Complex (Opus 5 / Sol):
- Debug a race condition
- Design a database schema
- Rewrite a core module
- Plan a multi-step refactor
Frontier (Fable 5 / Sol Pro):
- Novel algorithm design
- Security audit
- Complex multi-agent coordination
Implementation is straightforward - tag each request with a complexity level and switch models:
type Complexity = 'simple' | 'medium' | 'complex' | 'frontier';
const MODEL_MAP: Record<Complexity, string> = {
simple: 'gpt-5-6-luna', // $0.20/$1.20 after the July 30 cut
medium: 'claude-sonnet-5', // $3/$15 (promo $2/$10)
complex: 'claude-opus-5', // $5/$25
frontier: 'claude-fable-5', // $10/$50
};
function routeRequest(task: Task, complexity: Complexity) {
const model = MODEL_MAP[complexity];
return callModel(model, task.prompt);
}
Set a per-request or per-session budget and let the router pick the model dynamically. Useful for cost-sensitive workloads like CI/CD pipelines or bulk processing.
interface BudgetConfig {
maxInputCostPerMTok: number;
maxOutputCostPerMTok: number;
}
function pickModelByBudget(budget: BudgetConfig): string {
const models = [
{ name: 'gpt-5-6-luna', input: 0.2, output: 1.2 },
{ name: 'claude-haiku-4-5', input: 1, output: 5 },
{ name: 'claude-sonnet-5', input: 3, output: 15 },
{ name: 'deepseek-v4-flash', input: 0.14, output: 0.28 },
];
const candidates = models.filter(
m => m.input <= budget.maxInputCostPerMTok
&& m.output <= budget.maxOutputCostPerMTok
);
return candidates.sort((a, b) => a.input - b.input)[0]?.name ?? 'claude-opus-5';
}
Run models from multiple providers and route based on availability, latency, or pricing shifts. This protects against provider outages and lets you arbitrage pricing differences.
interface ProviderConfig {
provider: 'anthropic' | 'openai' | 'moonshot' | 'deepseek';
model: string;
priority: number;
}
const PROVIDER_CHAIN: ProviderConfig[] = [
{ provider: 'anthropic', model: 'claude-sonnet-5', priority: 1 },
{ provider: 'openai', model: 'gpt-5-6-terra', priority: 2 },
{ provider: 'moonshot', model: 'kimi-k3', priority: 3 },
];
async function routeWithFallback(task: Task): Promise<Result> {
for (const config of PROVIDER_CHAIN.sort((a, b) => a.priority - b.priority)) {
try {
return await callProvider(config.provider, config.model, task);
} catch (err) {
console.warn(`${config.provider}/${config.model} failed:`, err);
continue;
}
}
throw new Error('All providers failed');
}
Use a cheap model to decide which model to use for the actual task. The router model analyzes the request and returns a complexity score or model recommendation.
async function routerLLM(task: Task): Promise<Complexity> {
const routerPrompt = `Classify this coding task as "simple", "medium", "complex", or "frontier".
Task: ${task.description}
Respond with exactly one word.`;
const response = await callModel('claude-haiku-4-5', routerPrompt);
return response.trim().toLowerCase() as Complexity;
}
async function routedCall(task: Task) {
const complexity = await routerLLM(task);
const model = MODEL_MAP[complexity];
return callModel(model, task.prompt);
}
The routing LLM costs about $0.001 per classification with Haiku 4.5. On a 10:1 simple-to-complex ratio, this saves 90%+ on the simple tasks while keeping the routing overhead below 1% of total cost.
| Team Type | Recommended Strategy | Estimated Savings vs Always-Opus-5 |
|---|---|---|
| Solo dev, daily coding | Task-complexity routing (Haiku + Sonnet + Opus 5) | 40-60% |
| Small team on a budget | Cost-budget routing with Haiku + Luna + Terra | 60-80% |
| CI/CD pipelines | Budget routing with V4 Flash + Haiku | 80-95% |
| Production agent platform | LLM-as-router + provider fallback | 50-70% |
| Enterprise with fixed budget | Provider-level routing across all tiers | 40-50% |
| Daily Token Volume | Model Strategy | Recommended Setup |
|---|---|---|
| < 10M tokens | Single model | Sonnet 5 or Terra |
| 10M - 100M tokens | 2-tier routing | Haiku + Sonnet |
| 100M - 1B tokens | 3-tier + caching | Haiku + Sonnet + Opus 5 |
| 1B+ tokens | Full routing + provider fallback | All tiers, multi-provider |
Routing is not free. It adds complexity, testing surface, and potential failure modes. Skip it when:
Model routing is the practice of sending different coding tasks to different AI models based on task complexity, cost sensitivity, or latency requirements. Simple tasks like file reads go to cheap models like GPT-5.6 Luna ($0.20/$1.20 after the July 30 cut) or DeepSeek V4 Flash. Complex tasks like architecture design go to capable models like Claude Opus 5 or GPT-5.6 Sol. The goal is to maximize output quality while minimizing token cost.
Savings depend on your task distribution. A typical coding agent session has about 70% simple tasks, 20% medium tasks, and 10% complex tasks. Routing these appropriately saves 40-60% compared to using Opus 5 for everything, and 80-95% compared to using Fable 5 for everything. CI/CD pipelines see the largest savings because most automated tasks are simple.
A common three-tier setup: GPT-5.6 Luna ($0.20/$1.20) or Claude Haiku 4.5 ($1/$5) for simple tasks, Claude Sonnet 5 ($3/$15, promo $2/$10) or GPT-5.6 Terra ($2/$12) for medium tasks, and Claude Opus 5 ($5/$25) or GPT-5.6 Sol ($5/$30) for complex tasks. Budget workloads can substitute DeepSeek V4 Flash ($0.14/$0.28) for the simple tier. All prices verified July 31, 2026.
Yes. Provider-level routing between Anthropic and OpenAI is common for fallback and cost arbitrage. Both providers have compatible API formats. The main consideration is response quality differences - Opus 5 and Sol are close on coding benchmarks but may handle specific task types differently. Test your routing logic with both providers before production deployment.
Claude Code uses the model selected in its configuration for all tasks within a session. It does not support per-request model routing. For routing at the API level, build your own routing layer and call the Claude API directly with different model parameters per request. Cursor, Codex, and Windsurf similarly use a single model per session - routing is an API-layer concern, not a tool feature.
DeepSeek V4 Flash at $0.14/$0.28 per MTok is the cheapest available coding model as of July 2026, verified on DeepSeek's pricing page July 31. GPT-5.6 Luna at $0.20/$1.20 (after the July 30 cut) and Claude Haiku 4.5 at $1/$5 are the cheapest options from major US providers, with Luna now undercutting Haiku on both rates. For self-hosted workloads, Kimi K3 open weights or DeepSeek V4 self-hosted eliminate per-token costs entirely (infrastructure costs still apply). Note DeepSeek's announced peak/off-peak policy: peak-hour rates double once it lands, effective date to be announced.
Only if your token volume exceeds about 10 million tokens per month. Below that threshold, the engineering cost of building and maintaining routing logic exceeds the savings. Use a single mid-tier model like Claude Sonnet 5 or GPT-5.6 Terra and switch to routing when your costs justify the complexity.
All prices verified July 31, 2026:
| Source | Description |
|---|---|
| Anthropic Models | Current Claude model IDs, capabilities, and pricing |
| Anthropic Pricing | Official Claude API per-token rates |
| OpenAI API Pricing | Current OpenAI model pricing (GPT-5.6 family) |
| OpenAI Price-Performance Announcement | July 30 Luna/Terra price cuts and Fast mode |
| Moonshot Kimi K3 Pricing | Kimi K3 API per-token pricing |
| DeepSeek Pricing | V4 Pro and V4 Flash per-token rates, peak/off-peak notice |
| Frontier Model API Pricing Tracker | Full comparison table with cache and batch rates |
Read next
Same-day-verified llm api pricing july 2026: Claude Fable 5, GPT-5.6 Sol/Terra/Luna, Claude Sonnet 5, Gemini 3.5 Flash, and DeepSeek V4 compared per million tokens, plus the caveats that change the math.
11 min readComplete pricing breakdown for every major AI coding tool. Claude Code, Cursor, Copilot, Windsurf, Codex, Augment, and more. Free tiers, pro plans, hidden costs, and what you actually get for your money.
12 min readClaude Opus 5 launched July 24, 2026 at $5/$25 per MTok - matching Opus 4.8 pricing while delivering near-Fable 5 intelligence. Full benchmark comparison across 7 evals, pricing breakdown, and decision guide.
22 min readTechnical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Open-source AI pair programming in your terminal. Works with any LLM - Claude, GPT, Gemini, local models. Git-aware ed...
View ToolHigh-performance code editor built in Rust with native AI integration. Sub-millisecond input latency. Built-in assistant...
View ToolUnified API for 200+ models. One API key, one billing dashboard. OpenAI, Anthropic, Google, Meta, Mistral, and more. Aut...
View ToolAnthropic's smallest Claude 4.5 model. Near-frontier coding performance at one-third the cost of Sonnet 4 and up to 4-5x...
View ToolEvery coding agent in one window. Stop alt-tabbing between Claude, Codex, and Cursor.
View AppBeat the August 2026 Assistants API sunset. Paste old code, get Responses API.
View AppRoute prompts to the right model based on cost, latency, and priority rules.
View AppInstall Ollama and LM Studio, pull your first model, and run AI locally for coding, chat, and automation - with zero cloud dependency.
Getting StartedClickable PR link in the footer with review state color coding.
Claude CodeUse opus, sonnet, haiku, and best to switch models easily.
Claude Code
The video reviews OpenAI’s newly released GPT 5.4, highlighting access tiers (GPT 5.4 Thinking in ChatGPT Plus/Teams/Pro/Enterprise and GPT 5.4 in the $200/month tier) and API availability. It covers

Use OpenAI's O1, GPT-4o, Anthropic Claude Sonnet, Claude Haiku, Gemini Flash, Gemini Pro, Perplexity and More for Optimizing AI Model Selection for Price, Speed, and Quality in AI Applications...

In this video, I'll show you how to set up internet-enabled responses from LLMs using Serper, Firecrawl with dynamic model routing. We'll utilize a model router called Not Diamond to dynamically...

Same-day-verified llm api pricing july 2026: Claude Fable 5, GPT-5.6 Sol/Terra/Luna, Claude Sonnet 5, Gemini 3.5 Flash,...

Complete pricing breakdown for every major AI coding tool. Claude Code, Cursor, Copilot, Windsurf, Codex, Augment, and m...

Claude Opus 5 launched July 24, 2026 at $5/$25 per MTok - matching Opus 4.8 pricing while delivering near-Fable 5 intell...

A verified directory of the frontier AI models in July 2026 - Claude Fable 5, Opus 5, GPT-5.6 Sol/Terra/Luna, Sonnet 5,...

A practical guide to choosing GPT-5.6 Sol, Terra, and Luna, using programmatic tool calling, caching, and the multi-agen...

Claude Code parallel agents cost real money because every session draws from one quota - here is the July 2026 budgeting...

New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.