Skip to content
Β 
Β 

Latest commit

Β 

History

1,846 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VansRouter Dashboard

VansRouter

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.

npm Downloads GHCR License: MIT

Quick Start β€’ Architecture β€’ Features β€’ Client Tools β€’ Configuration


πŸ’‘ Overview

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.)

πŸš€ Quick Start

Option 1: Global CLI (Recommended for Local Dev)

Requirements: Node.js >= 22.5.0

npm install -g vansrouter
vansrouter

The 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).

Option 2: Docker Container (Recommended for Servers)

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.Z

Save 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.

Option 3: Run from Source

git clone https://github.com/Vanszs/VansRouter.git
cd VansRouter
pnpm install
pnpm run build
pnpm run start

⚑ Features

1. Unified Multi-Modal Gateway

Exposes 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.

2. Lossless Protocol Translation

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.

3. Token & Context Optimization

  • 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.

4. Multi-Account Rotation & Failover

  • 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.

5. Multi-Tenant Access Control (ACL)

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 llm and web, deny image or tts).

πŸ› οΈ Client Tools Setup

Configure your favorite AI agent by pointing its base URL to VansRouter:

OpenCode

{
  "provider": {
    "vansrouter": {
      "name": "VansRouter",
      "api": "http://localhost:20128/v1"
      "type": "openai",
      "key": "your-vansrouter-api-key"
    }
  }
}

Claude Code CLI

export ANTHROPIC_BASE_URL="http://localhost:20128"
export ANTHROPIC_API_KEY="your-vansrouter-api-key"
claude

Cursor IDE

  1. Open Cursor Settings β†’ Models β†’ OpenAI API Key.
  2. Set Base URL: http://localhost:20128/v1
  3. Enter your VansRouter API key.
  4. Add desired model names (e.g., claude-sonnet-4.5, gpt-5.4, deepseek-v4-flash).

Codex CLI

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"

βš™οΈ Configuration

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.

πŸ“„ License

This project is licensed under the MIT License.

About

πŸ†“ Lightweight Version of 9Route x Omniroute Combined Logic - Unlimited FREE AI coding. Connect Claude Code, Codex, Cursor, Cline, Copilot, Antigravity to FREE Claude/GPT/Gemini via 40+ providers. Auto-fallback, RTK -40% tokens, never hit limits.

Topics

Resources

Stars

274 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages