Lesson 28 of 46 ~20 min
Course progress
0%

Model Selection Decision Framework

Build a systematic decision framework for choosing between Opus, Sonnet, and Haiku — balancing cost, quality, speed, and task requirements.

Choosing the right model is not a technical decision — it is an economic one. This lesson gives you a decision framework that optimizes for total cost of ownership, not just API cost.

The True Cost Equation

Most people only consider API cost. The real equation is:

Total Cost = API Cost + Human Review Cost + Error Cost + Opportunity Cost
  • API Cost: Token pricing (Opus is ~1.7× Sonnet, ~20× Haiku)
  • Human Review Cost: Time spent checking and fixing AI output
  • Error Cost: Production bugs, security incidents, data corruption
  • Opportunity Cost: Slower development velocity from using a weaker model

For critical tasks, Opus 4.6 is often the cheapest option because it minimizes human review and error costs.

Decision Matrix

graph TD
    A[New Task] --> B{Correctness<br/>Critical?}
    B -->|Yes| C{Budget<br/>Constrained?}
    B -->|No| D{Volume<br/>>100/day?}
    C -->|No| E[Opus 4.6]
    C -->|Yes| F[Opus 4.6 with<br/>cost controls]
    D -->|Yes| G[Haiku]
    D -->|No| H{Complexity?}
    H -->|Simple| G
    H -->|Medium| I[Sonnet 4.5]
    H -->|Complex| E

Task-to-Model Mapping

Task CategoryModelReasoning
Security auditOpus 4.6Error cost is catastrophic
Architecture designOpus 4.6Requires deep multi-step reasoning
Code review (critical)Opus 4.6Must catch subtle bugs
Code review (routine)Sonnet 4.5Good enough for style and basic issues
Bug fixing (complex)Opus 4.6Better at root cause analysis
Bug fixing (simple)Sonnet 4.5Cost-effective for straightforward fixes
DocumentationSonnet 4.5Quality sufficient, lower cost
Code completionSonnet 4.5Speed matters more than depth
Log parsingHaikuHigh volume, pattern matching
Data extractionHaikuStructured, repetitive tasks
Customer support triageHaikuSimple classification

Building an Automated Model Router

from dataclasses import dataclass
from enum import Enum

class ModelTier(Enum):
    OPUS = "claude-opus-4-6-20260205"
    SONNET = "claude-sonnet-4-5-20241022"
    HAIKU = "claude-haiku-3-5-20241022"

@dataclass
class TaskProfile:
    correctness_critical: bool
    complexity: str  # "low", "medium", "high"
    volume: str      # "single", "batch", "stream"
    domain: str      # "security", "coding", "content", "data"

def route_to_model(task: TaskProfile) -> ModelTier:
    """Route tasks to the appropriate model tier."""
    # Security and architecture always get Opus
    if task.domain in ("security", "architecture"):
        return ModelTier.OPUS

    # Critical correctness gets Opus
    if task.correctness_critical and task.complexity != "low":
        return ModelTier.OPUS

    # High volume simple tasks get Haiku
    if task.volume == "stream" and task.complexity == "low":
        return ModelTier.HAIKU

    # Everything else gets Sonnet
    if task.complexity == "high":
        return ModelTier.OPUS

    return ModelTier.SONNET

Cost Projection Example

A team of 5 engineers using Claude daily:

ScenarioOpus OnlySmart RoutingSavings
500 requests/day$125/day$45/day64%
Monthly cost$3,750$1,350$2,400/month

Smart routing sends ~20% of tasks to Opus, ~50% to Sonnet, ~30% to Haiku — without sacrificing quality where it matters.

In the next lesson, we cover the breaking API changes when migrating from Opus 4.5.