← 返回
AI产品发布/更新#LLM路由器#Northwood Systems#Rust#自托管

Millwright:基于 Rust 的自托管 LLM 路由器

Hacker News 热门(Algolia · 中文化)T2
03:0307/23 03:03HN 编译阅读原文 ↗导出 MD ↓

评分

69
信息增量7 ×0.3

提供了一种新型自托管路由方案,对多模型管理场景有明确信息增量。

内容质量7 ×0.2

项目文档和架构描述清晰,但尚未经过大规模生产验证。

实用价值8 ×0.2

对需要成本控制和隐私保护的团队有直接实用价值,开源且易于集成。

时效性9 ×0.15

发布于 Hacker News 热门当日,与当前 LLM 部署痛点高度契合。

信源可信度8 ×0.15

来自 Hacker News 热门话题,GitHub 项目内容公开可查,可信度较高。

基础分 76.5 × T2 信源权重 ×0.9 = 69

精选线 70未达精选线

精选理由

该项目解决了多个模型后端切换的实际痛点,开源实现具有较高参考价值。

AI 点评

「如果你正在为多个 LLM API 的编排和成本发愁,Millwright 的确定性路由方案值得一试。Rust 实现和自托管特性让它特别适合对延迟和安全有苛刻要求的团队。」

速览

Millwright 是一个用 Rust 编写的自托管 LLM 路由器,主打成本可控、确定性路由和高性能。它默认安全私密,支持多模型负载均衡与 fallback,适合需要本地化部署、低延迟和高可靠性的 AI 应用场景。项目已在 GitHub 开源,可灵活集成到现有推理后端。

  • 基于 Rust 开发,性能高且内存安全
  • 支持自托管,默认安全私密
  • 提供确定性路由与成本控制机制
  • 支持多模型 fallback 与负载均衡

正文

Millwright

Millwright

The self-hosted LLM router for policy, cache affinity, and spend control in one Rust Binary.

Release v0.1.0 Apache-2.0 license CI status Rust 1.97 Linux and macOS

What is Millwright

Millwright is an open-source, self hosted LLM router that runs between your AI applications and the model providers you choose. It accepts OpenAI Chat Completions and Anthropic Messages, then routes each request to an OpenAI-compatible API, Anthropic, or Amazon Bedrock.

You define which models belong in the cheap, mid, and frontier roles. Millwright selects the lowest estimated-cost healthy route the resolved role permits and, when given a session ID, preserves provider/model affinity for prompt-cache reuse.

Millwright is a router, not an agent orchestrator. It does not spawn agents, schedule work, inspect prompts, or rewrite context.

Why Millwright

LLM costs rise quickly when every request reaches the most expensive model and provider changes break prompt-cache reuse. Millwright makes the lower-cost path explicit:

  • Control model spend — reserve frontier models for the work your policy says needs them.
  • Protect prompt caches — role-scoped affinity keeps each session on a confirmed provider and model while its cache window is warm.
  • Keep concurrent agents moving — one session can maintain independent cheap, mid, and frontier lanes without serializing requests.
  • Change providers without changing application code — route compatible traffic across providers behind one endpoint.
  • Keep routing inspectable — response headers identify the chosen route; traces and ledger entries retain the evidence when persistence is available.
  • Run the data plane yourself — provider credentials stay on your infrastructure, with no required hosted control plane.

Get Started

Quick Start

Rust 1.97+ is required when building from source.

git clone https://github.com/Northwood-Systems/millwright.git
cd millwright
cargo install --path . --locked
millwright init
millwright serve

millwright init walks through provider endpoints, model roles, pricing, and separate workload and operator keys. It stores references to provider-secret environment variables, never the provider credentials themselves.

Connect Claude Code, Codex, OpenCode, Pi, or another compatible client. Choose millwright-fast, millwright-code, or millwright-plan to request the cheap, mid, or frontier role.

Optional Local Demo

The included Docker Compose setup starts Millwright with a mock provider and local demo key:

make compose-up

From another terminal:

curl http://localhost:8080/v1/chat/completions \
  -H 'Authorization: Bearer sk-millwright-local-demo' \
  -H 'Content-Type: application/json' \
  -d '{"model":"millwright-fast","messages":[{"role":"user","content":"Hello from Millwright"}]}'

Architecture · Router API · Policy & Catalog · Deployment · Cost Analysis · Security

Features

Policy-controlled routing

Classify requests with explicit task and risk headers, the client's model selection, or documented defaults. Millwright resolves a cheap, mid, or frontier role, then selects the lowest estimated-cost healthy model that policy allows. High-risk and planning requests always use the frontier role.

Every decision includes the chosen model, provider, route reason, and rejected alternatives. Message content is never inspected to make the decision.

Cache-aware concurrency

Naive per-request routing can erase provider prompt-cache savings by switching models mid-session. Millwright keeps independent cheap, mid, and frontier affinity lanes under one opaque session ID, each with its own cache TTL.

Traffic resolved to different roles no longer fights over one warm route. Same-role calls converge on the last confirmed provider/model, while all requests remain concurrent—Millwright does not serialize agent traffic or orchestrate agent lifecycles.

See where the spend goes

Completed requests normally write usage evidence, cost provenance, provider attempts, and routing evidence to the ledger. SQLite is the local default; PostgreSQL is available for production deployments.

Command What it shows
millwright spend Total spend, cache read rate, and per-team breakdown
millwright models Model and provider mix
millwright trace <id> One routing decision, including rejected alternatives
millwright top Live spend and model activity in the terminal

The same data is available through the authenticated /v1/millwright/* management APIs, with JSON output from spend, models, and trace for dashboards and automation.

Analyze cost opportunities

millwright analyze reads a live Millwright ledger or local Millwright, OpenAI-compatible, or Anthropic JSONL. It produces a self-contained HTML or Markdown report plus schema-versioned JSON.

millwright analyze \
  --url http://127.0.0.1:8080 \
  --key "$MILLWRIGHT_OPERATOR_KEY" \
  --since 30d \
  --report analysis.html \
  --json-out analysis.json

Reports separate measured cost evidence from modeled candidate economics. Add an explicit catalog and candidate allowlist to compare full-swap costs and a price-floor economic scenario. Candidate results are cost hypotheses—not quality results or production routing recommendations. See Cost Analysis.

Provider and protocol support

OpenAI Chat Completions and Anthropic Messages come in; OpenAI-compatible APIs, native Anthropic, and Amazon Bedrock go out. Same-protocol routes preserve fields Millwright does not model. Cross-protocol routes translate the supported text-and-tools subset and reject unsupported shapes instead of silently dropping data.

Retryable transport failures, timeouts, HTTP 408/429, and HTTP 5xx responses can trigger one bounded failover attempt. Circuit breakers stop unhealthy routes from receiving every request.

Built for self-hosting

Millwright ships as one Rust binary with Docker and Docker Compose support. Provider credentials remain in environment variables, while separate workload and operator keys control inference and management access. Structured logs omit API keys and prompt payloads; request bodies, concurrency, timeouts, and upstream buffers are bounded.

Enterprise

Need help deploying Millwright inside your infrastructure, integrating a provider, or designing a routing policy for your workload?

Talk to the founder

Contributing

Bug fixes, features, tests, and documentation improvements are welcome. Read CONTRIBUTING.md before opening a pull request.

Quick Start for Contributors

The Rust toolchain is pinned in rust-toolchain.toml.

git clone https://github.com/Northwood-Systems/millwright.git
cd millwright
make build
make test

Code Quality / Linting

Before opening a pull request, run:

make fmt
make lint
make test
make audit

The checks cover Rustfmt, Clippy with warnings denied, all Rust test targets, dependency advisories, approved licenses, and dependency sources. make audit requires cargo-deny. CI also builds the release binary and Docker image.

License

Apache-2.0

相关条目

92

五维评分

信息增量8 ×0.3

首次系统介绍 OpenRouter 缓存与路由协同策略,信息增量较高。

内容质量9 ×0.2

官方教程,结构清晰,包含原理、示例和实测效果。

实用价值10 ×0.2

直接明确降低 API 成本,开发者可立即应用。

时效性10 ×0.15

刚刚发布,且对当前 Agent 开发热潮具有及时指导意义。

信源可信度10 ×0.15

来源为 OpenRouter 官方 RSS 和官网,信源权威可靠。

基础分 92 × T1 信源权重 ×1 = 92

精选线 60已入选精选

08:00OpenRouter:Announcements(RSS)T1RSS

精选OpenRouter 推出提示缓存与粘性路由,大幅降低多轮对话成本

对于高频调用 AI API 的开发者,这个功能堪称直接省钱利器。粘性路由保证了缓存命中率,配合 session_id 零配置接入,值得所有使用 OpenRouter 的团队立即尝试。

AI产品#OpenRouter#会话ID#成本优化
91

五维评分

信息增量9 ×0.3

首次公开ChatGPT Work的Agent能力,信息增量高。

内容质量8 ×0.2

官方发布,内容清晰,但细节较少。

实用价值9 ×0.2

为用户提供可直接使用的Agent能力,实用价值高。

时效性10 ×0.15

刚刚发布,时效性极强。

信源可信度10 ×0.15

来自OpenAI官方,信源权威可靠。

基础分 91 × T1 信源权重 ×1 = 91

精选线 60已入选精选

18:00OpenAI:News(RSS)T1RSS

精选ChatGPT Work:可在跨应用和文件中执行操作的AI Agent

我认为这是AI助手从问答走向执行的关键一步。对需要自动化复杂工作流的专业人士尤其值得关注。ChatGPT Work可能成为生产力工具的新范式。

AI产品#Agent#AI 生产力#ChatGPT Work
90

五维评分

信息增量9 ×0.3

首次公开前沿实验室代理入侵的完整技术时间线,信息增量极高。

内容质量8 ×0.2

结构严谨、技术细节丰富,但缺乏部分原始日志数据佐证。

实用价值9 ×0.2

提供了缓解建议和自检工具,对AI安全从业者具有直接指导意义。

时效性10 ×0.15

事件发生仅数月后即发布分析,时效性极佳。

信源可信度9 ×0.15

Hugging Face 作为顶级开源AI平台,其技术博客可信度极高。

基础分 89.5 × T1 信源权重 ×1 = 90

精选线 60已入选精选

08:00Hugging Face:Blog(RSS)T1RSS

精选前沿实验室代理入侵事件技术时间线:2026年7月事件剖析

这篇技术时间线值得所有AI安全研究员和代理开发者细读——它不只是描述一次攻击,而是为整个行业敲响了代理系统防御体系薄弱的警钟。对正在部署自主代理的团队来说,这是必读的灾难预防手册。

科技产品#AI代理安全#Hugging Face#入侵时间线
90

五维评分

信息增量8 ×0.3

文章揭示了工具增强反而导致AI性能下降的反直觉发现,并提供了具体工程改进方案,信息增量高。

内容质量9 ×0.2

来自GitHub官方工程博客,有数据支撑(成本下降40%),论证清晰,质量上乘。

实用价值9 ×0.2

对AI产品团队、代码审查工具开发者、以及依赖AI辅助编程的团队有直接借鉴意义。

时效性10 ×0.15

2024年发布的工程实践,符合当前AI产品优化趋势,时效性强。

信源可信度10 ×0.15

信源为GitHub官方博客,具有高度权威性和技术可信度。

基础分 90 × T1 信源权重 ×1 = 90

精选线 60已入选精选

23:57GitHub Blog(网页)T1网页

精选更好的工具反而让Copilot代码审查更糟?GitHub这样改进

这篇博客值得所有AI产品工程师和ML从业者仔细阅读——它打破了'更强大的工具=更好的AI'的直觉,转而强调与Agent推理模式匹配的工程哲学。对正在优化代码审查或类似Agent产品的团队尤其重要。

AI产品#Agent工作流#Copilot#GitHub
88

五维评分

信息增量9 ×0.3

披露了OpenRouter产品的新能力,对关注多模态开发的用户有较高信息增量。

内容质量8 ×0.2

内容清晰,准确描述了API功能与优势,但缺少性能数据对比。

实用价值9 ×0.2

直接解决多模态API碎片化问题,开发者可立即降低集成成本。

时效性10 ×0.15

该API为新近发布,具有很高时效性。

信源可信度8 ×0.15

OpenRouter官方博客,权威性高,但未提及其他第三方验证。

基础分 88 × T1 信源权重 ×1 = 88

精选线 60已入选精选

08:00OpenRouter:Announcements(RSS)T1RSS

精选OpenRouter 推出统一多模态 API:单端点支持图像、视频、音频、嵌入与转录

这条消息值得所有做多模态AI应用的开发者关注:OpenRouter用联合API解决了模型切换的痛点,特别适合初创团队或快速原型开发。如果你正被多个API密钥和SDK折磨,这个接口可能是你需要的统一层。

AI产品#OpenRouter#多模态API#模型集成
87

五维评分

信息增量8 ×0.3

介绍了全新的教育产品,填补了AI安全公司在教育垂直领域的空白,信息增量较高。

内容质量8 ×0.2

内容简洁清晰,准确概括产品功能、安全理念和试点情况,无冗余信息。

实用价值9 ×0.2

直接解决教师备课负担痛点,且强调安全合规,对教育工作者具有实际参考价值。

时效性10 ×0.15

消息发布时间接近当前日期,属于最新产品发布动态。

信源可信度9 ×0.15

来源为Anthropic官方新闻页面,权威性高,内容可靠。

基础分 86.5 × T1 信源权重 ×1 = 87

精选线 60已入选精选

23:40Anthropic:News(网页)T1网页

精选Anthropic 推出 Claude for Teachers:面向教师的教育 AI 工具

这条消息对教育工作者和AI行业观察者都很有价值。Anthropic没有选择通用聊天机器人,而是专门为教师设计了安全可控的工具,这显示出AI在垂直场景落地的正确思路——不是技术炫技,而是切实解决用户痛点。同时,产品内置的安全护栏也值得其他AI公司参考,尤其是在面向儿童或青少年的场景中。

AI产品#AI安全#Anthropic#Claude
86

五维评分

信息增量9 ×0.3

全新路由机制,市场智慧概念为行业带来较高信息增量。

内容质量8 ×0.2

官方公告内容清晰,但技术细节不足,略有扣分。

实用价值8 ×0.2

对开发者选型有直接实用价值,可降低试错成本。

时效性9 ×0.15

产品刚发布,时效性极强。

信源可信度9 ×0.15

来自OpenRouter官方RSS公告,信源可靠。

基础分 86 × T1 信源权重 ×1 = 86

精选线 60已入选精选

08:00OpenRouter:Announcements(RSS)T1RSS

精选OpenRouter发布全新Auto Router:用市场智慧优化模型路由

这条更新值得所有用API开发AI应用的人关注。以前选模型靠经验和测试,现在市场数据帮你选。虽然细节不多,但方向很对。对依赖聚合模型服务的团队尤其重要。

AI产品#Auto Router#OpenRouter#市场智慧
86

五维评分

信息增量8 ×0.3

包含大量具体修复细节和安全改进,信息密度高。

内容质量9 ×0.2

内容详尽,结构清晰,覆盖新功能、修复、改进多个方面。

实用价值9 ×0.2

修复了多个实际开发中遇到的问题,对用户有直接帮助。

时效性10 ×0.15

刚刚发布的版本,时效性极强。

信源可信度10 ×0.15

来自 Anthropic 官方 GitHub Release,信源权威可靠。

基础分 90 × T1.5 信源权重 ×0.95 = 86

精选线 65已入选精选

07:02Claude Code:GitHub Releases(RSS)T1.5GitHub Release

精选Claude Code v2.1.211 发布:多项修复与改进

作为一个经常使用 Claude Code 进行自动化编码的开发者,我特别关注这次的安全修复,尤其是权限预览字符绕过和自动模式覆盖钩子决策的问题——这些直接关系到团队协作时的安全边界。后台代理报告的改进也让长时间运行的任务更可靠。建议所有使用者尽快升级。

AI产品#Anthropic#Claude Code#代码生成工具

引用前请核对原文