Per-window model switcher, subagent router, and automatic 429 failover for Claude Code — switch any window from the /provider panel, route subagents to any provider, and keep working when quota runs out.
Switch any Claude Code window to another model from an interactive panel, route subagents to any provider, and automatically fail over when Claude hits a usage limit—all on localhost, with Remote Control and statuslines intact.
Claude Code binds model settings globally across every terminal window. model-relay runs a lightweight router on localhost (127.0.0.1:8950) so each window and subagent can use the model you want—with zero external cloud proxies.
When…
Without model-relay
With model-relay
You want to switch just one window to another model
Editing settings.json switches every open terminal at once
Type /provider to switch only the current window from the panel above your prompt (and write its active model to model-relay-status/<session id> for your statusline)
You want haiku or a specific subagent on another model
Changing global env vars forces your main Opus/Sonnet chat onto that endpoint too
/provider alias haiku <name> offloads haiku globally, or model-relay:<name> spawns a one-off subagent on that provider with all tools intact
Claude hits a 5-hour usage limit (HTTP 429) or a provider hiccups
Your turn fails mid-task until quota resets
Automatic retries and failover.chain hand the request to your backup provider and pin only that window while new windows return to Claude after cooldown
You use Remote Control (claude.ai/code) from your phone or browser
Custom ANTHROPIC_BASE_URL blocks Remote Control from connecting
Local HTTPS proxy mode (/provider rc on) keeps Remote Control working while routing each window independently
Third-party gateways lose history/tools or reject ToolSearch / cache_control
message-threads deltas cause mid-chat amnesia, and ToolSearch hides tools or triggers HTTP 400
Automatically sends full conversations keeps ToolSearch working, and cleans cache_control per provider on the fly
Who this is for
model-relay is built for Claude Code users who combine a Claude subscription with backup or specialized endpoints (z.ai, DeepSeek, Kimi, MiniMax, OpenRouter, or a gateway on your own machine). Each provider has to accept Anthropic's /v1/messages format; a service that only speaks OpenAI Chat Completions needs a local translator (see Limitations). If you need a multi-tenant cloud proxy for an entire organization, use LiteLLM instead—model-relay is a single-user localhost daemon.
Install
Requires Node.js 20+ and Claude Code 2.1.287 or later (tested on Node.js 22.23.2 and Claude Code 2.1.306).
⚠️ Upgrading from 0.6 or earlier? Updating the plugin alone is not enough. Version 0.7+ reads only "format": 2 in ~/.claude/model-relay.json. Until you migrate your config and restart the router, an old 0.6 router still running in the background keeps running 0.6 code (without 0.7's conversation/tool loss fix or localhost security check), and once that process stops, the plugin will not start a new router until you migrate. Run /provider setup upgrade my model-relay config and Claude does it with you, or follow UPGRADING.md by hand (node tools/setup.mjs migrate, then migrate --go, then /provider restart).
claude plugin marketplace add cablate/model-relay
claude plugin install model-relay@model-relay