jev-model-router (lucianfialho)
Python library that classifies each request with Jev and ranks OpenRouter's live full catalog to pick the cheapest capable model.
Overview
This jev-model-router is a Python library for cost-optimised routing on OpenRouter. Unlike routers with a hand-picked list of models in config, it reads OpenRouter's live full catalog (hundreds of models, cached with a short TTL) on each decision. Jev never sees the model list; it only classifies the request, and a deterministic scoring function ranks the catalog against that classification.
The flow is: filter the catalog by hard constraints such as vision, minimum context and maximum price (pure code, so impossible constraints never waste a call); make one Jev call with five narrow questions about domain, complexity, long-context need, vision need and latency sensitivity; then rank candidates by blended price targeted to a price percentile derived from complexity. If Jev fails, it falls back to cheapest-first ranking without fabricating a classification, configurable as fail-open or fail-closed. It can also route and complete in one call.
What the decision model decides
| Type | Question | Answers |
|---|---|---|
| Choice | domain: what kind of request is this (for example code)? | — |
| Score | complexity: how complex is this request (0-2)? | — |
| Yes / no | needs_long_context / needs_vision / latency_sensitive | yes · no |
How it works
- Fetch and filter the live OpenRouter catalog by hard constraints
- One Jev call answers five questions about the prompt
- Code ranks remaining models by price targeted to complexity
- Return a RoutingDecision, or complete the request directly
Strengths
- Picks up new OpenRouter models automatically
- Library, not a proxy; no server to run
- Deterministic ranking and explicit fallback on failure
Caveats
- Requires both TypeSafe and OpenRouter keys
- Quality is inferred from price percentiles, not measured per model
Getting started
pip install -e ".[dev]", export TYPESAFE_API_KEY and OPENROUTER_API_KEY, then from model_router import Router and call router.choose_model(...)At a glance
- Type
- Project
- Status
- beta
- Language
- Python
- Runtime
- Library
- Has code
- yes
- License
- MIT
Use cases and integrations
How curated lists describe it
Cost-optimized OpenRouter model router using TypeSafe's Jev, with a live full-catalog scorer instead of a hardcoded model list
logicrw/awesome-jev-projectsCost-optimized OpenRouter model router using TypeSafe's Jev, with a live full-catalog scorer instead of a hardcoded model list.
hellogumbo/awesome-jev
Frequently asked questions
Does Jev pick the model directly?
No. Jev only classifies the request; a deterministic scorer ranks the live catalog.
What if Jev is down?
It falls back to cheapest-first ranking, or fails closed if configured.
Do I have to maintain a model list?
No. It reads OpenRouter's live catalog.
Related projects
Local-first routing engine for long-running agent tasks that uses a Jev decider to pick a model group per turn.
PluginproductionRust, TypeScriptOpen-source AI gateway for 100+ LLMs that can use Jev to classify requests for complexity routing and to compact tool results.
ProxyproductionPythonOpen-source workspace for running and reviewing AI coding agents across devices, with an optional Jev-based automatic model router.
ProjectproductionTypeScript- jev-router★ 593
Per-turn model routing for Claude Code and Codex: wraps the real CLI and lets Jev send simple turns to fast models and hard ones to strong.
ProxybetaJavaScript - jev-codex-router★ 274
Per-call router for Codex where Jev picks the model and thinking effort for every model call, including tool continuations.
ProjectbetaPython Model router where Jev classifies each request's task family and code picks the cheapest capable model on a cost Pareto chain.
ProjectbetaTypeScript