Write A Policy
A policy receives the normalized request, eligible candidates, and an abort signal:reasoningEffort is optional — omitting it applies the candidate’s default. The field is reasoningEffort in TypeScript, reasoning_effort in JSON, and thinking_level in Dari custom rules.
Inspect Without Executing
Callrouter.select() to see a decision without making a provider call:
anthropicRequest(payload) provides the equivalent normalization for Anthropic Messages.
Dari’s Selector Policy
createDariRoutingPolicy() uses a separate LLM call (the selector) to choose the route. Its answer is validated before execution.
selectorModel doesn’t need to be a routed candidate. selectorContextWindowChars is a character budget for the selector prompt, not a token count.
Optional callbacks add evidence to the choice:
pricing— model and cache ratesevals— benchmark scorecardsstate— observed provider-cache prefixesmetadata— richer model capabilities
Custom Rules Strategy
Usestrategy: "custom" to give the selector natural-language rules:
when text against the request. Its answer must name an eligible pair or Router Core returns a policy error.