Show HN: Foreman, a self-hosted LLM gateway for cost aware model routing Foreman, a self-hosted LLM gateway, routes requests to the cheapest model allowed by user-defined policies while maintaining deterministic behavior and prompt cache efficiency. The open-source tool supports multiple providers, tracks spending, and requires no code changes to switch models, aiming to reduce costs without sacrificing output quality. 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. 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 https://github.com/Northwood-Systems/foreman/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 /Northwood-Systems/foreman/blob/main/docs/clients.md . Every response carries X-Foreman-Trace-ID , X-Foreman-Model , X-Foreman-Provider , and X-Foreman-Route-Reason headers; foreman trace