Zero-model mid-session backend switching with shell commands#36
Open
oloflun wants to merge 1 commit into
Open
Conversation
New file: proxy/routing-proxy.mjs A lightweight 3-server routing proxy enabling mid-session backend switching without model involvement. Supports per-session isolation via dynamic ports and per-session mode files. Backward compatible -- defaults to global mode file and port 3199 when CLI args omitted. Auto-fallback: Anthropic 401/402/403 silently retries via DeepSeek. Status endpoint at GET /_router/status returns current mode and port. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Switch between DeepSeek and Anthropic backends mid-session without model involvement. Type
!dsor!antdirectly in Claude Code -- the shell executes the switch before any model call. No /command delay, no skill/agent loading, works even when the current backend is completely unreachable.How it works
A lightweight 3-server routing proxy (routing-proxy.mjs) sits between Claude Code and the API backends. It reads a mode file on every request and routes to the appropriate backend:
!ds/!ant/!backendare Bash scripts that write to the session mode file. Claude Code's!prefix runs them at the CLI layer before any API request.PowerShell session management (master commands)
From any PowerShell window:
Functions auto-detect the current session via ANTHROPIC_BASE_URL env var. Auto-refresh from disk -- no manual profile reload needed.
Changes
Companion setup (one-time, on user machine)
Three Bash scripts in ~/.local/bin/ and PowerShell profile functions provide the in-session commands and session management. See the companion Gist linked below for full setup.
🤖 Generated with Claude Code