fetch handler. You declare models, provide a policy that chooses among eligible candidates, and provide executors that call those models.
models, policy, and executor are the three things you supply; models is a list of candidate declarations, executor is the adapter that calls them, and the Quickstart shows all three together for a complete minimal server.
router.fetch accepts OpenAI Chat Completions and Anthropic Messages requests and returns the matching response format. The framework does not host your credentials, persist your conversations, or choose a provider for you.
The three decisions you make
Models are candidate declarations. They describe an ID, reasoning levels, provider metadata, and capabilities such as images, tools, structured output, and streaming. Policies choose one eligible model. A policy can be a local function, a service you own, the self-hosted deterministic policy from/policy-engine, or Dari’s hosted Auto Router.
Executors run the selected model. The package includes createPiRuntime(), which calls models through the Pi model catalog with your credentials; you can also connect any SDK with a RouterExecutor.
Framework or managed router?
Use this package when your application should own the HTTP endpoint, provider credentials, execution, and operations. Use the Dari Managed Router when Dari should host those concerns.Public package boundaries
The root package is the end-to-end framework:@mupt-ai/dari-router/protocols. Most applications should start with createRouter and never need either subpath.
Pre-1.0 APIs may change. Do not build compatibility wrappers around removed options such as
createRouter({ runtime: ... }); the generic router uses executor.Quickstart
Run a local router in a few minutes.
Models
Declare Pi or custom candidates.
Policies
Choose a routing strategy.
Operations
Handle leases, hooks, and fallback.