promptdojo_
Checkpoint

One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.

Final drill. The pattern Perplexity and Cursor built into their products from day one: routing logic that picks the cheapest model that meets a quality floor under a monthly budget cap.

Build pick_model(constraint) that takes a constraint dict:

  • max_cost_per_month: float — the budget cap in dollars per user per month
  • quality_floor: str — one of "haiku", "sonnet", "opus" (the model must be at LEAST this good)

And returns one of: "haiku", "sonnet", "opus", or "none" if no model meets both the floor AND the budget.

Quality ranking (low to high): haiku < sonnet < opus. A quality_floor of "sonnet" means sonnet or opus qualifies; haiku does not. Among models that meet the floor, pick the cheapest one that stays under budget.

Use this fixed usage profile (don't change it):

  • 20 messages/day
  • 500 avg input tokens, 200 avg output tokens
  • 30 days/month
  • prices: haiku $1/$5, sonnet $3/$15, opus $5/$25 per 1M tokens

Five constraints run for you. Expected output:

tight budget, haiku floor:   haiku
mid budget, sonnet floor:    sonnet
big budget, opus floor:      opus
tight budget, sonnet floor:  none
big budget, haiku floor:     haiku

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.

open this same url on a laptop to keep going today.