Repository navigation
Releases: cablate/model-relay
Release list
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