Skip to content

About

Lightweight model routing for agents, with OpenAI and Anthropic API compatibility, automatic model selection, and a management CLI.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

Jev Model Router

English | Chinese

A lightweight, open-source model router for AI agents. Keep your OpenAI Chat Completions or Anthropic Messages client, choose a model explicitly, or use auto for automatic model selection on each request.

Why Jev

  • One endpoint for Agent clients. Use familiar OpenAI and Anthropic client entry points while Jev handles configured OpenAI-compatible and native Anthropic generation upstreams within the compatibility matrix.
  • Routing policy you can read and edit. Describe each model's strengths, weaknesses, cost, and speed in natural language, then tune the shared routing prompt instead of hard-coding selection rules in every Agent.
  • Evidence you can inspect. Compare frozen fixed-model, Jev, and Semantic Router snapshots, including costs, limitations, and offline reproduction scripts.

Learn how Agent model routing works, when per-request selection helps, and when a fixed model is the better choice.

The latest release runs as a single Go service with SQLite, streams text and tool calls, and includes a management CLI and bilingual dashboard. Local Laya, sensitive-session locking, ArbiterOS and PostgreSQL remain planned.

Client and upstream support

Client entry point OpenAI-compatible upstream Native Anthropic upstream
/v1/chat/completions JSON / SSE JSON / SSE, including supported thinking and tool continuations
/v1/messages JSON / SSE through conversion JSON / SSE with native preservation

Support is limited to the fields and combinations in the compatibility matrix. Unsupported conversions fail explicitly. BigModel glm-5.3 and glm-5.3-flash passed 12 original Agent SDK examples through the local Router; see the compatibility and validation scope. This does not establish compatibility with every Anthropic deployment or native signed thinking history.

Benchmark results

Seven strategies replay the same Qwen3.8-Max / Flash answers. Score columns show tasks passed and generation cost (CNY), excluding routing overhead.

Strategy Code (128 tasks) Non-code (96 tasks) Median decision latency: RTX 4090 / 4-core CPU (ms)
Jev Model Router (cloud Jev) 91 · 7.5988 86 · 0.5026 —
Semantic Router 85 · 6.5021 85 · 0.3110 —
Jev Model Router (Laya) 88 · 6.1811 84 · 0.2764 31.0 / 225.4
Jev Model Router (Decider 2B) 88 · 6.4732 88 · 0.7316 29.6 / 2,172.1
Jev Model Router (D3 nano) 87 · 8.3495 85 · 0.3746 28.3 / 2,248.9
Fixed Max 88 · 8.7390 88 · 0.9874 —
Fixed Flash 85 · 0.9988 84 · 0.1811 —

Local latency uses eight tasks run serially after warmup. See the full report for routing counts, P95, historical cloud latency on a different sample, and reproduction steps.

Quick Start

The recommended path is the Docker Compose Quick Start. It pulls the prebuilt image, persists SQLite, and includes the management UI; no local Go or Node installation is needed.

For Agent

Install the jev-router skill from this repository's skills/jev-router directory using your skill installer (repository: https://github.com/zerone-agents/jev-model-router, path: skills/jev-router). Alternatively, clone the repository and register that directory with your agent's local skill loader. Keep the checkout available: the skill references its deployment and configuration docs.

Load jev-router to deploy Jev Model Router with Docker Compose, configure providers, models and automatic routing, and verify connectivity. The skill includes the deployment steps and CLI configuration workflow.

Local CLI

To manage a remote Compose instance, download the CLI from GitHub Releases. See CLI installation and remote access.

Run from source

Requires Go 1.27.0. The SQLite driver does not require CGO.

go build -o /tmp/jev-router ./cmd/jev-router
# Securely inject distinct JEV_ROUTER_SETTINGS_TOKEN / JEV_ROUTER_INFERENCE_TOKEN values
/tmp/jev-router serve

The default listener is 127.0.0.1:8080, and the database is .data/router.sqlite. Use serve --config conf.json and environment overrides as described in startup configuration. Two distinct credentials must be available at startup.

If Jev is useful for your Agent, consider starring the repository to follow releases and help other developers discover it.

Management UI

/tmp/jev-router serve
# In another terminal
/tmp/jev-router dashboard
# Headless environment: print the address without probing or opening a browser
/tmp/jev-router dashboard --no-open

The UI is served at /dashboard/ by the same Go binary. Use dashboard --url https://router.example.com for a remote instance. This command never starts the server or passes credentials to the browser. Enter the Settings credential once to establish a 7-day HttpOnly session; refresh and same-credential restart retain login. Logout revokes the current session. Remote browser access requires HTTPS and JEV_ROUTER_DASHBOARD_ORIGIN; see session configuration.

The English/Chinese UI shows instance status, models, the routing prompt and routing records. It edits model descriptions and the prompt through the existing management API, preserving version conflicts and explicit same-key retries. Configure providers, model mappings and capabilities through the CLI. See UI development and boundaries.

Agent configuration workflow

/tmp/jev-router --help
/tmp/jev-router schema
/tmp/jev-router schema providers.put
/tmp/jev-router call status.get --json /tmp/empty-object.json
/tmp/jev-router call providers.put --json /tmp/provider.json --expected-version 1 --idempotency-key setup-provider-1

The contents of empty-object.json are {}. A complete provider configuration example (inject PROVIDER_API_KEY first):

{"id":"cloud","protocol":"openai","base_url":"https://api.openai.com/v1","secret_ref":"env:PROVIDER_API_KEY"}

Configure a disabled model using schema models.put, run the fixed connection test with call models.test --id <ID>, read the current version and enable the model, then check routing with route.inspect. Automatic routing with multiple candidates also requires decision.put to configure the Jev root URL, native model version, and secret reference. Use prompt.put to edit the single default balanced template. Supply complex inputs through JSON files or stdin; all writes include a version and an idempotency key. See the companion SKILL for the complete workflow.

Use /v1/models to discover enabled public model IDs. The settings credential is only for management and fixed tests; generation uses the inference credential.

Call the inference API

OpenAI clients use http://127.0.0.1:8080/v1 as their base URL. Anthropic SDK clients use the root http://127.0.0.1:8080; the SDK appends /v1/messages. Both use the inference credential and auto or an enabled public model ID.

curl http://127.0.0.1:8080/v1/chat/completions \
  -H "Authorization: Bearer $JEV_ROUTER_INFERENCE_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"model":"auto","messages":[{"role":"user","content":"Hello"}],"max_tokens":1024}'

curl http://127.0.0.1:8080/v1/messages \
  -H "x-api-key: $JEV_ROUTER_INFERENCE_TOKEN" \
  -H 'anthropic-version: 2023-06-01' \
  -H 'Content-Type: application/json' \
  -d '{"model":"auto","messages":[{"role":"user","content":"Hello"}],"max_tokens":1024}'

Add "stream":true for SSE. Messages supports configured OpenAI-compatible and native Anthropic upstreams within the documented field and model-profile boundaries. See the Anthropic SDK example, native Messages compatibility, and native upstream configuration.

Routing behavior

  • No candidates means failure; a single candidate is selected directly; multiple candidates invoke Jev on every request. Explicit model selection skips Jev.
  • Preferences live primarily in prompts and natural-language model cards. Code enforces authorization, capability, capacity, and protocol boundaries.
  • auto is a reserved ID. Generation requests are not truncated and parameters are not silently dropped. SDK retries remain disabled; explicit requests never switch models, while Auto may reselect once before semantic output after an eligible generation failure.
  • Jev mode provides no sensitive-data routing guarantee. Conversation text may go to Jev. Image data, tool definitions, tool arguments and tool outputs are excluded; paired tool IDs and names remain.
  • Configuration writes affect new requests immediately. Disabling a model does not revoke snapshots already in use.
  • Records retain routing metadata and up to 120 characters from the latest user message. Default retention is seven days or 100,000 records, whichever limit is reached first. Writes are best effort and degraded status is exposed; these records are not audit logs.

See the compatibility matrix for supported fields and estimation limits, and the evaluation guide for measuring real-world quality and cost.

Architecture

flowchart TD
    Agent[Agent model client] --> API[Chat Completions / Messages JSON / SSE]
    Skill[Companion SKILL] --> CLI[Go CLI]
    CLI --> Admin[Management HTTP / schema]
    Admin --> Management[Shared management service]
    Management --> SQLite[SQLite configuration / versions / idempotency / records]
    Management -->|route.inspect| Planner[Routing planner]
    API --> Planner
    SQLite -->|Configuration snapshot| Planner
    Planner -->|Multiple candidates in auto mode| Jev[Jev native choice]
    Planner --> Executor[Single-target execution]
    Executor --> Bifrost[Bifrost Core]
    Bifrost --> Models[OpenAI-compatible / native Anthropic upstreams]
    API -->|Best-effort writes| SQLite
Loading

Directory structure

.
├── cmd/          # Executable entry points
├── internal/     # Routing, management, storage, and protocol adapters
├── contracts/    # Machine-readable contracts and validation
├── templates/    # Single balanced prompt
├── skills/       # Agent workflows
├── tests/        # Black-box end-to-end tests
├── evals/        # Explicitly invoked paid evaluation tooling and synthetic data
├── services/     # Future local Laya service
├── web/          # Embedded bilingual management UI
└── docs/         # Architecture, configuration, compatibility, and contributor conventions

Development checks

CI runs tests and lint in parallel. Lint uses a pinned version of golangci-lint with govet, staticcheck, and unused enabled, and checks gofmt for product code and locally patched dependency files. The unchanged Bifrost source snapshot is kept byte-identical to upstream; see dependency maintenance.

go install github.com/golangci/golangci-lint/v2/cmd/[email protected]
golangci-lint run ./...
# Expect no output; use gofmt -w on any files listed
git ls-files -z '*.go' ':!:third_party/bifrost-core/**' | xargs -0 gofmt -l
gofmt -l third_party/bifrost-core/providers/utils/{utils,proxy_context,proxy_config_failure_test,proxy_tls_close_test,proxy_connect_test}.go
python3 scripts/verify-bifrost-snapshot.py
(cd third_party/bifrost-core && go test -race ./providers/utils -count=1)
go test ./... -count=1
go test -race ./... -count=1
go vet ./...

Default tests access local mock endpoints. Optional SDK tests require a local SDK installation; explicitly enabled live acceptance tests call paid upstreams and can execute example tools. See validation scope. Start with the architecture, management contract, and domain terminology. Local research, implementation specifications, ADRs and per-run acceptance records are excluded from Git by convention.

About

Lightweight model routing for agents, with OpenAI and Anthropic API compatibility, automatic model selection, and a management CLI.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages