The model picker — when Sonnet is wrong and Haiku is right — step 8 of 8
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
Final drill. Synthesize the model picker AND its cost into one
function: cost_aware_routing(tasks).
Takes a list of task dicts (same shape as step 7:
kind, volume_per_day, latency_ms_max, criticality).
Returns a dict:
routes: dict mapping each task'skindto the chosen model ("haiku","sonnet", or"opus").total_cost: float, total estimated daily cost across all tasks, rounded to 2 decimal places.
Use the same routing rules from step 7:
volume_per_day >= 10000→"haiku", unlesscriticality == "high"→"sonnet".volume_per_day < 100ANDcriticality == "high"→"opus".- Default →
"sonnet".
Cost math: assume each call averages 1000 tokens. Blended prices per million tokens:
- haiku: $3.00
- sonnet: $9.00
- opus: $15.00
Daily cost for one task = volume_per_day * 1000 * (rate / 1_000_000),
which simplifies to volume_per_day * rate / 1000.
Five tasks run. Expected output:
ticket_tagger -> haiku
support_summary -> sonnet
contract_review -> opus
fraud_alert -> sonnet
architect_review -> opus
total daily cost: $375.09
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
Final drill. Synthesize the model picker AND its cost into one
function: cost_aware_routing(tasks).
Takes a list of task dicts (same shape as step 7:
kind, volume_per_day, latency_ms_max, criticality).
Returns a dict:
routes: dict mapping each task'skindto the chosen model ("haiku","sonnet", or"opus").total_cost: float, total estimated daily cost across all tasks, rounded to 2 decimal places.
Use the same routing rules from step 7:
volume_per_day >= 10000→"haiku", unlesscriticality == "high"→"sonnet".volume_per_day < 100ANDcriticality == "high"→"opus".- Default →
"sonnet".
Cost math: assume each call averages 1000 tokens. Blended prices per million tokens:
- haiku: $3.00
- sonnet: $9.00
- opus: $15.00
Daily cost for one task = volume_per_day * 1000 * (rate / 1_000_000),
which simplifies to volume_per_day * rate / 1000.
Five tasks run. Expected output:
ticket_tagger -> haiku
support_summary -> sonnet
contract_review -> opus
fraud_alert -> sonnet
architect_review -> opus
total daily cost: $375.09
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.