High-performance bridge proxy connecting Claude Code CLI & Anthropic SDK to ANY OpenAI-compatible LLM provider (DeepSeek, OpenRouter, Groq, Ollama, Gemini, OpenAI) with zero-crash streaming, failover & secret redaction.
30
stars
19
commits
Python
primary language
Sep 2, 2026
updated
High-Performance Universal Bridge connecting Claude Code CLI & Anthropic SDKs to ANY AI Model.
Zero-crash streaming, multi-provider failover, chain-of-thought sanitization, PII redactor, and 24+ provider presets.
Claude Code CLI is one of the most capable agentic coding tools available today. However, it is natively locked to Anthropic's commercial cloud endpoints.
ClaudeGate is a lightweight, high-throughput, and secure local API gateway that bridges Anthropic's Messages API protocol (/v1/messages and /v1/messages/count_tokens) into standard OpenAI-compatible Chat Completions.
With ClaudeGate, developers can power Claude Code CLI, Cursor, and Anthropic SDK applications using:
BIG_MODEL, MIDDLE_MODEL, and SMALL_MODEL tiers or passes through direct model slugs.ClaudeGate in active operation, translating Claude Code CLI tool calls, bash commands, and streaming tokens in real-time:
โก ClaudeGate Proxy Gateway
|
๐ค Claude Code CLI in Action
|
content_block_start, content_block_delta, message_delta, message_stop). Mid-stream disconnects and upstream errors are caught gracefully without crashing Starlette/ASGI.503, 429, or timeout errors without dropping the active client session.SANITIZE_SECRETS=true).<thinking> Sanitizer: Cleanses internal reasoning tokens and <thinking> blocks from conversation history so multi-turn reasoning models (like DeepSeek R1/V4) never trigger 400 Bad Request errors on follow-up turns.timeout_keep_alive=600) to prevent Node.js ECONNRESET drops during prolonged user typing pauses.--setup), live connectivity diagnostic (--test), and 24+ instant preset switches (--preset <name>).hmac (Constant-time token authentication) and Regex Token Redaction EngineClaudeGate sits transparently between Claude Code CLI and your chosen AI model provider:
flowchart LR
A["Claude Code CLI\nor Anthropic SDK"] -- "POST /v1/messages\n(Anthropic Schema)" --> B["ClaudeGate Gateway\n(FastAPI / Port 8082)"]
subgraph CoreEngine ["ClaudeGate Core Engine"]
B --> C["Constant-Time Auth & IP Validator"]
C --> D["Request Sanitizer\n(PII & Credential Redaction)"]
D --> E["Protocol Converter\n(Tools, Messages, System Prompts)"]
E --> F["Upstream Client & Failover Controller"]
end
subgraph Upstream ["Upstream AI Providers"]
F -- "Primary Request" --> G["Primary Provider\n(OpenRouter / DeepSeek / Gemini)"]
F -. "Auto Failover on 503/429" .-> H["Backup Provider\n(Groq / Local Ollama)"]
end
G -- "OpenAI Chunk Stream" --> I["SSE Stream Adapter\n(Zero-Crash Generator)"]
H -- "OpenAI Chunk Stream" --> I
I -- "Anthropic SSE Events" --> A
ClaudeGate/
โโโ assets/ # Visual assets and screenshots
โ โโโ ClaudeGate.png # Project Banner & Logo
โ โโโ claude_terminal_ss.png # Claude Code CLI in action
โ โโโ proxy_terminal.png # ClaudeGate terminal proxy log
โโโ Dockerfile # Container image specification
โโโ docker-compose.yml # Container service configuration
โโโ requirements.txt # Python package dependencies
โโโ pyproject.toml # Modern package build configuration
โโโ setup.py # Legacy pip install compatibility
โโโ start_proxy.py # CLI & Server launcher script
โโโ .env.example # Comprehensive environment template
โโโ LICENSE # MIT License
โโโ SECURITY.md # Security policy & reporting guidelines
โโโ CODE_OF_CONDUCT.md # Community standard of conduct
โโโ CONTRIBUTING.md # Contribution guidelines
โโโ CHANGELOG.md # Version release history
โโโ README.md # Project documentation
โ
โโโ presets/ # Ready-to-use provider templates
โ โโโ openrouter.env # OpenRouter (Claude Opus 5, Sonnet 5, Haiku 4.5)
โ โโโ groq.env # Groq (DeepSeek V4-Pro, Llama 4 Maverick, Muse Glimmer)
โ โโโ ollama.env # Ollama (100% Local DeepSeek V4-Pro, Qwen3.6-35B, Muse Glimmer)
โ โโโ deepseek.env # DeepSeek (DeepSeek V4-Pro & V4-Flash)
โ โโโ gemini.env # Google Gemini (Gemini 3.1 Pro, 3.7 Flash & 3.5 Flash-Lite)
โ โโโ openai.env # OpenAI Official (GPT-5.6 Sol, GPT-5.6 Terra, GPT-5.6 Luna)
โ โโโ kimi.env # Moonshot AI (Kimi K3 2.8T Reasoning & K2.7 Code)
โ โโโ qwen.env # Alibaba Qwen / DashScope (Qwen3.8-Max, Qwen3.7-Plus, Qwen3.8-27B)
โ โโโ mistral.env # Mistral AI (Mistral Large 3, Mistral Medium 3.5, Mistral Small 4)
โ โโโ perplexity.env # Perplexity (Sonar Reasoning Pro, Sonar Pro & Sonar)
โ โโโ cohere.env # Cohere (Command A+, Command A & Command R7B)
โ โโโ minimax.env # MiniMax (MiniMax M3 Frontier & MiniMax M2.7)
โ โโโ meta.env # Meta AI (Muse Spark 1.2, Llama 4 Maverick, Muse Glimmer)
โ โโโ zai.env # Z.ai / Zhipu GLM (GLM-5.3 Flagship, GLM-5-Turbo, GLM-4.7-Flash)
โ โโโ together.env # Together AI (DeepSeek V4-Pro, DeepSeek V4-Flash, Qwen3.8-27B)
โ โโโ fireworks.env # Fireworks AI (DeepSeek V4-Pro, DeepSeek V4-Flash, Qwen3.8-27B)
โ โโโ cerebras.env # Cerebras (DeepSeek V4-Pro, Llama 4 Maverick, Muse Glimmer)
โ โโโ sambanova.env # SambaNova Cloud (DeepSeek V4-Pro, Llama 4 Maverick, Qwen3.8-27B)
โ โโโ siliconflow.env # SiliconFlow (DeepSeek V4-Pro, DeepSeek V4-Flash, Qwen3.8-27B)
โ โโโ lmstudio.env # LM Studio Desktop (DeepSeek V4-Pro & Muse Glimmer)
โ โโโ vllm.env # vLLM Self-Hosted GPU (DeepSeek V4-Pro & Qwen3.6-35B)
โ โโโ azure.env # Azure OpenAI Service (o1 & GPT-5.6 Enterprise Deployments)
โ โโโ kiro.env # AWS Amazon Q Developer / Claude Opus 5 Bridge
โ โโโ ox.env # Stealth Ox Alpha (Frontier Reasoning Model)
โ โโโ nemotron.env # Nvidia Nemotron Free Tier
โ
โโโ scripts/ # Verification & test utilities
โ โโโ verify_failover.py # Automated failover simulation runner
โ โโโ test_live_nemotron_ox.py # Live dual-model probe (Nemotron & Ox Alpha)
โ
โโโ src/ # Source code
โโโ main.py # FastAPI app & Uvicorn lifecycle
โโโ cli.py # CLI commands, setup wizard & test runner
โโโ api/
โ โโโ endpoints.py # /v1/messages, /health & /count_tokens routes
โโโ conversion/
โ โโโ request_converter.py # Anthropic -> OpenAI message & tool parsing
โ โโโ response_converter.py # OpenAI stream -> Anthropic SSE translation
โโโ core/
โ โโโ client.py # Async client with failover & retry logic
โ โโโ config.py # Dynamic environment loader & constant-time auth
โ โโโ constants.py # Anthropic & OpenAI protocol constants
โ โโโ logging.py # Structured logging configuration
โ โโโ model_manager.py # Intelligent model tier & slug router
โโโ models/
โ โโโ claude.py # Pydantic schemas for Anthropic API
โ โโโ openai.py # Pydantic schemas for OpenAI API
โโโ security/
โโโ sanitizer.py # Secret, AWS key, and PAT redaction engine
git clone https://github.com/Santosh-Prasad-Verma/ClaudeGate.git
cd ClaudeGate
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Launch the interactive configuration wizard:
python start_proxy.py --setup
Or load a ready-made preset directly:
python start_proxy.py --preset openrouter
You can configure Claude Code CLI to communicate with ClaudeGate using either Permanent or Session-Based configuration:
Edit (or create) ~/.claude/settings.json to automatically route all future claude commands to ClaudeGate:
{
"env": {
"ANTHROPIC_BASE_URL": "http://127.0.0.1:8082",
"ANTHROPIC_API_KEY": "sk-claudegate-local"
}
}
Export the variables in your active shell before launching Claude:
export ANTHROPIC_BASE_URL="http://127.0.0.1:8082"
export ANTHROPIC_API_KEY="sk-claudegate-local"
Run the built-in diagnostic test to verify your upstream provider connection and measure latency:
python start_proxy.py --test
Expected Output:
๐ Testing upstream connection...
Provider Base URL: https://openrouter.ai/api/v1
Test Model: stealth/ox-alpha
โ
Connection Successful! Model is active and responsive.
Status: 200 OK
You can also probe the gateway health endpoint directly from your terminal:
curl http://127.0.0.1:8082/health
# {"status":"healthy","service":"claudegate"}
Once setup is complete, your day-to-day workflow looks like this:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ TERMINAL 1: Start ClaudeGate Gateway Daemon โ
โ $ cd ClaudeGate && python start_proxy.py โ
โ [Gateway listening on http://127.0.0.1:8082 (OpenRouter/Groq/Ollama)] โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ (Translates Anthropic โท OpenAI protocol)
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ TERMINAL 2: Your Codebase Workspace (Run Claude Code) โ
โ $ cd /path/to/my-project โ
โ $ claude โ
โ โ
โ > "Add JWT authentication to src/auth.py and run the unit tests" โ
โ โ
โ Claude Code โโโโโโโบ ClaudeGate (8082) โโโโโโโบ DeepSeek R1 / Qwen / Groq โ
โ (CLI Tool Calls) (Translates schemas) (Executes inference & tools) โ
โ โโโโโโโโโโโโโโโโโโโ (Streams SSE Events) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โ
Claude Code automatically reads files, writes code, and runs bash tests! โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Start the Gateway (Terminal 1):
cd ClaudeGate
python start_proxy.py
ClaudeGate will boot up, display active model mappings, and listen on http://127.0.0.1:8082.
Open Your Coding Project (Terminal 2): Navigate to whatever software project or repo you want to work on:
cd ~/my-flutter-app # or any project directory
Launch Claude Code:
claude
You can now type natural language instructions as usual. Claude Code will execute file inspections, bash commands, multi-file edits, and git commits powered entirely by your chosen backend model!
Switching Models On The Fly: Want to swap from free cloud models (OpenRouter) to 100% private offline models (Ollama)? In Terminal 1:
python start_proxy.py --preset ollama
python start_proxy.py
Claude Code in Terminal 2 will immediately begin routing through local Ollama without needing a restart.
| Command | Purpose |
|---|---|
python start_proxy.py | Start the ClaudeGate server |
python start_proxy.py --test | Run live connectivity probe & measure upstream latency |
python start_proxy.py --setup | Launch interactive 24-provider setup wizard |
python start_proxy.py --preset <name> | Quick-load a preset (e.g. groq, gemini, ollama, deepseek) |
python start_proxy.py --help | View help and available options |
python start_proxy.py --version | Display current release version |
If you prefer to run ClaudeGate as a background Docker container:
# Build and start container in the background
docker compose up -d --build
# View real-time logs
docker compose logs -f
# Check container health status
docker ps
# Stop container
docker compose down
ClaudeGate includes built-in live diagnostics and automated test suites:
Test your active model and measure upstream response latency:
python start_proxy.py --test
Output:
๐ Testing upstream connection...
Provider Base URL: https://openrouter.ai/api/v1
Test Model: stealth/ox-alpha
โ
Connection Successful! Model is active and responsive.
Status: 200 OK
Simulate an upstream outage to test automatic failover:
python scripts/verify_failover.py
Run the full test suite covering non-streaming failover, SSE streaming, and endpoint security:
pytest tests/ -v
ClaudeGate implements defense-in-depth privacy controls to ensure secure self-hosting:
127.0.0.1): Restricts incoming traffic exclusively to the local machine.hmac.compare_digest to validate x-api-key headers, preventing side-channel timing analysis.SANITIZE_SECRETS="true", prompts are automatically scrubbed for sensitive tokens (GitHub PATs, AWS Access Keys, OpenAI Keys, Private SSH keys) before reaching upstream providers.Error Markers over Generator Exceptions:
HTTPException inside an active StreamingResponse async generator after HTTP headers (200 OK) are flushed causes a fatal RuntimeError: response already started and terminates the ASGI worker.ERROR::<status>::<message> tokens that the SSE converter catches and translates into standard Anthropic error events, keeping the worker process healthy.Multi-Turn <thinking> Cleansing:
400 Bad Request.request_converter automatically identifies and filters thinking and redacted_thinking content blocks before dispatching to upstream providers.Constant-Time Client Authentication:
key == expected) are susceptible to side-channel timing attacks.hmac.compare_digest across all header validation points.10-Minute TCP Keep-Alive (timeout_keep_alive=600):
ECONNRESET if an interactive user takes longer than 5 seconds between prompts.http://127.0.0.1:8082/dashboard) for live latency charts, token velocity, and cost tracking./run/user/$UID/claudegate.sock.We welcome bug fixes, documentation improvements, new provider presets, and feature additions!
presets/<provider_name>.env and submit a pull request!Distributed under the MIT License. See LICENSE for more information.
Built with โค๏ธ for the open-source & AI developer community.
Empowering developers to run Claude Code with any model, anywhere, completely unrestricted.
โญ If you find ClaudeGate useful, consider giving it a star on GitHub! โญ
18 commits
1 commits
Python
99.4%
High-performance bridge proxy connecting Claude Code CLI & Anthropic SDK to ANY OpenAI-compatible LLM provider (DeepSeek, OpenRouter, Groq, Ollama, Gemini, OpenAI) with zero-crash streaming, failover & secret redaction.
30
stars
19
commits
Python
primary language
Sep 2, 2026
updated
High-Performance Universal Bridge connecting Claude Code CLI & Anthropic SDKs to ANY AI Model.
Zero-crash streaming, multi-provider failover, chain-of-thought sanitization, PII redactor, and 24+ provider presets.
Claude Code CLI is one of the most capable agentic coding tools available today. However, it is natively locked to Anthropic's commercial cloud endpoints.
ClaudeGate is a lightweight, high-throughput, and secure local API gateway that bridges Anthropic's Messages API protocol (/v1/messages and /v1/messages/count_tokens) into standard OpenAI-compatible Chat Completions.
With ClaudeGate, developers can power Claude Code CLI, Cursor, and Anthropic SDK applications using:
BIG_MODEL, MIDDLE_MODEL, and SMALL_MODEL tiers or passes through direct model slugs.ClaudeGate in active operation, translating Claude Code CLI tool calls, bash commands, and streaming tokens in real-time:
โก ClaudeGate Proxy Gateway
|
๐ค Claude Code CLI in Action
|
content_block_start, content_block_delta, message_delta, message_stop). Mid-stream disconnects and upstream errors are caught gracefully without crashing Starlette/ASGI.503, 429, or timeout errors without dropping the active client session.SANITIZE_SECRETS=true).<thinking> Sanitizer: Cleanses internal reasoning tokens and <thinking> blocks from conversation history so multi-turn reasoning models (like DeepSeek R1/V4) never trigger 400 Bad Request errors on follow-up turns.timeout_keep_alive=600) to prevent Node.js ECONNRESET drops during prolonged user typing pauses.--setup), live connectivity diagnostic (--test), and 24+ instant preset switches (--preset <name>).hmac (Constant-time token authentication) and Regex Token Redaction EngineClaudeGate sits transparently between Claude Code CLI and your chosen AI model provider:
flowchart LR
A["Claude Code CLI\nor Anthropic SDK"] -- "POST /v1/messages\n(Anthropic Schema)" --> B["ClaudeGate Gateway\n(FastAPI / Port 8082)"]
subgraph CoreEngine ["ClaudeGate Core Engine"]
B --> C["Constant-Time Auth & IP Validator"]
C --> D["Request Sanitizer\n(PII & Credential Redaction)"]
D --> E["Protocol Converter\n(Tools, Messages, System Prompts)"]
E --> F["Upstream Client & Failover Controller"]
end
subgraph Upstream ["Upstream AI Providers"]
F -- "Primary Request" --> G["Primary Provider\n(OpenRouter / DeepSeek / Gemini)"]
F -. "Auto Failover on 503/429" .-> H["Backup Provider\n(Groq / Local Ollama)"]
end
G -- "OpenAI Chunk Stream" --> I["SSE Stream Adapter\n(Zero-Crash Generator)"]
H -- "OpenAI Chunk Stream" --> I
I -- "Anthropic SSE Events" --> A
ClaudeGate/
โโโ assets/ # Visual assets and screenshots
โ โโโ ClaudeGate.png # Project Banner & Logo
โ โโโ claude_terminal_ss.png # Claude Code CLI in action
โ โโโ proxy_terminal.png # ClaudeGate terminal proxy log
โโโ Dockerfile # Container image specification
โโโ docker-compose.yml # Container service configuration
โโโ requirements.txt # Python package dependencies
โโโ pyproject.toml # Modern package build configuration
โโโ setup.py # Legacy pip install compatibility
โโโ start_proxy.py # CLI & Server launcher script
โโโ .env.example # Comprehensive environment template
โโโ LICENSE # MIT License
โโโ SECURITY.md # Security policy & reporting guidelines
โโโ CODE_OF_CONDUCT.md # Community standard of conduct
โโโ CONTRIBUTING.md # Contribution guidelines
โโโ CHANGELOG.md # Version release history
โโโ README.md # Project documentation
โ
โโโ presets/ # Ready-to-use provider templates
โ โโโ openrouter.env # OpenRouter (Claude Opus 5, Sonnet 5, Haiku 4.5)
โ โโโ groq.env # Groq (DeepSeek V4-Pro, Llama 4 Maverick, Muse Glimmer)
โ โโโ ollama.env # Ollama (100% Local DeepSeek V4-Pro, Qwen3.6-35B, Muse Glimmer)
โ โโโ deepseek.env # DeepSeek (DeepSeek V4-Pro & V4-Flash)
โ โโโ gemini.env # Google Gemini (Gemini 3.1 Pro, 3.7 Flash & 3.5 Flash-Lite)
โ โโโ openai.env # OpenAI Official (GPT-5.6 Sol, GPT-5.6 Terra, GPT-5.6 Luna)
โ โโโ kimi.env # Moonshot AI (Kimi K3 2.8T Reasoning & K2.7 Code)
โ โโโ qwen.env # Alibaba Qwen / DashScope (Qwen3.8-Max, Qwen3.7-Plus, Qwen3.8-27B)
โ โโโ mistral.env # Mistral AI (Mistral Large 3, Mistral Medium 3.5, Mistral Small 4)
โ โโโ perplexity.env # Perplexity (Sonar Reasoning Pro, Sonar Pro & Sonar)
โ โโโ cohere.env # Cohere (Command A+, Command A & Command R7B)
โ โโโ minimax.env # MiniMax (MiniMax M3 Frontier & MiniMax M2.7)
โ โโโ meta.env # Meta AI (Muse Spark 1.2, Llama 4 Maverick, Muse Glimmer)
โ โโโ zai.env # Z.ai / Zhipu GLM (GLM-5.3 Flagship, GLM-5-Turbo, GLM-4.7-Flash)
โ โโโ together.env # Together AI (DeepSeek V4-Pro, DeepSeek V4-Flash, Qwen3.8-27B)
โ โโโ fireworks.env # Fireworks AI (DeepSeek V4-Pro, DeepSeek V4-Flash, Qwen3.8-27B)
โ โโโ cerebras.env # Cerebras (DeepSeek V4-Pro, Llama 4 Maverick, Muse Glimmer)
โ โโโ sambanova.env # SambaNova Cloud (DeepSeek V4-Pro, Llama 4 Maverick, Qwen3.8-27B)
โ โโโ siliconflow.env # SiliconFlow (DeepSeek V4-Pro, DeepSeek V4-Flash, Qwen3.8-27B)
โ โโโ lmstudio.env # LM Studio Desktop (DeepSeek V4-Pro & Muse Glimmer)
โ โโโ vllm.env # vLLM Self-Hosted GPU (DeepSeek V4-Pro & Qwen3.6-35B)
โ โโโ azure.env # Azure OpenAI Service (o1 & GPT-5.6 Enterprise Deployments)
โ โโโ kiro.env # AWS Amazon Q Developer / Claude Opus 5 Bridge
โ โโโ ox.env # Stealth Ox Alpha (Frontier Reasoning Model)
โ โโโ nemotron.env # Nvidia Nemotron Free Tier
โ
โโโ scripts/ # Verification & test utilities
โ โโโ verify_failover.py # Automated failover simulation runner
โ โโโ test_live_nemotron_ox.py # Live dual-model probe (Nemotron & Ox Alpha)
โ
โโโ src/ # Source code
โโโ main.py # FastAPI app & Uvicorn lifecycle
โโโ cli.py # CLI commands, setup wizard & test runner
โโโ api/
โ โโโ endpoints.py # /v1/messages, /health & /count_tokens routes
โโโ conversion/
โ โโโ request_converter.py # Anthropic -> OpenAI message & tool parsing
โ โโโ response_converter.py # OpenAI stream -> Anthropic SSE translation
โโโ core/
โ โโโ client.py # Async client with failover & retry logic
โ โโโ config.py # Dynamic environment loader & constant-time auth
โ โโโ constants.py # Anthropic & OpenAI protocol constants
โ โโโ logging.py # Structured logging configuration
โ โโโ model_manager.py # Intelligent model tier & slug router
โโโ models/
โ โโโ claude.py # Pydantic schemas for Anthropic API
โ โโโ openai.py # Pydantic schemas for OpenAI API
โโโ security/
โโโ sanitizer.py # Secret, AWS key, and PAT redaction engine
git clone https://github.com/Santosh-Prasad-Verma/ClaudeGate.git
cd ClaudeGate
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Launch the interactive configuration wizard:
python start_proxy.py --setup
Or load a ready-made preset directly:
python start_proxy.py --preset openrouter
You can configure Claude Code CLI to communicate with ClaudeGate using either Permanent or Session-Based configuration:
Edit (or create) ~/.claude/settings.json to automatically route all future claude commands to ClaudeGate:
{
"env": {
"ANTHROPIC_BASE_URL": "http://127.0.0.1:8082",
"ANTHROPIC_API_KEY": "sk-claudegate-local"
}
}
Export the variables in your active shell before launching Claude:
export ANTHROPIC_BASE_URL="http://127.0.0.1:8082"
export ANTHROPIC_API_KEY="sk-claudegate-local"
Run the built-in diagnostic test to verify your upstream provider connection and measure latency:
python start_proxy.py --test
Expected Output:
๐ Testing upstream connection...
Provider Base URL: https://openrouter.ai/api/v1
Test Model: stealth/ox-alpha
โ
Connection Successful! Model is active and responsive.
Status: 200 OK
You can also probe the gateway health endpoint directly from your terminal:
curl http://127.0.0.1:8082/health
# {"status":"healthy","service":"claudegate"}
Once setup is complete, your day-to-day workflow looks like this:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ TERMINAL 1: Start ClaudeGate Gateway Daemon โ
โ $ cd ClaudeGate && python start_proxy.py โ
โ [Gateway listening on http://127.0.0.1:8082 (OpenRouter/Groq/Ollama)] โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ (Translates Anthropic โท OpenAI protocol)
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ TERMINAL 2: Your Codebase Workspace (Run Claude Code) โ
โ $ cd /path/to/my-project โ
โ $ claude โ
โ โ
โ > "Add JWT authentication to src/auth.py and run the unit tests" โ
โ โ
โ Claude Code โโโโโโโบ ClaudeGate (8082) โโโโโโโบ DeepSeek R1 / Qwen / Groq โ
โ (CLI Tool Calls) (Translates schemas) (Executes inference & tools) โ
โ โโโโโโโโโโโโโโโโโโโ (Streams SSE Events) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โ
Claude Code automatically reads files, writes code, and runs bash tests! โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Start the Gateway (Terminal 1):
cd ClaudeGate
python start_proxy.py
ClaudeGate will boot up, display active model mappings, and listen on http://127.0.0.1:8082.
Open Your Coding Project (Terminal 2): Navigate to whatever software project or repo you want to work on:
cd ~/my-flutter-app # or any project directory
Launch Claude Code:
claude
You can now type natural language instructions as usual. Claude Code will execute file inspections, bash commands, multi-file edits, and git commits powered entirely by your chosen backend model!
Switching Models On The Fly: Want to swap from free cloud models (OpenRouter) to 100% private offline models (Ollama)? In Terminal 1:
python start_proxy.py --preset ollama
python start_proxy.py
Claude Code in Terminal 2 will immediately begin routing through local Ollama without needing a restart.
| Command | Purpose |
|---|---|
python start_proxy.py | Start the ClaudeGate server |
python start_proxy.py --test | Run live connectivity probe & measure upstream latency |
python start_proxy.py --setup | Launch interactive 24-provider setup wizard |
python start_proxy.py --preset <name> | Quick-load a preset (e.g. groq, gemini, ollama, deepseek) |
python start_proxy.py --help | View help and available options |
python start_proxy.py --version | Display current release version |
If you prefer to run ClaudeGate as a background Docker container:
# Build and start container in the background
docker compose up -d --build
# View real-time logs
docker compose logs -f
# Check container health status
docker ps
# Stop container
docker compose down
ClaudeGate includes built-in live diagnostics and automated test suites:
Test your active model and measure upstream response latency:
python start_proxy.py --test
Output:
๐ Testing upstream connection...
Provider Base URL: https://openrouter.ai/api/v1
Test Model: stealth/ox-alpha
โ
Connection Successful! Model is active and responsive.
Status: 200 OK
Simulate an upstream outage to test automatic failover:
python scripts/verify_failover.py
Run the full test suite covering non-streaming failover, SSE streaming, and endpoint security:
pytest tests/ -v
ClaudeGate implements defense-in-depth privacy controls to ensure secure self-hosting:
127.0.0.1): Restricts incoming traffic exclusively to the local machine.hmac.compare_digest to validate x-api-key headers, preventing side-channel timing analysis.SANITIZE_SECRETS="true", prompts are automatically scrubbed for sensitive tokens (GitHub PATs, AWS Access Keys, OpenAI Keys, Private SSH keys) before reaching upstream providers.Error Markers over Generator Exceptions:
HTTPException inside an active StreamingResponse async generator after HTTP headers (200 OK) are flushed causes a fatal RuntimeError: response already started and terminates the ASGI worker.ERROR::<status>::<message> tokens that the SSE converter catches and translates into standard Anthropic error events, keeping the worker process healthy.Multi-Turn <thinking> Cleansing:
400 Bad Request.request_converter automatically identifies and filters thinking and redacted_thinking content blocks before dispatching to upstream providers.Constant-Time Client Authentication:
key == expected) are susceptible to side-channel timing attacks.hmac.compare_digest across all header validation points.10-Minute TCP Keep-Alive (timeout_keep_alive=600):
ECONNRESET if an interactive user takes longer than 5 seconds between prompts.http://127.0.0.1:8082/dashboard) for live latency charts, token velocity, and cost tracking./run/user/$UID/claudegate.sock.We welcome bug fixes, documentation improvements, new provider presets, and feature additions!
presets/<provider_name>.env and submit a pull request!Distributed under the MIT License. See LICENSE for more information.
Built with โค๏ธ for the open-source & AI developer community.
Empowering developers to run Claude Code with any model, anywhere, completely unrestricted.
โญ If you find ClaudeGate useful, consider giving it a star on GitHub! โญ
18 commits
1 commits
Python
99.4%