Universal AI API Gateway, Protocol Translator & Token Optimization Proxy
Connect any AI developer tool or client (Claude Code, Cursor, OpenCode, Codex, Cline, Kilo, etc.) to 150+ AI providers through a unified OpenAI-compatible endpoint.
Quick Start β’ Architecture β’ Features β’ Client Tools β’ Configuration
VansRouter sits between your AI coding tools and upstream model providers. It acts as an intelligent proxy that handles protocol translation, credential rotation, token compression, and multi-tier failover.
Client (OpenAI / Claude format)
β
βΌ
POST /v1/*
β
βββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββ
β VansRouter β
β β
β 1. Auth & ACL (Verify API key, check ACL) β
β 2. Token Saver (RTK context compression) β
β 3. Model Routing (Direct, Combo, or Failover) β
β 4. Translation (OpenAI β Claude β Gemini) β
β 5. Circuit Breaker (Proxy & Account Health) β
βββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
Upstream Provider (Anthropic, OpenAI, Meta, Google, DeepSeek, etc.)
Requirements: Node.js >= 22.5.0
npm install -g vansrouter
vansrouterThe Web Dashboard will launch at http://localhost:20128/masuk.
(On macOS without NVM, run sudo npm install -g vansrouter --prefer-online if your global node_modules directory requires root permissions).
docker run -d \
--name vansrouter \
-p 20128:20128 \
-v 9router-data:/app/data \
-e INITIAL_PASSWORD="$(openssl rand -base64 24)" \
--restart always \
ghcr.io/vanszs/vansrouter:X.Y.ZSave the generated INITIAL_PASSWORD securely. If you omit INITIAL_PASSWORD, a new installation uses the compatibility default 123456; change it before public exposure. Open http://localhost:20128/masuk and log in.
git clone https://github.com/Vanszs/VansRouter.git
cd VansRouter
pnpm install
pnpm run build
pnpm run startExposes a single OpenAI-compatible /v1 endpoint supporting:
- Chat & Reasoning: OpenAI Chat, Anthropic Claude Messages, OpenAI Responses, and Google Gemini formats.
- Vision & Document OCR: Multimodal image-to-text understanding and document parsing (
imageToText). - Image Generation: DALL-E, FLUX, Imagen, Muse Image, and custom diffusion endpoints (
/v1/images/generations). - Speech & Audio: Real-time Text-to-Speech (
/v1/audio/speech) and Audio Transcription / STT (/v1/audio/transcriptions). - Text Embeddings: Vector embedding models across OpenAI, Qwen, Perplexity, and custom self-hosted nodes (
/v1/embeddings). - Web Search: Built-in unauthenticated local SearXNG search or provider-backed search integration.
Send standard OpenAI requests to Anthropic Claude or Google Gemini models, or vice versa, without rewriting your client code. VansRouter handles tool-call schema conversion, stream chunk demuxing, thinking tags (<think>), and token estimation automatically.
-
RTK (Real-Time Compression): Analyzes and trims repetitive tool outputs (
git diff,grep, directory trees, test logs) within context history, reducing payload sizes on long sessions. - Caveman Mode: Injects concise communication prompts to reduce verbose assistant replies.
- Ponytail Mode: Enforces lazy-senior-developer principles to minimize unnecessary boilerplate generation.
-
LoopGuard Protection: Protects against model reasoning and tool-calling loops with
$O(K)$ bounded sliding window checks, preventing event-loop stalls on 1,000+ message histories.
- Combo Routing: Combine multiple providers under a single virtual model name with customizable fallback strategies (Priority Fallback, Round-Robin, Fusion Judge, and Capacity Auto-Switch).
- Circuit Breakers: Tracks consecutive upstream failures and temporary 429 rate limits, automatically routing traffic to healthy standby accounts or proxy pools.
- Proxy Pool Integration: Bind specific providers or accounts to SOCKS5/HTTP proxy pools with health scoring.
Issue scoped API keys with granular permissions:
- Restrict keys to specific Providers (e.g. only Claude and DeepSeek).
- Restrict keys to specific Combos or Models.
- Restrict keys to specific Service Kinds (e.g., allow
llmandweb, denyimageortts).
Configure your favorite AI agent by pointing its base URL to VansRouter:
{
"provider": {
"vansrouter": {
"name": "VansRouter",
"api": "http://localhost:20128/v1"
"type": "openai",
"key": "your-vansrouter-api-key"
}
}
}export ANTHROPIC_BASE_URL="http://localhost:20128"
export ANTHROPIC_API_KEY="your-vansrouter-api-key"
claude- Open Cursor Settings β Models β OpenAI API Key.
- Set Base URL:
http://localhost:20128/v1 - Enter your VansRouter API key.
- Add desired model names (e.g.,
claude-sonnet-4.5,gpt-5.4,deepseek-v4-flash).
In ~/.codex/config.toml:
model = "claude-sonnet-4.5"
model_provider = "openai-chat-completions"
[model_providers.openai-chat-completions]
base_url = "http://localhost:20128/v1"
env_key = "VANSROUTER_API_KEY"VansRouter is configured via environment variables:
| Variable | Default | Description |
|---|---|---|
PORT |
20128 (or 3003) |
Port to listen on. |
HOSTNAME |
0.0.0.0 |
Bind host address. |
DATA_DIR |
~/.9router (macOS/Linux) or %APPDATA%\9router (Windows) |
Root directory for persistent SQLite database and backups. |
REQUIRE_API_KEY |
false |
Enforce valid Bearer API key on all /v1/* routes. |
JWT_SECRET |
Auto-generated | Secret for signing dashboard session cookies. |
INITIAL_PASSWORD |
123456 for a new installation |
Initial dashboard password; set a strong value before public exposure. |
HTTP_PROXY, HTTPS_PROXY |
"" |
Outbound proxy for upstream provider requests. |
SEARXNG_URL |
http://127.0.0.1:8888/search |
Endpoint for the local SearXNG search provider. |
GROK_CLI_VERSION |
1.0.44 |
Grok CLI version advertised to cli-chat-proxy.grok.com. The upstream answers 426 Upgrade Required below its minimum (1.0.13); raise this to clear a future gate without a code change. Read at startup β restart to apply. |
This project is licensed under the MIT License.