# ClaudeGate

> A high-performance local API gateway that bridges Claude Code CLI and Anthropic SDKs to any OpenAI-compatible LLM provider, with zero-crash streaming, multi-provider failover, and PII redaction.

ClaudeGate is an open-source local proxy gateway built in Python that lets developers use Claude Code CLI and Anthropic SDK applications with any OpenAI-compatible AI model provider. It was created by Santosh-Prasad-Verma and released under the MIT License, with its first stable release (v1.0.0) published in August 2026. The project sits transparently between Claude Code CLI and upstream AI providers, translating Anthropic's Messages API protocol into standard OpenAI Chat Completions format.

## What It Is

ClaudeGate is a protocol translation layer — a FastAPI-based ASGI server that runs locally on port 8082 and intercepts requests from Claude Code CLI or any Anthropic SDK application. It converts the Anthropic `/v1/messages` schema into OpenAI-compatible Chat Completions requests, then translates the responses back into Anthropic Server-Sent Events. This allows developers to power Claude Code with models from 24+ provider presets including OpenRouter, DeepSeek, Google Gemini, Groq, Ollama, LM Studio, vLLM, Azure OpenAI, and more — without modifying the Claude Code CLI itself.

## Architecture and Protocol Translation

ClaudeGate's core engine processes requests through a pipeline of components:

- **Constant-Time Auth & IP Validator**: Validates `x-api-key` headers using `hmac.compare_digest` to prevent timing attacks, and restricts traffic to localhost by default.
- **Request Sanitizer**: Scrubs outgoing prompts for AWS keys, GitHub PATs, OpenAI tokens, and SSH private keys when `SANITIZE_SECRETS=true`.
- **Protocol Converter**: Handles bidirectional translation of tools, messages, system prompts, and function calls between Anthropic and OpenAI schemas.
- **Upstream Client & Failover Controller**: Manages async HTTP connections with automatic failover across primary and backup providers on `503`, `429`, or timeout errors.
- **SSE Stream Adapter**: Translates raw OpenAI chunk streams into Anthropic SSE events (`content_block_start`, `content_block_delta`, `message_delta`, `message_stop`) without crashing the ASGI worker.

A key engineering decision is yielding formatted `ERROR::<status>::<message>` tokens inside the streaming generator rather than raising `HTTPException` after HTTP headers are flushed, which would cause a fatal `RuntimeError: response already started`.

## Provider Support and Model Routing

ClaudeGate ships with 24+ ready-to-use provider preset `.env` files covering:

- **Free/cloud providers**: OpenRouter, Groq, DeepSeek, Google Gemini, OpenAI, Moonshot Kimi, Alibaba Qwen, Mistral, Perplexity, Cohere, MiniMax, Meta, Z.ai GLM, Together AI, Fireworks AI, Cerebras, SambaNova, SiliconFlow, Nvidia Nemotron, Stealth Ox Alpha
- **100% local/offline**: Ollama, LM Studio, vLLM (zero data leaves the machine)
- **Enterprise**: Azure OpenAI Service, AWS Amazon Q (via Kiro Bridge)

The model manager intelligently routes all Claude version slugs (Claude 3.5, 3.7, 4.x, 4.5, 5.x) to configurable `BIG_MODEL`, `MIDDLE_MODEL`, and `SMALL_MODEL` tiers, or passes through direct model slugs.

## Setup Path

Installation requires Python 3.9+ and follows a four-step process: clone the repository, create a virtual environment and install dependencies from `requirements.txt`, run the interactive setup wizard (`python start_proxy.py --setup`) or load a preset directly (`--preset openrouter`), then configure Claude Code CLI to point to `http://127.0.0.1:8082`. Docker and Docker Compose support is also included for running ClaudeGate as a background daemon with health-check monitoring. The built-in `--test` command probes upstream connectivity and measures latency before use.

## Update: v1.0.0 — Universal LLM Gateway & Bridge for Claude Code CLI

The first stable release (v1.0.0) was published on August 25, 2026. The repository was created on August 23, 2026, and last updated August 25, 2026, indicating this is a very recently launched project. The roadmap lists planned features including a real-time web dashboard at `/dashboard` for latency charts and token velocity, SQLite-backed prompt caching for deduplication, a dynamic complexity router for automatic task-difficulty classification, and Unix Domain Socket support for zero-network communication.

## Features
- Zero-crash SSE streaming with Anthropic event translation
- Automatic multi-provider failover on 503/429/timeout errors
- PII and secret sanitizer for AWS keys, GitHub PATs, SSH keys, OpenAI tokens
- Full bidirectional tool/function calling translation
- Chain-of-thought and <thinking> block sanitizer for multi-turn reasoning models
- 24+ provider presets including OpenRouter, DeepSeek, Gemini, Ollama, Azure
- Interactive CLI setup wizard with --setup, --test, --preset commands
- Intelligent model tier routing (BIG_MODEL, MIDDLE_MODEL, SMALL_MODEL)
- Docker and Docker Compose support with health-check monitoring
- Constant-time authentication using hmac.compare_digest
- Extended 10-minute TCP keep-alive to prevent ECONNRESET drops
- 100% local/offline model support via Ollama, LM Studio, vLLM
- Enterprise provider support: Azure OpenAI, AWS Amazon Q via Kiro Bridge
- Localhost-only default binding for security
- Automated failover simulation and pytest test suite

## Integrations
Claude Code CLI, Anthropic SDK, OpenRouter, DeepSeek, Google Gemini, OpenAI, Groq, Ollama, LM Studio, vLLM, Azure OpenAI Service, AWS Amazon Q, Moonshot Kimi, Alibaba Qwen / DashScope, Mistral AI, Perplexity, Cohere, MiniMax, Meta AI, Z.ai GLM, Together AI, Fireworks AI, Cerebras, SambaNova, SiliconFlow, Nvidia Nemotron, Docker, FastAPI, Uvicorn, Pydantic v2, httpx, openai-python

## Platforms
WINDOWS, MACOS, LINUX, WEB, API, CLI

## Pricing
Open Source

## Version
v1.0.0

## Links
- Website: https://github.com/Santosh-Prasad-Verma/ClaudeGate
- Documentation: https://github.com/Santosh-Prasad-Verma/ClaudeGate#readme
- Repository: https://github.com/Santosh-Prasad-Verma/ClaudeGate
- EveryDev.ai: https://www.everydev.ai/tools/claudegate
