58 lines
1.8 KiB
Markdown
58 lines
1.8 KiB
Markdown
# Cascade Routing: Cut Your API Costs by 66%
|
|
|
|
**June 11, 2026**
|
|
|
|
Most teams use one model for everything. They default to Claude Opus or GPT-5 for every task, which means they are paying premium prices for simple work.
|
|
|
|
## The Price Range
|
|
|
|
| Model | Input ($/M) | Output ($/M) |
|
|
|-------|-------------|----------|
|
|
| Gemini 2.5 Flash | $0.15 | $0.60 |
|
|
| DeepSeek V3 | $0.27 | $1.10 |
|
|
| Claude Sonnet 4 | $3.00 | $15.00 |
|
|
| Claude Opus 4 | $15.00 | $75.00 |
|
|
|
|
That is a 100x range between the cheapest and most expensive.
|
|
|
|
## The Cascade Pattern
|
|
|
|
Route different steps to different models. Use cheap models for simple retrieval and formatting. Use expensive models only for complex reasoning.
|
|
|
|
```
|
|
Retrieve context -> Gemini Flash ($0.15/$0.60)
|
|
Analyze data -> Claude Sonnet ($3/$15)
|
|
Make decision -> Claude Opus ($15/$75)
|
|
Format output -> Gemini Flash ($0.15/$0.60)
|
|
```
|
|
|
|
## The Savings
|
|
|
|
| Pattern | Cost/Task | Savings |
|
|
|---------|-----------|--------|
|
|
| All Opus | $2.50 | Baseline |
|
|
| Cascade | $0.85 | 66% |
|
|
| All Sonnet | $0.50 | 80% (but quality loss on complex steps) |
|
|
|
|
## Implementation
|
|
|
|
```python
|
|
def route_task(task_complexity: str) -> str:
|
|
if task_complexity == "retrieval":
|
|
return "gemini-2.5-flash"
|
|
elif task_complexity == "analysis":
|
|
return "claude-sonnet-4"
|
|
elif task_complexity == "decision":
|
|
return "claude-opus-4"
|
|
elif task_complexity == "formatting":
|
|
return "gemini-2.5-flash"
|
|
```
|
|
|
|
## When Not to Cascade
|
|
|
|
If your task is a single critical decision, use the best model. Cascade routing shines when you have a pipeline of steps with varying complexity, which is most real-world agent systems.
|
|
|
|
---
|
|
|
|
*From Module 6 of the [Agentic Engineering Course](/). The full module includes a cost optimization lab with working code.*
|