AI Engineering Reference/Models, Selection & Tuning

Choosing & Routing Models

Frontier vs fast vs cheap models, task-based routing, latency/cost budgets, and model upgrade strategy without breaking workflows.

3/5Overview: 30m

Not every task needs the frontier model

Mid-2026 model tiers (representative — check current pricing):

TierExamplesBest forCost ratio
FrontierClaude Opus, GPT-4.1, Gemini 2.5 ProArchitecture, complex reasoning, agent orchestration1× (baseline)
BalancedClaude Sonnet, GPT-4.1-mini, Gemini 2.5 FlashCode generation, review, most daily tasks~0.2–0.3×
Fast/cheapClaude Haiku, GPT-4.1-nano, Gemini Flash-LiteClassification, triage, formatting, simple Q&A~0.05–0.1×

Using Opus for "format this JSON" is like using a senior architect to fix typos. Route by task complexity.

Task-based routing

TaskRecommended tierWhy
Architecture designFrontierHigh reasoning, low frequency
Code implementationBalancedGood enough quality, high frequency
Code review (first pass)BalancedSpeed matters; human does final pass
Triage/classificationFastSimple decision, high volume
Test generationBalancedPattern-following, not reasoning
Agent orchestrationFrontierTool selection quality is critical
Doc summarizationFast/cheapLow stakes, high volume
Customer-facing answersFrontierQuality and safety critical

Routing implementation

Simple (most teams): manual selection in IDE settings or per-request model picker.

Programmatic (production agents):

def route_model(task_type, complexity_score): if task_type in ("architecture", "agent_supervisor"): return "claude-opus-4" if complexity_score > 0.7: return "claude-sonnet-4" return "claude-haiku-3.5"

Classifier-based: fast model classifies task complexity → routes to appropriate tier. Meta, but cost-effective at scale.

Cost optimization without quality loss

StrategySavingsRisk
Route easy tasks to cheap models50–80% on those tasksQuality drop on misclassified tasks
Cache common queries100% on cache hitsStale answers
Reduce context sizeLinear with input tokensMissing context → wrong answers
Batch API requests~50% discountLatency increase
DistillationRun cheap model trained on frontier outputsUpfront training cost

Measure, don't assume. Run your eval suite on the cheap model before switching.

Latency considerations

FactorImpact
Model tierFrontier: 2–10s TTFT; Fast: 0.5–2s
Context lengthLonger input = slower prefill
Output lengthStreaming helps perceived latency
Tool callsEach call adds round-trip
Provider loadTime-of-day variance

For interactive IDE use, time-to-first-token matters more than total generation time. Streaming is non-optional for UX.

Model upgrade strategy

Models change monthly. Your workflow shouldn't break:

  1. Pin model versions in production (claude-sonnet-4-20250514, not claude-sonnet-4-latest)
  2. Re-run eval suite before upgrading
  3. A/B test new model on 10% traffic before full switch
  4. Monitor regression metrics for 48h after upgrade
  5. Keep rollback path — previous model version available for 30 days

Cursor handles model selection in the IDE; for custom agents, you own this lifecycle.

Multi-provider strategy

Avoid single-vendor lock-in for production agents:

ApproachTrade-off
Primary + fallbackRoute to provider B if A is down/slow
Best-of-breedClaude for code, GPT for structured output, Gemini for long context
Abstraction layerLiteLLM, Portkey — unified API, harder to optimize per-provider

For IDE work, use whatever Cursor supports. For production agents, abstract the provider interface.

Interview framing

"I route by task complexity: frontier for architecture and agent orchestration, balanced for code generation, fast for triage and classification. I pin model versions in production, re-run evals before upgrades, and measure cost per task type monthly."

Senior signal: Show a routing matrix with cost estimates. Explain why you wouldn't use the frontier model for CI code review. Mention eval-gated model upgrades.

Further Reading

Hands-On Tasks (Optional)

Practical exercises — prompt drills, local MCP servers, or workflow design on paper. The goal is professional fluency, not model training.

  • Build a model routing matrix for your team

    List 5 task types your team uses AI for. For each, assign: model tier, max tokens, temperature, and estimated cost per call. Identify one task currently over-provisioned.

    20m