Skip to main content
This guide creates a router with no provider credentials. The local executor makes the example runnable while showing the same API used by a real executor.

Install

The package is ESM and requires Node.js 22.19 or later, or Bun.

Create server.ts

Run it:
On Node.js rather than Bun, replace Bun.serve with your web framework’s handler adapter and run node server.ts — the router.fetch is a standard Request-to-Response handler.

Send a request

The response is OpenAI Chat Completions-shaped. The selected model is also reported in dari_routing and X-Router-Selected-Model. The caller’s model value names your router; it does not force a candidate with that ID. The same handler accepts POST /v1/messages for Anthropic Messages. Add stream: true to either request to receive that protocol’s SSE stream.

Use real models next

Replace the local executor with createPiRuntime, or keep your own transport and read Custom Executors. Then choose a more capable policy from Policies.