Skip to content

codeking-ai/cligate

Repository files navigation

CliGate

CliGate Dashboard

AGPL-3.0 License Node.js Version npm Version GitHub stars

English | 中文

A multi-protocol AI API proxy server with account pooling, API key management, and a visual dashboard. Use Claude Code, Codex CLI, Gemini CLI, and OpenClaw through a unified local proxy — with multi-account rotation, intelligent routing, free model routing, usage analytics, and one-click configuration.


Features

Multi-CLI Proxy Support

  • Claude Code — Proxies Anthropic Messages API (/v1/messages) with streaming
  • Codex CLI — Proxies OpenAI Responses API (/v1/responses), Chat Completions (/v1/chat/completions), and Codex Internal API (/backend-api/codex/responses)
  • Gemini CLI — Proxies Gemini API (/v1beta/models/*) with one-click patch
  • OpenClaw — Custom provider injection via anthropic-messages or openai-completions

Account & Key Management

  • ChatGPT Account Pool — OAuth login, multi-account rotation (sticky / round-robin / random), auto token refresh, per-account quota tracking
  • Claude Account Pool — OAuth PKCE login, token refresh with source writeback to Claude Code credentials
  • Antigravity Account Pool — Google OAuth login for enterprise models, automatic model discovery and project management
  • API Key Pool — Support for OpenAI, Azure OpenAI, Anthropic, Google Gemini, Vertex AI, MiniMax, Moonshot, ZhipuAI keys with automatic failover and load balancing
  • Key Validation — One-click connectivity test for each API key
  • Smart Token Refresh — Only refreshes when tokens are about to expire (< 5 min), syncs back to source CLI tools

Intelligent Routing

  • Priority Mode — Choose between Account Pool First or API Key First when both are available
  • Routing Mode — Automatic routing or manual per-app credential assignments
  • App Routing — Bind each app (Claude Code, Codex, Gemini CLI, OpenClaw) to a specific ChatGPT account, Claude account, or API key
  • Model Mapping — Customize which upstream model each provider resolves to
  • Free Model Routing — Routes claude-haiku requests to free models (DeepSeek, Qwen, MiniMax, etc.) via Kilo AI — no API key needed

Analytics & Monitoring

  • Usage & Costs — Per-account, per-model, per-provider usage and cost statistics with daily/monthly breakdown
  • Request Logs — Full request/response logging with date and provider filtering, error-only view
  • Real-time Log Stream — Live SSE log stream for debugging
  • Pricing Registry — View and customize per-provider, per-model pricing with manual overrides

Web Dashboard

  • Dashboard — Quick status metrics (total/available accounts, expired tokens, default plan), quick test buttons, Claude Code usage example
  • Chat UI — Interactive chat interface with source selector (ChatGPT, Claude, API keys), model selection, system prompt, and chat history
  • Account Management — Tabbed interface for ChatGPT, Claude, and Antigravity accounts with add/remove/enable/disable/switch
  • API Key Management — Add, test, edit, disable API keys with provider-specific fields (Azure deployment name/API version, Vertex project ID/location)
  • Tool Installer — Detect and install/update Node.js, Claude Code, Codex CLI, Gemini CLI, OpenClaw — auto-detects OS, shows version status, checks for updates
  • Resources Catalog — Curated directory of free and trial LLM API resources with provider details, limits, and compatibility info
  • One-click CLI Configuration — Configure Claude Code, Codex CLI, Gemini CLI, OpenClaw with a single button
  • i18n — English and Chinese interface
  • Dark/Light Theme — Toggle between dark and light mode

Screenshots

Dashboard Chat UI
Dashboard Chat
Account Management API Key Management
Accounts API Keys
Settings & App Routing Usage & Costs
Settings Usage
Request Logs Pricing Registry
Request Logs Pricing
Tool Installer Resources Catalog
Tool Installer Resources

Demo

Demo


Architecture

┌─────────────┐  ┌───────────┐  ┌────────────┐  ┌──────────┐
│ Claude Code │  │ Codex CLI │  │ Gemini CLI │  │ OpenClaw │
└──────┬──────┘  └─────┬─────┘  └──────┬─────┘  └────┬─────┘
       │               │               │              │
       └───────────────┼───────────────┼──────────────┘
                       ▼
            ┌─────────────────────┐
            │   CliGate     │
            │   localhost:8081    │
            │                     │
            │  ┌───────────────┐  │
            │  │ Protocol      │  │
            │  │ Translation   │  │
            │  └───────┬───────┘  │
            │          │          │
            │  ┌───────▼───────┐  │
            │  │ Account Pool  │  │
            │  │ & Key Router  │  │
            │  └───────┬───────┘  │
            └──────────┼──────────┘
                       │
       ┌───────┬───────┼───────┬───────┐
       ▼       ▼       ▼       ▼       ▼
┌────────┐┌────────┐┌────────┐┌────────┐┌────────┐
│Anthropic││ OpenAI ││Google  ││Vertex  ││Kilo AI │
│  API   ││  API   ││Gemini  ││  AI    ││ (Free) │
└────────┘└────────┘└────────┘└────────┘└────────┘

Quick Start

Option 1: npx (No install)

npx cligate@latest start

Option 2: Global install

npm install -g cligate
cligate start

Option 3: Desktop App (Electron)

Download the latest release from Releases.


Setup

1. Start the server

cligate start

Dashboard opens at http://localhost:8081

2. Add accounts or API keys

Web Dashboard (recommended):

  1. Open http://localhost:8081Accounts tab
  2. Click Add Account → Login with ChatGPT / Claude / Google (Antigravity)
  3. Or go to API Keys tab → Add API Key with your OpenAI, Azure, Gemini, Vertex AI, or other provider keys
  4. Accounts are automatically saved and tokens are auto-refreshed

CLI:

cligate accounts add            # Opens browser
cligate accounts add --no-browser  # Headless/VM

3. Configure your CLI tool

Click the one-click configure button in the Dashboard or Settings tab, or manually:

Claude Code:

export ANTHROPIC_BASE_URL=http://localhost:8081
export ANTHROPIC_API_KEY=any-key
claude

Codex CLI:

# ~/.codex/config.toml
chatgpt_base_url = "http://localhost:8081/backend-api/"
openai_base_url = "http://localhost:8081"

Gemini CLI: Use the one-click patch button in the dashboard.

OpenClaw: Use the one-click configure button, or add manually to ~/.openclaw/openclaw.json:

{
  "models": {
    "providers": {
      "proxypool": {
        "baseUrl": "http://localhost:8081",
        "apiKey": "sk-ant-proxy",
        "api": "anthropic-messages"
      }
    }
  }
}

4. Configure routing (optional)

In the Settings tab:

  • Priority Mode — Choose "Account Pool First" or "API Key First"
  • Routing Mode — "Automatic" for smart routing, or "App Assigned" to bind each app to a specific credential
  • App Assignments — Bind Claude Code, Codex, Gemini CLI, or OpenClaw to a specific account or API key

Model Mapping

Requested Model Routed To Auth Required
claude-sonnet-4-6 GPT-5.2 Codex / Anthropic API Yes
claude-opus-4-6 GPT-5.3 Codex / Anthropic API Yes
claude-haiku-4-5 Free model via Kilo AI No

The haiku model can be changed to any free model (DeepSeek R1, Qwen3, MiniMax, etc.) from the Settings tab.


API Endpoints

Endpoint Protocol Used By
POST /v1/messages Anthropic Messages Claude Code, OpenClaw
POST /v1/chat/completions OpenAI Chat Completions Codex CLI, OpenClaw
POST /v1/responses OpenAI Responses Codex CLI
POST /backend-api/codex/responses Codex Internal Codex CLI
POST /v1beta/models/* Gemini API Gemini CLI
GET /v1/models OpenAI Models All
GET /health Health Check Monitoring

See API Documentation for the full reference.


Security & Privacy

  • 100% Local — Runs entirely on localhost, no external server involved
  • Direct Connection — Connects directly to official APIs (OpenAI, Anthropic, Google), no third-party relay
  • No Telemetry — Zero data collection, zero tracking
  • Token Safety — Credentials stored locally with 0600 permissions, smart refresh avoids unnecessary token rotation
  • Source Writeback — When tokens are refreshed for imported accounts, they are synced back to the source CLI tool so it keeps working

Community

  • GitHub Discussions — Ask questions, share ideas, report issues

  • Discord — Real-time chat with the community

  • WeChat — Scan to add the author, note "CliGate" to join the group

    WeChat

Support

If this project helps you, consider supporting its development:

Sponsor


License

This project is licensed under AGPL-3.0.

Disclaimer

This project is an independent open-source tool. It is not affiliated with, endorsed by, or sponsored by Anthropic, OpenAI, or Google. All trademarks belong to their respective owners. Use responsibly and in accordance with applicable Terms of Service.


Built for developers who use multiple AI coding assistants.
Star on GitHub