Repository navigation
Releases
v0.7.5
A window switched to a provider can call MCP tools that reconnected mid-session again, and an experimental pane can show the picture of the model you are talking to.
Fixed
- When an MCP server reconnects during a session, a window switched to another provider (GLM, DeepSeek, Gemini, GPT…) can now call its tools. Before, those tools were missing for the provider, so for example a cc-agent agent on GLM could no longer use its web-reply tools.
Added
- Experimental: add
avatarstomodel-relay.jsonand a side pane shows the picture of the model this window is talking to. It changes when you switch with/provider <name>, when a Claude limit hands the window to a provider, and when it goes back to Claude. It is off by default:/provider avatar onturns it on for every window, and/provider avataropens or closes it in this window. It needsffmpegonPATH. See the README.
Technical details
- Cause: Claude Code announces tools from an MCP server that connects or reconnects mid-session as
tool_additionandtool_removalblocks in system messages, not in the request's tool list. Anthropic applies them. Other providers ignore them, so the model never saw those tools. - Fix: Before forwarding to a provider, the router applies these blocks to the tool list in order, and removes them from the messages.
- Verified on: the full test suite, a real Claude Code request through this release's router, and a cc-agent agent on GLM (z.ai) calling its reconnected MCP tools.
繁體中文
切到供應商的視窗,又能叫用對話中途重新連上的 MCP 工具;另有實驗性的面板,可以顯示你正在對話的模型頭像。
修正
- MCP server 在對話中途重新連線後,切到其他供應商(GLM、DeepSeek、Gemini、GPT…)的視窗現在也叫得到它的工具。過去這些工具在供應商那邊會不見,例如 cc-agent 員工切到 GLM 後,就不能再用回覆網頁的工具。
新增
- 實驗性:在
model-relay.json加上avatars,側邊面板會顯示這個視窗正在對話的模型頭像。你用/provider <name>切換、Claude 額度用完交給供應商,或切回 Claude 時,頭像會跟著換。預設關閉:/provider avatar on替所有視窗打開,/provider avatar開關這個視窗的面板。需要ffmpeg在PATH上。細節見 README。
技術細節
- 原因: MCP server 在對話中途連上或重新連線時,Claude Code 會把它的工具寫成系統訊息裡的
tool_addition、tool_removal區塊,不放進請求的工具清單。Anthropic 會套用,其他供應商不認得,所以模型根本看不到這些工具。 - 修正方式: 轉發給供應商之前,router 會依序把這些區塊套進工具清單,再從訊息裡拿掉。
- 驗證範圍: 完整測試套件、一個經由本版 router 的真實 Claude Code 請求,以及 cc-agent 員工在 GLM(z.ai)上叫用重新連上的 MCP 工具。
v0.7.4
The router now stays up and responds when a config value is invalid or a provider stops sending data, and /provider doctor no longer changes your settings unless you ask it to.
Fixed
- When a provider stops sending data, Claude Code now receives an error after 5 minutes (
idleTimeoutMs) so the usual retry and failover rules can take over. Previously, a request could wait indefinitely. - An invalid URL in a provider address or
claudeUrlno longer stops the router across all open windows. The invalid provider is skipped, and an invalidclaudeUrlfalls back to Anthropic. - When multiple providers share a gateway, requests for each provider's own
modelnow reach that provider. In some setups, one provider could previously take another's requests. - A gateway started through
launchnow starts only once even when shared by multiple providers, and retries at growing intervals if it fails to come up. doctor --fixand/provider initno longer overwrite anANTHROPIC_BASE_URLthat points to your own local gateway on another port.aliasnow stops with an error when~/.claude/settings.jsonis not valid JSON, instead of overwriting the file.
Changed
/provider doctornow only reports issues by default. Add--fixto apply the fixes it can make.
Added
idleTimeoutMs: how long a provider may send nothing before the request counts as failed (default: 5 minutes).
Technical details
- Model matching: A request whose model matches a provider's own
modelnow goes to that provider before anymatchModelspattern is tried. A provider whose model name looks like Claude no longer gets a default^claudepattern that would catch every Claude request. - Crash guards: Addresses rejected by
new URL()are dropped when reading the config, a session switch with a non-string id is refused, and any uncaught error is logged instead of ending the process. - Stalls: The upstream socket is closed after
idleTimeoutMsof silence, and an error response that drops mid-body is treated as unreachable so retry and failover can act. - Gateway launch: Launches are keyed by host and port, and a failed start waits 1, 2, 4… up to 10 minutes before the next try.
- Verified on: the full test suite, plus a router built from this release answering GLM (z.ai), DeepSeek, and Gemini and GPT through magpie.
繁體中文
設定值有誤或供應商停止回應時,轉發站現在會維持運作並正常回應;除非你加上 --fix,否則 /provider doctor 不再自動修改設定。
修正
- 供應商停止傳送資料時,Claude Code 會在 5 分鐘後(
idleTimeoutMs)收到錯誤,並交由一般的重試與備援規則接手。過去可能會無限期等下去。 - 供應商位址或
claudeUrl不是有效網址時,不會再導致轉發站停止、讓所有開啟的視窗一起斷線。該供應商會被略過,無效的claudeUrl則會改回 Anthropic。 - 多個供應商共用同一個 Gateway 時,指定各供應商自身
model的請求都會送到該供應商。過去在部分設定下,請求可能會被另一個供應商搶走。 - 透過
launch啟動的 Gateway,即使由多個供應商共用也只會啟動一次;若啟動失敗,重試間隔會逐步拉長。 - 若
ANTHROPIC_BASE_URL指向你自己在本機其他埠上的 Gateway,doctor --fix與/provider init不會再將它改掉。 - 當
~/.claude/settings.json不是有效的 JSON 時,alias會顯示錯誤並停止,不再把整份檔案重寫。
變更
/provider doctor現在預設只回報問題。加上--fix才會套用它能做的修正。
新增
idleTimeoutMs:設定供應商多久沒有傳送任何資料就視為請求失敗(預設 5 分鐘)。
技術細節
- 模型比對: 當請求的模型名稱等於某個供應商自己的
model時,會先送到該供應商,之後才比對matchModels規則。模型名稱像 Claude 的供應商,不再自動套用會攔下所有 Claude 請求的預設^claude規則。 - 防止崩潰: 讀取設定時會略過
new URL()無法解析的位址;拒絕 session id 不是字串的切換請求;其他未預期的錯誤只會寫入紀錄,不會結束程序。 - 卡住的請求: 上游連線超過
idleTimeoutMs沒有資料就切斷;錯誤回應傳到一半斷線時視為無法連線,讓重試與備援機制接手。 - Gateway 啟動: 以主機與埠判斷是否已啟動;啟動失敗後依 1、2、4… 分鐘(最多 10 分鐘)的間隔重試。
- 驗證範圍: 完整測試套件,加上以本版轉發站實測連到 GLM(z.ai)、DeepSeek,以及經由 magpie 的 Gemini 與 GPT。
v0.7.3
If your subagents run on another provider (GLM, DeepSeek, Gemini, GPT…), they can use WebFetch and your MCP tools reliably again. In some setups these tools could go missing.
Fixed
- Tools that Claude Code loads on demand, such as
WebFetchand MCP tools, now work on third-party providers in both subagents and the main conversation. Before, they could be unavailable in some setups.
Removed
- The
stripToolSearchsetting. It is no longer needed and is ignored if it is still in your config.
Technical details
- Cause: Claude Code keeps most tools out of the first request and lets the model load them with
ToolSearch. The router used to removeToolSearchand every tool loaded through it before forwarding to a third-party provider, so those tools could not be loaded. Subagents on providers without a 1M context rely on this, so they were the ones most likely to lose the tools. - Fix: The router now sends
ToolSearchto the provider under another name and changes it back in the reply. Some providers, z.ai among them, replace a tool namedToolSearchwith their own and hide the rest. Loaded tools are sent as ordinary tools the provider can call. - Verified on: GLM (z.ai), DeepSeek, and Gemini and GPT through magpie, in both subagents and
claude -psessions.
繁體中文
如果你的子代理跑在其他供應商上(GLM、DeepSeek、Gemini、GPT…),現在又能穩定使用 WebFetch 和你的 MCP 工具。過去在某些設定下,這些工具可能會缺少。
修正
- Claude Code 按需載入的工具(如
WebFetch、MCP 工具)在第三方供應商上可以正常使用,子代理和主對話都適用。過去在某些設定下可能無法使用。
移除
stripToolSearch設定:已不需要,設定檔裡留著也會被忽略。
技術細節
- 原因: Claude Code 第一輪只送出常用工具,其他工具讓模型用
ToolSearch需要時再載入。router 以前轉給第三方供應商前,會拿掉ToolSearch和經由它載入的工具,所以這些工具載入不了。沒有 1M context 的供應商上,子代理會依賴這個機制,因此最容易少掉工具。 - 修正方式: router 現在把
ToolSearch改個名字再送給供應商,回應時再改回來。有些供應商(例如 z.ai)看到名為ToolSearch的工具,會換成自己的版本並藏起其他工具。已載入的工具改用一般工具的形式送出,供應商可以直接呼叫。 - 驗證範圍: GLM(z.ai)、DeepSeek,以及經 magpie 的 Gemini、GPT,子代理和
claude -p新對話都測過。
v0.7.2
Each provider's model-relay:<name> subagent can now be shaped through providers.<name>.agent in ~/.claude/model-relay.json, so you can tell Claude when to pick each provider and give it its own prompt, tools, and effort level. Changes apply from your next message with no restart.
{
"providers": {
"fast": {
"model": "your-model-id",
"agent": {
"description": "Use for quick searches and small edits.",
"effort": "low"
}
}
}
}Added
- Per-provider subagent configuration (
providers.<name>.agent): Shapes each provider'smodel-relay:<name>subagent in~/.claude/model-relay.json.nameandmodelalways stay the provider's. - Subagent selection guidance (
agent.description): Sets the exact line Claude reads in its agent list when deciding which subagent to spawn, so it should say when to pick that agent. - Agent frontmatter fields: Accepts the fields a
.claude/agents/*.mdfrontmatter takes, such asprompt,tools,disallowedTools,skills,effort,maxTurns,permissionMode,isolation,background,hooks, andmcpServers. - Live updates and fallback: A change applies from your next message with no restart. Fields of the wrong shape are ignored; if Claude Code refuses the whole set, the subagent keeps the defaults and a notice says so.
Known limits
permissionModecannot override a parent running inbypassPermissions(seen on Claude Code 2.1.308).initialPromptis not applied to subagents started by the Agent tool (seen on Claude Code 2.1.308).memoryhad no effect on Claude Code 2.1.308, the same as in an ordinary.claude/agents/*.mdagent file.
繁體中文
每個供應商的 model-relay:<name> 子代理現在可透過 ~/.claude/model-relay.json 中的 providers.<name>.agent 調整,讓你能寫明 Claude 何時該選用各供應商,並設定各自的提示詞、工具與 effort 等級。修改自下一則訊息起生效,無須重啟。
{
"providers": {
"fast": {
"model": "your-model-id",
"agent": {
"description": "Use for quick searches and small edits.",
"effort": "low"
}
}
}
}新增
- 各供應商子代理設定(
providers.<name>.agent): 在~/.claude/model-relay.json中調整各供應商的model-relay:<name>子代理。name與model一律維持該供應商的值。 - 子代理選用說明(
agent.description): 設定 Claude 在代理清單中決定要啟動哪個子代理時所讀的那一行文字,因此應寫明何時該選用該代理。 - Agent frontmatter 欄位: 支援
.claude/agents/*.mdfrontmatter 可用的欄位,例如prompt、tools、disallowedTools、skills、effort、maxTurns、permissionMode、isolation、background、hooks與mcpServers。 - 即時生效與退回預設值: 修改自下一則訊息起生效,無須重啟。結構不符的欄位會被忽略;若 Claude Code 拒絕整組設定,子代理會維持預設值並顯示提示。
已知限制
permissionMode無法覆寫以bypassPermissions執行的父層(於 Claude Code 2.1.308 實測)。initialPrompt不會套用到由 Agent 工具啟動的子代理(於 Claude Code 2.1.308 實測)。memory在 Claude Code 2.1.308 上沒有作用,與一般.claude/agents/*.md定義檔相同。
Full changelog / 完整差異: v0.7.1...v0.7.2
v0.7.1
Lets custom statuslines (such as coralline's relay segment) display the actual model and routing state of each Claude Code window, and hides the plugin's own yellow status line above the prompt by default so the two do not duplicate each other.
< 0.7.0)? You must upgrade and migrate now:
- Why
< 0.7.0must be updated: Versions before0.7.0suffer from mid-chat conversation history and tool loss on non-Claude providers in HTTPS proxy mode (proxy enable), as well as a localhost security flaw where open browser tabs can spend your provider quota. - Upgrading from
0.7.0: Runclaude plugin update model-relay@model-relay. The plugin restarts the background router automatically once no request is in flight. - Upgrading from
0.6.0or earlier (3 required steps—updating the plugin alone is not enough):- Run
claude plugin update model-relay@model-relay. - Migrate your config to
"format": 2: run/provider setup upgrade my model-relay configin Claude Code (ornode tools/setup.mjs migrate --goin the plugin folder). - Run
/provider restartwhen no window has a reply in progress. (Full details: UPGRADING.md.)
- Run
Added
- Per-window status file for custom statuslines (
model-relay-status/<session id>): Claude Code's built-instatusLinepayload always reports the Claude model name beforemodel-relayrewrites it. Each window now writes its real relay state to~/.claude/model-relay-status/<session id>as a single linekind<TAB>label(claude,pinned,failover,limit,offline,direct) whenever the route changes (and after/clear), so statusline tools like coralline can read it directly with a single shellread. The background router automatically cleans up status files untouched for 7 days.
Changed
- Plugin status line above the input is now off by default (
statusBar): To keep the prompt area clean and avoid duplicating your statusline, the yellow plugin status line ($.ui.status) is now opt-in. Turn it back on anytime withnode tools/setup.mjs set statusBar on(or"statusBar": trueinmodel-relay.json); switches, upgrade reminders, and outage alerts still appear as toast notices.
繁體中文
讓自訂狀態列(例如 coralline 的 relay segment)能直接顯示每個 Claude Code 視窗實際連線的模型與分流狀態,並預設收起輸入框上方的外掛黃字狀態列,畫面不再重複佔位。
< 0.7.0)?請務必立即升級並完成設定轉換:
- 為什麼
< 0.7.0必須更新:0.7.0以前的版本在 HTTPS proxy 模式(proxy enable)下切到非 Claude 供應商時,第二輪起會遺失歷史對話與工具定義;同時存在瀏覽器網頁可偷連本機盜用 API 額度的安全漏洞。 - 從
0.7.0升級: 執行claude plugin update model-relay@model-relay即可,外掛會在轉發站閒置時自動重啟背景程序。 - 從
0.6.0或更早版本升級(必做三步驟——只更新外掛不會生效):- 執行
claude plugin update model-relay@model-relay。 - 將設定檔轉換為
"format": 2:在 Claude Code 輸入/provider setup upgrade my model-relay config(或在外掛資料夾執行node tools/setup.mjs migrate --go)。 - 趁沒有視窗正在回覆時執行
/provider restart。(完整說明見 UPGRADING.zh-TW.md。)
- 執行
新增
- 每個視窗寫出獨立狀態檔,供自訂 statusline 直接讀取(
model-relay-status/<session id>): Claude Code 內建傳給statusLine的資料永遠顯示轉發前原本的 Claude 模型名稱。現在每個視窗在路由改變(或執行/clear)時,都會把真實轉發狀態寫進~/.claude/model-relay-status/<session id>,格式為單行kind<TAB>label(claude、pinned、failover、limit、offline、direct),讓 coralline 等狀態列工具用一行 shellread就能直接顯示。超過 7 天未更新的檔案會由背景轉發站自動清理。
變更
- 輸入框上方的外掛黃字狀態列改為預設關閉(
statusBar): 為保持輸入區乾淨、避免與自訂 statusline 重複顯示,外掛狀態列($.ui.status)改為選用開啟。需要時可隨時執行node tools/setup.mjs set statusBar on(或在model-relay.json設定"statusBar": true)恢復顯示;切換模型、升級提醒與轉發站離線仍會正常跳出通知。
Full changelog / 完整差異: v0.7.0...v0.7.1
model-relay v0.7.0
- Fixes mid-chat "amnesia" in HTTPS proxy mode (
proxy enable): Non-Claude providers no longer lose your conversation history, system prompt, or tools mid-chat—every turn now sends the full conversation instead of a delta only Anthropic's server could resolve. - Closes a local quota-theft vulnerability: Browser web pages can no longer send requests to
127.0.0.1to spend your provider quota or change your session routing. - Streamlined daily controls:
/providerswitches now reply in one line, the/providerpanel closes automatically after you pick a model, and/provider pingtells you the exact reason a provider failed (key refused, unknown model, quota reached, or local service not running).
Upgrading (Required—updating the plugin alone is not enough):
Version 0.7 only reads config format 2 ("format": 2). If you are on 0.6 or earlier, you must run the 3 steps below, or your new router will not start (leaving your old 0.6 router running with the unpatched bugs, or sending all requests straight to Claude):
- Update the plugin:
claude plugin update model-relay@model-relay. - Migrate your config file (required): In Claude Code, run
/provider setup upgrade my model-relay config(or runnode tools/setup.mjs migrate --goin the plugin folder)—this backs up your old file and keeps your exact routing rules. - Restart the background router (required): Run
/provider restartwhen no reply is in progress to replace the old 0.6 background router with 0.7.
(Full details: UPGRADING.md.)
Added
- Guided setup and upgrades inside Claude Code (
/provider setup [goal]): Run/provider setupfrom any folder (even before a config file exists) and Claude walks you throughsetup.mjsstep by step—previewing changes, asking before touching~/.claude/settings.json, and never asking you to paste an API key into chat. - Clear failure reasons when testing a provider (
/provider ping):/provider ping, the panel'spkey, anddoctor --pingnow run a 1-token streaming test (up to 15 seconds) and report the exact result: works, key refused, unknown model, quota or rate limit, local service not running, unreachable, or timed out. Test latency is stored inpingseparately from real requeststats(so a long reply never makes a provider look slow), and API keys are masked in upstream error messages. - Restart the background router from Claude Code (
/provider restart):/provider restartandsetup.mjs restart [--if-stale] [--if-idle]replace the running router with the installed plugin's version./__healthnow reportsversion,inflightrequests, and openCONNECTtunnelsso the plugin can auto-restart an older router only when it is completely idle. - Notice when a
model-relay:<name>subagent did not reach the provider: If Claude Code launches amodel-relay:<name>subagent on a different model, or the subagent finishes without the router ever seeing that model (seenModelsin/__health), the plugin pops up a warning pointing you to/provider doctor. - Change the router port in one command (
setup.mjs set port <n>): Updates the port (1025–65535) with a.model-relay-backupcopy and rewiressettings.json(ANTHROPIC_BASE_URLorHTTPS_PROXY). Refuses ports already in use and prints the old router's PID so you can stop it when ready. - Machine-readable diagnostics (
doctor --json): Outputs every finding with anid, thesetup.mjsfixarguments, andneedsConsentwhen a fix modifies user settings. Unsetenv:VARkeys are reported asmissing-key(naming the variable, never the secret), and pre-format-2 configs are reported asoutdatedwithmigrate --goas the fix. - Config format 2 (
"format": 2): Written byinit,add, andmigrate --goso every routing rule is explicit in your file. If an older config (custom-agent.json, ormodel-relay.jsonwithout"format": 2) is present, the plugin leaves any running 0.6 router in place (or sends requests to Claude if none is running) and alerts you in the status line, panel, and UPGRADING.md. doctorwarns when the running router is older than the installed plugin./__healthreportsconfigDir: Identifies which config directory started the router (compared by real path, case-insensitively on Windows), sodoctor,proxy, and the plugin never confuse another profile's router for yours.- Real-client release smoke test (
tools/smoke.mjs): Starts this checkout's router on a temporary port and runs a realclauderequest through it (plus--provider <name>when given) before a release. - CI tests for plugin logic and provider neutrality:
hooks/logic.test.tsruns in CI under Node, andtools/neutral.mjsblocks hardcoded provider names, private gateways, or 0.6 file names outside legacy migration blocks.
Changed
- Cleaner
/provideroutput and a focused model-picker panel:/provider <name>and/provider claudenow reply with a single confirmation line instead of dumping the full status report and command list. Running/provideropens a compact panel dedicated to switching this window's model (and closes as soon as you switch); global toggles shared by all windows (429 failover, retry, Remote Control) and aliases are tucked under Settings[s]. Full status is now at/provider status, and the command reference is at/provider help. - Breaking (0.6 and earlier): older config files require
migrate --go. The 0.7 router ignorescustom-agent.jsonand anymodel-relay.jsonwithout"format": 2(doctorreportsoutdated). Runningnode tools/setup.mjs migrate --goconverts your file to format 2 and writes in every default 0.6 used to assume behind the scenes (preset models, thehaikurule on oldzai/glmpresets, oldgemini/magpiegateway settings, name-based guesses, and the default failover chain), guaranteeing your routing behavior does not change. See UPGRADING.md. - Other
setup.mjscommands refuse unmigrated configs:set,add,remove,alias,providers,init,restart,rc, andproxy enableno longer silently rewrite an older config on the fly; they ask you to runmigratefirst. - No hidden routing rules in format 2: Built-in presets (
zai,deepseek,kimi,minimax,openrouter) only supply the API address and compatibility flags—you always pick themodel. The oldglm,gemini, andmagpiepresets are removed, no preset hijackshaikuunless you set an alias, 429 errors are returned as-is iffailover.chainis empty, and nothing is guessed from a provider's name. setup.mjs add <name> --model <model id> --token <token|env:VAR> (--preset <preset> | --url <address>)validates required flags and preserves extra fields: Instead of inventing<name>-defaultorapi.example.comwhen flags are omitted,addnow requires a model and an address, updates only the URL, key, and model when editing an existing provider, saves a.model-relay-backupcopy, and refuses to overwrite an unreadable config. The first provider added to a new config becomes the default 429 failover target.presetslists only each service's API address, since presets no longer bundle a default model./__pingstores test latency inpinginstead of overwritingstats: Real request timings stay instats. (A Claude Code window still running the 0.6 plugin will show test times again after you restart it.)- Consistent
model-relay*file names: Config, state, logs, and backups are nowmodel-relay.json,model-relay-state.json,model-relay.log,model-relay-requests.log, and*.model-relay-backup. The 0.6custom-agent*names (custom-agent.json,custom-agent-state.json,custom-agent-router.log,custom-agent-requests.log) are renamed automatically bymigrate --go. initcreates an empty format 2 config instead of copying example providers: New installs route everything to Claude until you add a provider, anddoctorexplains how to add one instead of reporting an error.- The plugin reads provider list and state from the running router only: It reads only
portandnodePathfrom disk, preventing the UI from showing or selecting a provider the router is not actually serving. model-relay.example.json, README, and diagrams use neutral placeholder names instead of real providers.- Clear log message when the router port is already taken: On
EADDRINUSE, the router exits silently only if the process on that port is already serving the same config directory; otherwise it logs the port conflict and the other process's config directory tomodel-relay.logand exits non-zero. doctorandproxycommands detect routers from another config directory: If the port is held by a router for a different config directory,doctorandproxy statuswarn you andproxy enable|renewrefuse to overwrite settings, printing both directory paths.- The plugin bypasses routers belonging to another config directory: If the router on your port was started for a different config directory, the session connects directly to Claude and displays the other directory in the status line.
- Expanded README troubleshooting and architecture notes: Documented where
tools/setup.mjslives, howenv:VARtokens are read from the router process's environment, why automatic direct-to-Claude fallback only applies toANTHROPIC_BASE_URLmode, howHTTPS_PROXYaffectsgit/curl/gh, whatproxy.enabledintercepts, what CI covers, and how to completely uninstall.
Fixed
- **Non-Claude providers losing conversation history and ...
model-relay v0.6.0
Use Remote Control without losing the relay (proxy.enabled with a local CA constrained to api.anthropic.com), point haiku / sonnet / opus aliases at any provider in one command (setup.mjs alias & /provider alias), and spawn provider subagents on the fly (subagent_type: "model-relay:<name>") without .claude/agents/*.md files or restarting your session. The /provider panel also adds live toggles for 429 failover (failover.chain), retries (retry.enabled), and Remote Control (f / t / x).
Upgrading: Pull the latest version or run claude plugin update model-relay@model-relay. Run node tools/setup.mjs migrate --go if you want to clean up legacy config keys.
Added
- Remote Control with the relay still in the path (HTTPS proxy mode): Claude Code keeps
api.anthropic.comas its address, which Remote Control requires, and uses the relay as itsHTTPS_PROXY. The relay answers forapi.anthropic.comwith its own certificate and routes model calls exactly as before (providers, sticky 429 failover, retries); token refresh, Remote Control traffic and WebSocket upgrades pass to Anthropic unchanged, and every other host is a plain byte tunnel. Opt-in: off by default, so the router never acts as an open proxy for anyone who does not use Remote Control. Setting:proxy.enabled. - Name-constrained local certificate authority: The CA can only vouch for
api.anthropic.com, its private key is discarded after it signs the one leaf certificate, and only processes that carryNODE_EXTRA_CA_CERTStrust it. Without a usable certificate the relay tunnelsapi.anthropic.comuntouched, so Claude Code keeps working. setup.mjs proxyandsetup.mjs rc:proxy status|enable|disable|renew(add--goto apply) switchessettings.jsonbetween API-address mode and proxy mode, keeps asettings.json.relay-backupcopy and refuses settings it does not own;rcstarts the router when needed and then runsclaude remote-control.- Failover chain:
failover.chainlists the providers that take over, in order. When Claude hits its limit the first one answers, and withretry.failovera provider that keeps failing hands the request to the next one, never back to one it already tried. A provider can override this withproviders.<name>.fallback(falsefor nobody, or its own list). - Retry master switch:
retry.enabledset tofalseturns retrying off everywhere and keeps the other retry settings for later. - Switches in the
/providerpanel: three rows turn 429 failover, retry and Remote Control on or off (hotkeysf,t,x). Remote Control asks for confirmation first because it rewritessettings.json; the panel changes the file through the samesetandproxycommands ofsetup.mjs. - Config commands in
setup.mjs:setchanges one switch or list after validating it,providersshows routes, failover and retry per provider,removedeletes a provider from the file and from every failover list, andmigratemoves an old file to the current layout. Edits keep a.relay-backupcopy, tokens are never printed, and the router reads the result on its next request. - First-class model alias management (
setup.mjs alias&/provider alias): Inspect or pointhaiku,sonnet,opus, orsubagent(CLAUDE_CODE_SUBAGENT_MODEL) at any provider or back to Claude in one command, keeping~/.claude/settings.json(ANTHROPIC_DEFAULT_*_MODEL) and~/.claude/model-relay.json(matchModels) in sync./providerand the panel now display model aliases separately from 429 failover and support/provider alias|failover|retry|rcdirectly from the prompt. - Dynamic
model-relay:<provider>subagent types ($.agent.register&agent.spawn): Because Claude Code'sAgenttool validatesmodelagainst"sonnet"|"opus"|"haiku"|"fable", the plugin dynamically registersmodel-relay:<name>(such asmodel-relay:glmandmodel-relay:gemini) with full parent tools and the provider's model ID, and locks that model inon('agent.spawn')—no static.claude/agents/*.mdfile or session restart needed.
Changed
doctorunderstands proxy mode:doctor --fixno longer putsANTHROPIC_BASE_URLback when proxy mode is on, and/__healthreports proxy state and connection counts.- Cleaner config layout:
failoverholdsenabled,chainandcooldownMs, and providers live only underproviders. The old top-levelbaseUrl,token,model,gemini,failoverEnabled,probeEveryMinandfailoverProviderstill work and are read as if migrated;migrate --gorewrites the file with the same behaviour. doctorchecks the config: it warns about an old layout, failover names that match no provider, and a model name that another provider'smatchModelsclaims first, and its failover line shows the chain and the cooldown./__healthreports the switches:failoverChainandconfigshow what the router is really doing, so the panel never guesses.
Fixed
failover.cooldownMswas ignored: the documented setting had no effect because the router readprobeEveryMin.failover.cooldownMsnow sets how long new sessions stay off Claude, with a one-minute minimum.- A half-saved config no longer fails requests: the router keeps the last good config when the file cannot be read for a moment, and the
setup.mjscommands write files in one step. - Claude model names matched via
matchModelsare now rewritten on the wire: when a request carrying aclaude-*model (such as a hardcodedclaude-haiku-4-5-20251001) matches a provider'smatchModels, the router now rewrites the body'smodelfield to that provider's target model instead of forwarding theclaude-*name unchanged.
繁體中文
支援保留轉發站的手機 Remote Control(proxy.enabled 搭配只限 api.anthropic.com 的本機 CA)、一行指令設定 haiku/sonnet/opus 模型別名分流(setup.mjs alias 與 /provider alias),並動態註冊可直接派工的供應商子代理(subagent_type: "model-relay:<name>"),免建 .claude/agents/*.md 也免重開對話。/provider 互動面板同步新增 429 備援(failover.chain)、失敗重試(retry.enabled)與手機遙控三列開關(熱鍵 f/t/x)。
升級: 拉取最新版本或執行 claude plugin update model-relay@model-relay。若想整理舊版設定鍵,可執行 node tools/setup.mjs migrate --go。
新增
- 轉發站留在路徑上也能用 Remote Control(HTTPS 代理模式): Claude Code 維持
api.anthropic.com當位址(Remote Control 的要求),改把轉發站當成它的HTTPS_PROXY。轉發站以自己的憑證代答api.anthropic.com,模型請求照舊分流(供應商、429 黏著備援、重試);token 更新、Remote Control 流量與 WebSocket 升級原封不動交給 Anthropic,其他網站則是單純的位元組通道。選用功能:預設關閉,沒用 Remote Control 的人,轉發站不會變成開放代理。設定:proxy.enabled。 - 限定網域的本機憑證授權單位: 這個 CA 只能為
api.anthropic.com背書,簽完唯一的那張葉憑證後私鑰立即丟棄,而且只有帶NODE_EXTRA_CA_CERTS的程序才會信任它。沒有可用憑證時,轉發站會把api.anthropic.com原封不動轉送,Claude Code 照常運作。 setup.mjs proxy與setup.mjs rc:proxy status|enable|disable|renew(加--go才會套用)在 API 位址模式與代理模式之間切換settings.json,保留settings.json.relay-backup備份,且不會碰不屬於轉發站的設定;rc會在需要時先啟動轉發站,再執行claude remote-control。- 備援名單:
failover.chain依序列出接手的供應商。Claude 額度用完時由第一個回答;開啟retry.failover後,持續失敗的供應商會把請求交給下一個,不會回頭找已經試過的。供應商可以用providers.<name>.fallback覆寫(false代表不交給任何人,或自己的清單)。 - 重試總開關:
retry.enabled設為false即全面停止重試,其他重試設定會保留,之後再開即可。 /provider面板上的開關: 三列開關可開關 429 備援、重試與 Remote Control(熱鍵f、t、x)。Remote Control 會改寫settings.json,所以先確認再執行;面板是透過setup.mjs同一組set與proxy指令修改檔案。setup.mjs的設定指令:set驗證後修改單一開關或清單,providers逐一列出路由、備援與重試,remove把供應商從檔案與所有備援名單中移除,migrate把舊格式檔案整理成目前的格式。每次修改都會留一份.relay-backup備份、token 一律不會印出,轉發站在下一個請求就會讀到結果。- 一鍵模型別名管理(
setup.mjs alias與/provider alias): 可在單一指令查看或將haiku、sonnet、opus與subagent(CLAUDE_CODE_SUBAGENT_MODEL)指向指定供應商或還原回 Claude,自動同步更新~/.claude/settings.json(ANTHROPIC_DEFAULT_*_MODEL)與~/.claude/model-relay.json(matchModels)。/provider與互動面板現在將「別名分流」與「429 備援」分開揭露,並支援直接在對話框輸入/provider alias|failover|retry|rc。 - 動態註冊
model-relay:<provider>子代理類型($.agent.register與agent.spawn): 針對 Claude CodeAgent工具model欄位只接受"sonnet"|"opus"|"haiku"|"fable"的限制,外掛現在會自動為每個供應商動態註冊具備完整父層工具的model-relay:<name>(如model-relay:glm、model-relay:gemini),並在on('agent.spawn')鎖定該供應商的模型 ID——無須建立.claude/agents/*.md或重開對話。
變更
doctor認得代理模式: 代理模式開啟時,doctor --fix不會再把ANTHROPIC_BASE_URL加回去,/__health也會回報代理狀態與連線數。- 設定檔格式更乾淨:
failover底下放enabled、chain與cooldownMs,供應商只放在providers。舊的頂層baseUrl、token、model、gemini、failoverEnabled、probeEveryMin與failoverProvider仍可使用,讀取時等同已整理過;migrate --go會在行為不變的前提下改寫檔案。 doctor會檢查設定: 提醒舊版格式、備援名單裡不存在的供應商,以及被別的供應商的matchModels先攔走的模型名稱,備援那一行也會顯示名單與冷卻時間。/__health回報開關狀態:failoverChain與config讓面板顯示轉發站實際的狀態,而不是猜測。
修正
failover.cooldownMs沒有作用: 文件寫的設定沒有生效,因為轉發站讀的是probeEveryMin。現在failover.cooldownMs會決定新對話離開 Claude 多久,最小一分鐘。- 存到一半的設定檔不再讓請求失敗: 檔案暫時讀不到時,轉發站會沿用上一份正常的設定;
setup.mjs的指令也改成一次寫完整個檔案。 - 經由
matchModels攔截的claude-*請求會正確改寫模型名稱: 當帶有claude-*(例如 Claude Code 內部寫死的claude-haiku-4-5-20251001)的請求符合某個供應商的matchModels時,轉發站現在會把送往上游的model欄位改寫為該供應商的目標模型,不再原樣送出claude-*。
Full changelog / 完整差異: v0.5.0...v0.6.0
model-relay v0.4.0
Type /provider to open an interactive AbovePrompt control panel right above your prompt input box: switch the current window's model with one click (or hotkeys 1–9), test live latency across every provider ([Ping]), and protect long prompt caches with a two-click confirmation before switching back to Claude. Both English and Traditional Chinese READMEs now have their own animated banners and story diagrams.
Upgrading: Pull the latest version or run claude plugin update model-relay@model-relay. No configuration changes are required.
Added
- Interactive
AbovePromptcontrol panel: Running/provideror/provider panelopens an interactive panel above the prompt where you can switch providers by clicking buttons or pressingctrl+x tab+1–9, with a two-step confirmation before switching a pinned session back to Claude. - Live upstream latency ping (
/__pingand/provider ping): Test live HTTP status and response time for all configured providers directly from the panel ([Ping]) or via/provider ping, and reset 429 cooldown timers via[Retry Claude]or/provider probe. - Separate English and Traditional Chinese animated SVGs: Added dedicated English and Traditional Chinese dark/light banners (
banner-dark.svg,banner-light.svg,banner-dark.zh-TW.svg,banner-light.zh-TW.svg) and story animations (relay-flow.svg/.zh-TW.svg,panel.svg/.zh-TW.svg).
繁體中文
輸入 /provider 即可在輸入框上方開啟 AbovePrompt 互動控制面板:一鍵(或按熱鍵 1–9)切換單一視窗的模型、即時測試各供應商的回應延遲([Ping]),並在切回 Claude 前提供二次確認以保護長對話快取。英文與繁體中文 README 現在各自擁有獨立的深淺色動態 Banner 與情境動畫圖。
升級: 拉取最新版本或執行 claude plugin update model-relay@model-relay 即可,無須修改現有設定檔。
新增
- 輸入框上方的
AbovePrompt互動控制面板: 執行/provider或/provider panel會在輸入框上方打開互動面板,可直接點選按鈕或按ctrl+x tab加數字鍵1–9切換模型,並在將已固定的長對話切回 Claude 前提供二次確認防呆。 - 上游供應商即時連線測速(
/__ping與/provider ping): 可直接從面板點選[Ping]或輸入/provider ping即時測試所有供應商的 HTTP 狀態碼與回應時間,並支援透過[Retry Claude]或/provider probe重置 429 冷卻計時。 - 中英雙語獨立動態 SVG: 為英文與繁體中文分別設計專屬的深淺色動態 Banner(
banner-dark.svg、banner-light.svg、banner-dark.zh-TW.svg、banner-light.zh-TW.svg)以及兩組情境動畫(relay-flow.svg/.zh-TW.svg、panel.svg/.zh-TW.svg)。
Full changelog / 完整差異: v0.3.0...v0.4.0
model-relay v0.3.0
model-relay is now open-source as a flexible, multi-provider localhost router and failover toolkit for Claude Code. You can route individual conversations or haiku subagents across Claude, GLM (z.ai), Gemini (via local gateway), DeepSeek, Kimi, MiniMax, or OpenRouter without losing prompt cache efficiency when Claude hits a 429 usage limit.
Upgrading: Existing ~/.claude/custom-agent.json files continue to work without changes. Run node tools/setup.mjs init --fix and node tools/setup.mjs doctor --ping to verify your setup or migrate to ~/.claude/model-relay.json.
Added
- Flexible multi-provider routing and built-in presets: Configure any number of providers under
providers.<name>using built-in presets (zai,glm,deepseek,kimi,minimax,openrouter,gemini,magpie) sobaseUrl,model,matchModels,stripToolSearch,stripCacheControl, andauthHeaderwork out of the box with just atoken. Setting:providers. - Cache-safe sticky 429 failover: When Anthropic returns a 429 usage-limit response, the router automatically forwards to
failover.providerand pins that session for 7 days so recovering Claude quota never triggers an expensive 800k-token prompt cache rebuild on existing long chats. Setting:failover. - Structured
/providercommand and live provider sync:/providernow displays an aligned route list (●active vs○available) synced directly with the router's live/__healthendpoint, hiding providers whoseenv:VAR_NAMEtoken is unset. - One-command
doctorand upstream--pingCLI: Runnode tools/setup.mjs doctor --fix --pingto validate config syntax, detect unsetenv:VARvariables, wireANTHROPIC_BASE_URLinto~/.claude/settings.json, check localhost router health, and send a 1-token live probe to every configured provider. - Local gateway supervision (
launch): Providers pointing at127.0.0.1orlocalhostcan declarelaunch: { command, args }so the router automatically spawns the local gateway whenever its TCP port is closed. Setting:providers.<name>.launch. - Cross-platform and bilingual UI support: Supports both Windows (
powershell.exe+curl.exe) and macOS/Linux (sh+curl), with English and Traditional Chinese status/command output plus SVG architecture diagrams.
Removed
- Legacy child-process
custom_agenttool: Removed the deprecatedclaude.exe -pchild-process wrapper so the plugin focuses purely on fast, zero-overhead HTTP relay and session routing.
繁體中文
model-relay 正式開源為 Claude Code 專用的多供應商本機模型轉發站與 429 自動備援工具。你可以在不中斷工作、不浪費長對話快取的前提下,將單一對話或 haiku 子代理靈活分流至 Claude、GLM(z.ai)、Gemini(透過本地端 Gateway)、DeepSeek、Kimi、MiniMax 或 OpenRouter。
升級: 既有的 ~/.claude/custom-agent.json 無須修改即可繼續使用。可執行 node tools/setup.mjs init --fix 與 node tools/setup.mjs doctor --ping 進行全鏈路體檢或遷移至 ~/.claude/model-relay.json。
新增
- 彈性多供應商路由與內建 Presets: 在
providers.<name>下自由新增任意數量的供應商,內建zai、glm、deepseek、kimi、minimax、openrouter、gemini、magpie預設集,只需填寫token即可自動帶入最佳的baseUrl、model、matchModels、stripToolSearch、stripCacheControl與authHeader。設定:providers。 - 保護快取的 429 自動備援與對話黏著: 當 Anthropic 回傳 429 額度上限時,自動切換至
failover.provider並將該對話固定 7 天;Claude 額度恢復後只有新對話回到 Claude,避免長對話切回時重建 80 萬+ token 快取而瞬間燒光額度。設定:failover。 - 結構化
/provider清單與即時狀態同步:/provider改為對齊顯示目前所在路由(●)與可切換路由(○),並直接與轉發站/__health同步,自動隱藏尚未匯出env:VAR_NAME金鑰的供應商。 - 一鍵
doctor全鏈路體檢與上游--ping實測: 執行node tools/setup.mjs doctor --fix --ping即可一次檢查設定檔語法、未設定的env:VAR環境變數、自動將ANTHROPIC_BASE_URL寫入~/.claude/settings.json、確認本機轉發站健康度,並對每個供應商發送 1-token 真實請求測試連線延遲。 - 本地端 Gateway 自動拉起(
launch): 指向127.0.0.1或localhost的供應商可設定launch: { command, args },當本機連接埠未開啟時由轉發站在背景自動啟動程序。設定:providers.<name>.launch。 - 跨平台與中英雙語介面: 同時支援 Windows(
powershell.exe+curl.exe)與 macOS/Linux(sh+curl),依 Claude Code 語系設定自動切換繁體中文/英文介面,並附深淺色 Banner 與架構流程 SVG。
移除
- 舊版
custom_agent子程序工具: 移除已棄用的claude.exe -p子程序包裝程式碼,讓外掛專注於純粹、零額外負擔的 HTTP 模型轉發與對話路由。
Full changelog / 完整差異: https://github.com/cablate/model-relay/releases/tag/v0.3.0