Jev model router

September 20, 2026 · View on GitHub

A small web chat where Jev, TypeSafe's decision model, picks which LLM should answer each message. The chosen model then replies. Both calls go through the Vercel AI Gateway with one key.

Inspired by Riley Brown's video Jev: the model that can't write, where he builds the same router in one prompt. This repo is that idea, built and documented step by step with Claude Code.

What it looks like

A greeting routed to nano, then a design question routed to balanced

A build request routed to balanced with 19% on frontier

How it works

  1. The page posts your message to POST /chat.
  2. server.mjs sends one Choice question to typesafe-ai/jev with four options: nano, fast, balanced, frontier. Each option has a one-line rubric.
  3. Jev returns a probability for every tier and a confidence.
  4. The server calls the chosen model with generateText and returns the reply, the probabilities, and both timings.
TierModelInput $/MOutput $/M
nanoopenai/gpt-5-nano0.050.40
fastgoogle/gemini-3-flash0.503.00
balancedanthropic/claude-sonnet-52.0010.00
frontieranthropic/claude-fable-5.110.0050.00

Change the tiers or the question in the TIERS and TIER_QUESTION blocks at the top of server.mjs.

Run it

Needs Node 20.6 or later and a Vercel AI Gateway key on the paid tier. The free tier limits Jev to a few calls and refuses most reply models.

npm install
echo AI_GATEWAY_API_KEY=your_key > .env
node server.mjs --check                  # free offline server check
node --env-file=.env server.mjs           # http://localhost:3000

npm test runs offline checks and the held-out routing cases without spending API credits. npm run eval:live evaluates the same cases with Jev and writes one JSON object per case to eval/results-live.jsonl; it does not call any reply model. For the browser flow, start node server.mjs --offline, then run python tests/browser.py in another terminal.

probe.mjs sends one raw Jev call and prints the full response body.

Cost

One Jev decision: about 340 input tokens at $0.042 per million, about $0.000014. The reply costs whatever the chosen tier costs.