Research · Millwright

The self-hosted LLM router that cuts inference cost, not quality.

Route Anthropic Messages and OpenAI Chat Completions to the model your policy allows: frontier where the work needs it, approved lower-cost models for the rest. Millwright decides from explicit policy, not prompt inspection, and records the reason for every route.

License
Apache-2.0
Runtime
One Rust binary
Deployment
Self-hosted
API surfaces
Messages + Chat Completions
Analyze

Find the expensive workloads and model the savings.

Every estimate includes its coverage, price source and assumptions. Candidate costs are modeled, not realized savings. Quality remains unverified until you test.

millwright analyze
$ millwright analyze ./logs
MEASURED SPEND billed · from your logs
retries · failovers · aborts
SUBSTITUTION CANDIDATES modeled · not yet replayed
quality stays UNVERIFIED
→ evaluate before changing policy
Route

Route only within model sets you’ve approved.

Assign requests to cheap, mid or frontier roles, then list the models each role may use. Millwright reuses a confirmed affinity route when it remains valid and otherwise selects the lowest-estimated-cost healthy model the resolved role permits.

millwright route
role: mid
approved: Claude Sonnet · GLM-4.6 · Qwen3-Coder · DeepSeek-V3
routed → glm-4.6
reason: approved for mid role · affinity valid
rejected
runtime prompt classifier
prompt inspection for routing
models outside your approved role
Integrate

Change the endpoint, not the developer workflow.

Keep compatible Anthropic Messages and OpenAI Chat Completions clients, including supported streaming and tool use. Route them to native Anthropic, AWS Bedrock or approved OpenAI-compatible endpoints.

client.py
# before
base_url = "https://api.anthropic.com"
# after: point at Millwright
base_url = "http://localhost:8080"
Agents

Drop into Claude Code and Codex.

Millwright speaks the APIs your agents already use. Point Claude Code at the Messages surface or Codex at Chat Completions, and the model picker you already use becomes the tier switch.

~/.codex/config.toml
model = "millwright-code" # main work → mid
base_url = "http://localhost:8080/v1"
# Claude Code: millwright-fast # background → cheap
# switch tiers with X-Millwright-Task-Type and X-Millwright-Risk
Evidence

A policy-approved route, role-scoped affinity, and evidence you can inspect.

Each response exposes the chosen model, provider, trace ID and route reason. Configured storage retains detailed traces and cost evidence for completed inference calls.

illustrative trace API record
trace summarization
model deepseek-v3
alternative considered
attempts 1
latency · cost recorded
Performance

Built for concurrent traffic.

No classifier in the hot path.

Millwright routes from explicit task and risk metadata, model aliases and your policy. It doesn’t make a second model call to decide where the first one should go.

Streaming remains streaming.

Supported upstream streams are forwarded incrementally instead of being buffered into a complete response first.

Concurrent sessions stay concurrent.

Role-scoped affinity keeps separate cheap, mid and frontier lanes under one session ID without a per-session lock.

We don’t promise a savings number. Millwright shows its work.