{"slug": "show-hn-gremlord-run-claude-code-on-any-model-with-a-budget", "title": "Show HN: Gremlord – Run Claude Code on any model, with a budget", "summary": "Gremlord, a new open-source tool announced on Hacker News, wraps Anthropic's Claude Code in a local router that lets users run the coding assistant on any model—including OpenAI, xAI, Ollama, vLLM, and OpenRouter—while metering every token and enforcing user-set budgets. The tool adds a SQLite-based cost log, per-turn model selection via a cheap classifier, and session-to-session messaging, addressing Claude Code's single-provider limitation and lack of cost visibility.", "body_md": "\n\n```\n                    \\    /\\  /\\  /\\    /\n                     \\  /  \\/  \\/  \\  /\n                  .-' \\/ ()  ()  () \\/ '-.\n                .-'   [================]   '-.\n       ,.      /    .-'~~~~~~~~~~~~~~~'-.    \\      .,\n      /  \\    /   .'   .-----.   .-----.   '.  \\   /  \\\n     /  /\\\\  |   /    / .---. \\ / .---. \\    \\  |  //\\  \\\n    /  /  \\\\ |  |    | ( (o) )-=-( (o) ) |    |  | //  \\  \\\n   /  /    \\\\|  '-'   \\ '---' / \\ '---' /   '-'  |//    \\  \\\n  /  /      \\\\_________'-----'   '-----'_________//      \\  \\\n |  /        \\\\  ~zzt~    \\   ___   /    ~zzt~  //        \\  |\n | /          \\\\      /    \\ /   \\ /    \\      //          \\ |\n |/            \\\\    |   .--'\\/\\/\\/'--.   |    //            \\|\n '              \\\\    \\   \\ /\\/\\/\\/\\ /   /    //              '\n                 \\\\    '-._'-.___.-'_.-'    //\n                  \\\\___.-'   '-...-'   '-.___//\n                       ===[ >-o-< ]===\n                    /  |               |  \\\n                  .'  /|   /\\      /\\   |\\  '.\n                 /  .' |  (  )    (  )  | '.  \\\n               _/  /   |   ~~      ~~   |   \\  \\_\n              (__)/    '=======[]======='    \\(__)\n                  \\      / /      \\ \\      /\n                   \\____/ /        \\ \\____/\n                    (_o_)/          \\(_o_)\n██████╗ ██████╗ ███████╗███╗   ███╗██╗      ██████╗ ██████╗ ██████╗\n  ██╔════╝ ██╔══██╗██╔════╝████╗ ████║██║     ██╔═══██╗██╔══██╗██╔══██╗\n  ██║  ███╗██████╔╝█████╗  ██╔████╔██║██║     ██║   ██║██████╔╝██║  ██║\n  ██║   ██║██╔══██╗██╔══╝  ██║╚██╔╝██║██║     ██║   ██║██╔══██╗██║  ██║\n  ╚██████╔╝██║  ██║███████╗██║ ╚═╝ ██║███████╗╚██████╔╝██║  ██║██████╔╝\n   ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═╝     ╚═╝╚══════╝ ╚═════╝ ╚═╝  ╚═╝╚═════╝\n```\n\nit’s smart. it’s in the wires. it’s already in prod.\n\n# Run Claude Code on any model, with a budget.\n\ngremlord wraps Claude Code in a thin local router. Same TUI, same tools, same auto-updates — Anthropic runs byte-faithful passthrough, while OpenAI, xAI, and any OpenAI-compatible endpoint (Ollama, vLLM, OpenRouter) work through full request/stream translation. Every token is metered, priced, and checked against a budget you set. A cheap classifier picks the model for each turn, filtered by which models can actually hold the request; a second, independent pass flags tasks that want a recurring loop instead of a single reply. And now, sessions find and message each other by name.\n\n```\ncurl -fsSL\n                https://raw.githubusercontent.com/gremlord/gremlord/main/install.sh\n                | sh\n```\n[README →](https://github.com/gremlord/gremlord)\n\n## What Claude Code alone doesn't do.\n\nIt's a great harness and it keeps getting better — forking it means losing that. But it only talks to one provider, and it never tells you what a session cost.\n\n### Two dialects, every provider\n\n                Anthropic runs byte-faithful passthrough. Everything else —\n                OpenAI, xAI, Ollama, vLLM, OpenRouter, a local llama.cpp\n                server — works through the same request/stream translation.\n                Model names are aliases you define in\n                `config.yaml`.\n              \n\n### Every token priced\n\n                A local SQLite log prices every request as it happens.\n                `gremlord cost --by model` breaks spend down by\n                model, profile, or session.\n              \n\n### Budgets that actually stop you\n\nDaily, weekly, monthly caps, global or per profile. Hit one and the router refuses the next request with a clear message in the TUI — in-flight responses are never cut.\n\n### Two classifiers watch every turn\n\n`--model auto` sends planning to a big model and\n                mechanical edits to a cheap one, sticky for the whole turn.\n                The same classifier call can also name a task specialist —\n                see [task routing](#tasks) below. A second,\n                independent pass, Auto Goal, flags tasks that need a\n                recurring check-in — a flaky test, a long build — and\n                nudges Claude Code toward `ScheduleWakeup` or\n                `/loop` instead of a single reply.\n              \n\n### Context scaling per model\n\n                Claude Code sizes auto-compact for a ~200K Claude window.\n                Declare a model's real `context_window` (and an\n                `effective_context` below it, if the model gets\n                unreliable early) and the router scales every token count it\n                reports, so a 32K local model and a 400K one both compact at\n                the right moment — never against a window they don't have.\n              \n\n### Size-aware routing, before it fails\n\nThe auto-router checks a request's size against each candidate model's window before picking one, so a large prompt skips tiers that can't hold it instead of overflowing one that can't. Anything still too large for every configured model gets refused with a clear error, before it reaches a provider.\n\n### Subagents on any model\n\n                Claude Code's Agent tool is normally pinned to\n                `sonnet | opus | haiku | fable`.\n                `gremlord agents sync` writes one subagent\n                definition per configured model alias, so a routed model\n                becomes selectable by name —\n                `subagent_type: \"gremlord-qwen\"` — and its traffic\n                is priced and budgeted like anything else.\n              \n\n### No daemon, no fork\n\nThe first session binds the router port; when it exits, another running session takes over in seconds. Claude Code stays unmodified and keeps auto-updating on its own.\n\n### Profiles you switch on the fly\n\n                Bundle a main model, a fast background model, and a budget\n                into a profile. `-p cheap` for one session,\n                `--model grok` for one request.\n              \n\n### No wrapper in the launch path\n\n                Claude Code sessions now find and message each other\n                natively, so gremlord dropped its own launch wrapper —\n                `claude` starts directly, one less subprocess and\n                PTY hop between you and the TUI.\n              \n\n## Find the other session by the name you'd actually say.\n\n            Claude Code sessions can message each other natively now — but\n            session names are auto-derived from whatever a session is doing,\n            so the name you'd say out loud is usually the project directory,\n            not the name it registered under. `gremlord peers`\n            matches on both, reads Claude Code's own session registry, and\n            hands back the exact session to send to. Ties are surfaced as\n            ties: messaging the wrong project is worse than a question.\n          \n\n```\n# \"the labs-service one\" — matched on name and cwd\n❯ gremlord peers labs-service-secondlife-be\nBest match for \"labs-service-secondlife-be\":\n  daily-case-runtime    busy  ~/code/secondlife/labs-service    started 12h ago\n```\n\n`gremlord setup` writes this workflow into\n            `~/.claude/CLAUDE.md`, so plain `claude`\n            sessions pick it up too. Sessions on a Claude Code build older\n            than 2.1.224 don't register a peer socket and stay unreachable\n            until restarted.\n          \n\n## The gauge tracks the model, not the label.\n\n            Claude Code sizes auto-compact for the ~200K window it assumes.\n            gremlord scales every token count it reports so a 32K local model\n            and a 400K one both compact at the moment that's actually right\n            for them — and a request too large for anything you've\n            configured is refused before it reaches a provider, not after.\n            See it in motion in the hero above; `gremlord context`\n            below shows the same numbers as plain text.\n          \n\n```\n# same session, two models configured\n❯ gremlord context sess_4f21\nmodel        window   effective   used     reported   compact-at\nqwen-32k     32K      28K         27,940   99.8%      ✓ compacted\nsonnet       200K     200K        27,940   14.0%      —\n```\n\n## Three ways to get Claude Code off one provider.\n\ngremlord isn't the only answer to \"I want Claude Code but not locked to Anthropic.\" Here's how the options actually differ.\n\n|  | gremlord | claude-code-router · proxy forks · LiteLLM | OpenCode, Crush, Goose, Aider | \n|---|---|---|---|\n| Harness | Real Claude Code, unmodified, auto-updating | Real Claude Code, unmodified | Different harness entirely — own prompts, tools, TUI | \n| Runs as | Static Go binary, no daemon (leader election over a fixed port) | Daemon / server process you deploy and administer | Standalone CLI you run instead of Claude Code | \n| Cost & budgets | First-class CLI: `gremlord cost` , live                     statusline, hard-stop daily / weekly / monthly budgets | Usually a dashboard (LiteLLM) or not built in | Varies by tool, rarely budget-gated | \n| Model routing | Aliases + a built-in LLM-classifier tier router                     ( `auto` ), size-aware and sticky per turn,                     with optional per-task specialist overrides | Rule-based routing configs; no classifier-based tiering | Manual model switch, no auto-routing | \n| Memory | Composes with [clauder](https://github.com/MaorBril/clauder) — separate binary, optional | Not their concern | Varies | \n| Multi-session | `gremlord peers` resolves a session by name or                     project directory | Not their concern | Varies | \n\n            gremlord doesn't try to be a better harness than Claude Code — it\n            keeps Claude Code exactly as Anthropic ships it and only swaps\n            what's behind `ANTHROPIC_BASE_URL`. Want a different\n            agent loop entirely? OpenCode, Crush, Goose, and Aider are the\n            right layer to look at. Want a gateway you deploy and administer\n            for a team? LiteLLM is more mature for that. Choosing between\n            gremlord and\n            [claude-code-router](/compare/claude-code-router/)?\n            There's a longer, honest comparison. gremlord is for one developer\n            who wants `claude`, unmodified, with a budget and a\n            cheap-model escape hatch — installed in one command, with nothing\n            to operate.\n          \n\n## A gateway, plus the CLI around it.\n\n            Claude Code already supports pointing at a gateway via\n            `ANTHROPIC_BASE_URL`. gremlord is that gateway — it\n            never touches Claude Code's source.\n          \n\n#### Install\n\n                    One command drops the binary in\n                    `~/.local/bin`. `gremlord setup`\n                    writes a config, registers the statusline, and offers to\n                    install anything missing.\n                  \n\n#### Run `gremlord`\n\n                    It starts the local router, points Claude Code at it via\n                    `ANTHROPIC_BASE_URL`, and hands you the exact\n                    same TUI you already know.\n                  \n\n#### The router does the rest\n\nResolves the model alias, translates the dialect if needed, logs priced usage, checks the budget — then streams the response straight back.\n\n```\n# default profile, tracked\n❯ gremlord\n\n# same session, cheaper models\n❯ gremlord -p cheap\n\n# one-off model override\n❯ gremlord --model grok\n\n# where did today's $4.31 go?\n❯ gremlord cost --by model\nopus     $2.87\nsonnet   $1.12\nqwen     $0.32\n```\n\n## Same tier, different specialist.\n\n            Tiering alone can't say that ordinary implementation work and\n            architecture review need comparable capability but do better on\n            different models. An optional `tasks:` map adds that\n            second dimension on top of tiering, from a fixed label set:\n            `implementation`, `sql_data`,\n            `debugging`, `code_review`,\n            `architecture`, `security_review`,\n            `critical_review`. The classifier's one call per turn\n            returns both the tier and, if configured, the task — no extra\n            classifier request, just a fraction of a cent depending on\n            classifier and prompt.\n          \n\n```\n# tier router, plus specialists for two labels\n❯ gremlord routing set auto --classifier haiku \\\n    --deep opus --standard sonnet --light qwen \\\n    --task implementation=grok --task security_review=fable\n\n# later calls merge into this rule; --task label= removes one\n❯ gremlord routing list\nALIAS  CLASSIFIER  DEEP  STANDARD  LIGHT  TASKS\nauto   haiku       opus  sonnet    qwen   implementation=grok, security_review=fable\n\n# tier and model disagree — the task override is what moved it\n❯ grep autoroute ~/.gremlord/router.log\n... tier=standard model=grok  reason=task:implementation\n... tier=deep     model=fable reason=task:security_review\n```\n\n            A task label only wins if its model fits the request's context\n            and size budget; otherwise the request stays on the classified\n            tier's own model. The label set is fixed, not customizable, and\n            this is a model-selection hint, not a security boundary —\n            naming `security_review` picks a model, it doesn't\n            enforce a review policy. Pinned sessions\n            (`pin_tiers` / `X-Gremlord-Pin-Model`)\n            bypass task routing the same way they bypass tiering.\n          \n\n## New · experimental Paired model evals, blinded\n\n`gremlord eval` runs a baseline model and a candidate\n            on the same coding tasks, each in its own isolated workspace, and\n            records the route and usage for both. An optional judge compares\n            the resulting patches without seeing which one is which. It's\n            new, still rough at the edges, and meant for your own coding\n            tasks or a pinned SWE-bench manifest — not yet a general\n            leaderboard tool.\n          \n\n## Plain Claude Code vs. gremlord\n\n|  | Plain Claude Code | gremlord | \n|---|---|---|\n| Same TUI, tools, auto-updates | yes | yes | \n| Non-Anthropic models | — | OpenAI, xAI, any OpenAI-compatible endpoint | \n| Per-session cost tracking | — | priced & logged | \n| Spend budgets & caps | — | day / week / month | \n| Per-task model routing | — | classifier-driven | \n| Requires forking Claude Code | n/a | never | \n\n## Fine print\n\n## How is this billed?\n\n                Traffic through the router is billed to your\n                **API keys**, not your Claude Pro/Max\n                subscription. OAuth credentials are never proxied. For\n                subscription billing, use a `passthrough: true`\n                profile — normal claude, no tracking.\n              \n\n## Do the non-Anthropic models feel as good?\n\nThey work through translation, but Claude Code's prompts and tool patterns are tuned for Claude, so expect them to be clunkier in the main loop. They're better used as cheap workhorses for background tasks and subagents. Translation keeps getting more reliable — tool-call IDs from translated models are sanitized so malformed ones don't corrupt a turn, and a turn that reasoned on a translated model no longer breaks the next turn on a native Anthropic one: unsigned thinking blocks are repaired before replay instead of retry-looping as \"Tool use interrupted.\"\n\n## What's experimental right now?\n\n`gremlord eval` — paired baseline-vs-candidate\n                coding runs with an optional blinded judge. It works and\n                produces real artifacts, including a documented one-task\n                SWE-bench comparison, but it's new, the interface can still\n                change, and one task is a smoke test, not a model ranking.\n              \n\n## Is Claude Code modified?\n\n                No. gremlord launches the unmodified, auto-updating\n                `claude` binary and points it at the local router\n                via `ANTHROPIC_BASE_URL` — an officially supported\n                gateway hook.\n              \n\n## Is it secure?\n\n                The router binds `127.0.0.1` only and requires a\n                per-install token (mode 0600), so other local processes can't\n                spend on your keys. Keys live in `~/.gremlord/env`,\n                never in the config file.\n              \n\n## What does gremlord itself cost?\n\nNothing — it's MIT-licensed. You pay your model providers for the tokens you use, which is exactly what gremlord measures and caps.\n\n## One command to a tracked session.\n\n```\ncurl -fsSL\n                https://raw.githubusercontent.com/gremlord/gremlord/main/install.sh\n                | sh\n```\n[GitHub →](https://github.com/gremlord/gremlord)", "url": "https://wpnews.pro/news/show-hn-gremlord-run-claude-code-on-any-model-with-a-budget", "canonical_source": "https://gremlord.com/", "published_at": "2026-09-08 12:47:40+00:00", "updated_at": "2026-09-08 12:58:47.783013+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "large-language-models", "ai-infrastructure"], "entities": ["Gremlord", "Claude Code", "Anthropic", "OpenAI", "xAI", "Ollama", "vLLM", "OpenRouter"], "alternates": {"html": "https://wpnews.pro/news/show-hn-gremlord-run-claude-code-on-any-model-with-a-budget", "markdown": "https://wpnews.pro/news/show-hn-gremlord-run-claude-code-on-any-model-with-a-budget.md", "text": "https://wpnews.pro/news/show-hn-gremlord-run-claude-code-on-any-model-with-a-budget.txt", "jsonld": "https://wpnews.pro/news/show-hn-gremlord-run-claude-code-on-any-model-with-a-budget.jsonld"}}