Context Budget
Before selecting a model, the router checks whether the conversation fits in the model’s context window. Models that can’t fit the conversation are automatically excluded.context_tokens is not provided, TokenSense estimates it from message content using a 4-chars-per-token approximation. Pass the exact count if you have it:
Per-Call Overrides
Override routing behaviour on a per-call basis.| Override | Type | Description |
|---|---|---|
task_hint | string | Label passed to if_task rule conditions |
max_cost_usd | float | Hard cost ceiling — expensive tiers excluded |
min_tier | string | Minimum tier — never route below this |
context_tokens | int | Exact token count — skips estimation |
Routing Decision
router.route() always returns a RoutingDecision object.
CallEvent as routed_tier, so your output captures which tier was used for each call.
on_failure
Controls what happens when a model call fails.Routing Decision
router.route() always returns a RoutingDecision object.
CallEvent as routed_tier, so your output captures which tier was used for each call.
