> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dari.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Jev Router

> Route with TypeSafe's Jev System One model instead of Dari's trained routing policy.

`createJevRouter()` is a routing policy backed by [TypeSafe's Jev](https://docs.typesafe.ai/introduction). Jev is a System One model: it does not generate text. Each selection sends the conversation and candidate evidence as Jev `state` and asks two typed Choice questions — which candidate serves the next turns, and how many turns to lease — and reads the answers back as calibrated probabilities. No prompt parsing, no JSON coercion.

<Note>You need a TypeSafe API key. Selection is billed by TypeSafe per input token (output tokens are free). Your executors still make provider calls and your provider credentials stay in your application.</Note>

## Setup

```ts theme={null}
import { createJevRouter, createPiRuntime, createRouter } from "@mupt-ai/dari-router";

const pi = await createPiRuntime({
  apiKey: ({ provider }) => {
    const key = process.env[`${provider.toUpperCase()}_API_KEY`];
    if (!key) throw new Error(`Missing ${provider.toUpperCase()}_API_KEY`);
    return key;
  },
});

const router = createRouter({
  models: [
    pi.model("openai/gpt-5.6-sol"),
    pi.model("anthropic/claude-sonnet-5"),
  ],
  policy: createJevRouter({
    apiKey: process.env.TYPESAFE_API_KEY!,
    pricing: (model) => pricing[model] ?? null,
    averageOutputTokensByModel,
  }),
  executor: pi,
});
```

`createJevRouter` uses the deterministic policy engine for candidate eligibility, cache-aware cost estimates, and benchmark evidence, so `pricing` and `averageOutputTokensByModel` are required exactly as they are for [`createDariRoutingPolicy`](/framework/policies). Custom rules are not supported; Jev serves only the default routing policy.

## What Jev sees

Candidates are de-identified through the same anonymous-action protocol as Dari's trained policy: each candidate is an action letter, stable for the whole conversation, and no model identity ever reaches TypeSafe. The state is the retained task, the previous action, the lease history, and the (image-scrubbed) conversation. Each action is one option in the `action` question, described only by its projected loop cost at each lease length with a cost rank across actions, and its benchmark scores and ranks. Comparisons Jev is weak at — cost ordering and benchmark standing — are computed in this package and passed as text.

The `lease` question offers the same turn commitments as Dari (`5`, `10`, `30` by default). The chosen lease becomes `leaseTurnsRemaining` on the decision, so `createRouter` holds the pair for that many turns without calling Jev again. Pass `leaseTurns: []` to route one turn at a time.

## Reading the answers

`router.select()` and the `onSelection` hook expose the raw Jev answers through `policyDetails.selectorOutput`, a JSON document with the decision and a `jev` field carrying `model`, both answers with their probability distributions and confidence, and token usage. Use the probabilities to gate on confidence in your own code, for example by only honoring long leases when the lease answer is confident.

## Configuration

```ts theme={null}
createJevRouter({
  apiKey: process.env.TYPESAFE_API_KEY!,
  endpoint: "https://api.typesafe.ai/v1",
  model: "jev-latest",
  leaseTurns: [5, 10, 30],
  timeoutMs: 30_000,
  pricing,
  averageOutputTokensByModel,
  evals: benchmarkEvals,
});
```

`createJevSelector` under `/policy-engine` returns the same selection as a `Selector` for [`createDariRoutingPolicy`](/framework/policies) when you want to combine Jev with your own state or eval sources. `buildJevSelectorRequest` and `parseJevSelectorResponse` are exported for inspection and tests.
