惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
罗磊的独立博客
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
A
About on SuperTechFans
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
IT之家
IT之家
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
爱范儿
爱范儿
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
T
Tailwind CSS Blog
The Cloudflare Blog
Hugging Face - Blog
Hugging Face - Blog

Hacker News

Probed — Talk to Your People HN Work A Visualization Language for the AI Era NoCrap — Neuroscience-Based Recovery Pods GitHub - weirdGuy/kastor: Declarative language and toolchain for AI agents: define agents, tools and prompts in HCL, then compile to frameworks or manage them on hosted platforms with plan/apply semantics. Abralo - Run multiple Claude Code agents in one window GitHub - mehranzand/repofleet: RepoFleet is an issue-centered CLI tool for managing Git workflows across multiple repositories. GitHub - exmergo/dex: Dex is the agent-native analytics engineering toolkit. Point it at your warehouse and your dbt project. It learns the landscape, authors your transformations, and tells you exactly what to fix when the schema drifts. Built for analytics engineers and data engineers who want more out of their coding agent. Pug — Open Source Product Analytics GitHub - instavm/tarit: A hypervisor and sandbox cloud for self-hosted AI agents and RL Chiptune Radio — Aleph Void, LLC Free Mermaid Live Editor & Diagram Maker GitHub - Salnika/dejavu: Stop showing coding agents the same command output twice. GitHub - hirasso/html-obfuscator: Obfuscate emails, phone numbers, and other sensitive data in PHP. Invisible to humans, hidden from bots until they interact. Davit — a native macOS UI for Apple containers Fenzo AI - The perfect course, every time. HTML Drive — Edit and Publish HTML from Google Drive GitHub - rowboatlabs/rowboat: Open-source AI coworker, with memory ZeroGate | Automated Cluster Scaling A tiny scale-free kernel language — Joa Ebert GitHub - arman-jalili/guardian-framework: Architecture Enforcement Framework for AI-Assisted Development Yamanote.fun PostgreSQL on AWS: Size & Benchmark EC2 Instances GitHub - zqiren/Orbital: the agent that never starts from zero GitHub - Rodiun/frugon: Free, local, open-source LLM cost analyzer — see where your LLM bill leaks, on your machine. Artificiety — A Fantasy World for AI Agents Ex Situ FlexInference: Drop your AI costs today WhimFiles - Find Any File in Seconds GitHub - josephsenior/Grinta-Coding-Agent: Local-first autonomous coding agent that plans, executes, validates, and finishes software tasks end-to-end.
GitHub - Northwood-Systems/foreman: Self-hosted LLM gatew...
AndrewLiu96 · 2026-07-09 · via Hacker News

Foreman

Self-hosted LLM gateway. Cost effective, deterministic, fast. Secure and private by default.

Foreman is a self-hosted LLM gateway: one Go binary between your coding agent and any number of providers. Your keys and traffic stay inside your network. Track every dollar of spend, and switch models or providers from inside your favorite harness with no code changes. Keep frontier models where quality matters and route routine work to cheaper ones. You write the policy, so you cut cost without giving up output quality.

It sends each request to the cheapest model your policy allows, and pins every conversation to its model while the provider's prompt cache is warm, so routing never burns your cache to save pennies. OpenAI and Anthropic surfaces in, any number of providers out, and every decision lands in a ledger you can query for the reason it made and the alternatives it rejected.

Quickstart

Install with Homebrew (macOS):

brew install northwood-systems/tap/foreman

On Linux or from source: go install github.com/Northwood-Systems/foreman/cmd/foreman@latest, a prebuilt archive from Releases, or go build -o bin/foreman ./cmd/foreman (Go 1.26+).

Then run the interactive setup to pick providers, assign cheap/mid/frontier models, and generate a Foreman key (shown once, stored only as a hash):

foreman init    # never asks for a secret: provider keys stay in your env vars,
foreman serve   # referenced as ${VAR} and resolved at startup

Point your coding agent at it. Claude Code, Codex, OpenCode, and Pi setups are in docs/clients.md. Every response carries X-Foreman-Trace-ID, X-Foreman-Model, X-Foreman-Provider, and X-Foreman-Route-Reason headers; foreman trace <id> shows the full decision, including every alternative the router rejected and why.

How routing works

  1. Pick the tier by precedence: policy floors (high risk and planning always get frontier) > explicit X-Foreman-Task-Type/X-Foreman-Risk headers (the precision instrument for harnesses you control) > the model the client asked for, since your agent's native model picker is the tier switch. Foreman advertises foreman-plan / foreman-code / foreman-fast via /v1/models, and also resolves catalog names and upstream model names (a request for claude-sonnet-4-5 lands in whatever tier your catalog gives that model). Unrecognized models fall back to the documented defaults (routine_code/low). Message content is never inspected.
  2. Route within the tier: the router picks the cheapest healthy model the tier allows; a tier is a list, so multiple models across providers compete on price and cover for each other.
  3. Stick while warm: with X-Foreman-Session-ID, a conversation keeps its model/provider while the prompt cache is warm (TTL from the catalog's prompt_cache.ttl_seconds). Explicit signals (switching the model picker, or a task-type header) release a warm route across tiers; unlabeled traffic never thrashes the cache.
  4. Fail over: provider errors trip a circuit breaker (threshold + cooldown + half-open trials) and requests retry on the next allowed route.
  5. Record: every request writes a ledger event (measured tokens, measured cost) and a route trace (reason + rejected alternatives). SQLite by default, Postgres for production.

Passthrough is faithful: tools, images, and parameters Foreman doesn't model are forwarded byte-identical to same-protocol upstreams. For cross-protocol traffic (Anthropic-format clients on OpenAI-compatible providers), the full tool protocol is translated: tool definitions, tool results, and streamed tool calls, so Claude Code can run against Qwen/GLM-class upstreams. Only what cannot translate (images, documents) is refused with an explicit 400, never silently flattened.

Seeing where the money goes

foreman spend            # totals, cache read rate, per-team breakdown
foreman models           # model/provider mix
foreman trace <id>       # one routing decision, fully explained
foreman top              # live view (bubbletea)

Everything the CLI shows comes from GET /v1/foreman/* JSON APIs (spend/summary, spend/top, models/mix, cache/metrics, traces/{id}, ledger/export), so your own dashboards can read the same numbers. --json on any subcommand pipes cleanly.

Foreman never publishes a savings number. It is the instrument that computes yours, from your own ledger: actual_cost_usd is measured usage priced by your catalog (or provider-reported cost), never a backfilled estimate. Send your own traffic, read your own receipt.

Configuration

Two JSON files and environment variables, documented in docs/policy.md:

  • configs/policy.example.json: API keys (SHA-256 hashes), and model roles: which models are cheap/mid/frontier and which task types each role is allowed to handle.
  • configs/models.example.json: the model catalog, with provider, upstream model name, prices per MTok (fresh/cached/output/cache-write), and prompt-cache TTL.
  • Provider credentials via env only: FOREMAN_OPENAI_COMPAT_PROVIDERS=qwen,openai plus FOREMAN_PROVIDER_<ID>_BASE_URL/_API_KEY, FOREMAN_ANTHROPIC_API_KEY for native Anthropic, and FOREMAN_BEDROCK_REGION + AWS credentials for Claude via AWS Bedrock. Knobs: FOREMAN_WARM_ROUTE_TTL, FOREMAN_PROVIDER_FAILURE_THRESHOLD, FOREMAN_PROVIDER_FAILURE_COOLDOWN, FOREMAN_REQUEST_TIMEOUT, FOREMAN_STREAM_TIMEOUT, FOREMAN_MAX_BODY_BYTES, FOREMAN_CONCURRENCY_LIMIT (docs/gateway-api.md has the full list).

Logs are structured JSON with request/trace IDs, route metadata, and team attribution; API keys and prompt payloads are never logged.

Decomposition: a pattern, not a service

Breaking large jobs into small, verifiable subtasks that cheap models execute, escalating only the pieces that fail deterministic verification, is something you build on top of the gateway, in whatever language your harness lives in. The whole pattern is four HTTP calls per subtask: plan with X-Foreman-Task-Type: planning (frontier per policy), execute each piece with a cheap-class task type, verify the output deterministically yourself, and re-send failures with X-Foreman-Task-Type: escalation. Every call goes through the gateway, so policy and spend accounting apply to every subtask, and /v1/foreman/spend/summary gives you the running cost to enforce a budget against. See docs/design.md.

Docs

Design · Gateway API · Policy & Catalog · Client Setup · Deployment

License

Apache-2.0