Skip to main content
A policy receives the normalized request and the candidates that survived capability filtering. It returns a model ID and may choose a reasoning effort.

A local policy

Policies may be synchronous or asynchronous. Router Core validates the returned model and reasoning effort. Omit reasoningEffort to use the candidate’s default. The TypeScript field is reasoningEffort; wire JSON uses reasoning_effort.

Inspect or serve a selection

router.evaluatePolicy(request) is stateless: it runs the policy without reading or writing leases and without firing hooks. Use it for previews, logs, or tests. router.select(request) is the authoritative serving primitive. It reads an existing lease, applies a new lease returned by the policy, and fires onSelection. router.fetch() uses the same semantics.

Self-hosted selector policy

The advanced createDariRoutingPolicy uses a selector model (an LLM that answers routing questions) and the deterministic policy engine to assemble evidence, ask the selector, and validate its answer. It is public from /policy-engine because it is more opinionated than the core policy interface.
selector is the only place the selector model is called. It is an option of createDariRoutingPolicy, not of createRouter. For self-hosted createDariRoutingPolicy, provide your own pricing and observed output-token averages. Router Core does not ship or infer them. Cache state and model metadata remain optional; unknown cache state means the engine makes no cache-savings claim. evals also accepts a callback, so a large benchmark pool can be filtered per request. selectRelevantEvals asks TypeSafe’s Jev one yes/no question per card (does this benchmark measure the kind of work the agent is doing?) and keeps the cards whose relevance probability exceeds JEV_EVAL_RELEVANCE_THRESHOLD (0.3). This is the same filter the Managed Router applies.

Custom rules

Custom rules restrict the candidates to the rule and default targets, and the selector request is the same one every router uses with a short rules section appended to its system prompt. The selector must return an eligible model and effort. For a fully local deterministic policy, write a RoutingPolicy directly; for full preparation/finalization control, use the advanced policy engine.