CliRelay is a free, open source api development & testing project written in Go and released under MIT. It has 1,011 GitHub stars, 121 forks and 13 open issues, and was last pushed 21 hours ago. On this registry it ranks #120 of 154 tracked projects in API Development & Testing, with 5 head-to-head comparisons available.

Go License Stars Forks

🔀 CliRelay

A unified proxy server for AI CLI tools — use your existing subscriptions with any OpenAI / Gemini / Claude / Codex compatible client.

Multi-tenant web panel · request logs & quotas · routing groups & failover · self-hosted

English | 中文

📖 Docs · 🖥️ Management Panel · 🐛 Report Bug · ✨ Request Feature


⚡ What is CliRelay?

✨ Heavily enhanced fork of the CLIProxyAPI project — rebuilt with a production-grade management layer, web control panel hosting, and a terminal TUI for day-2 operations.

CliRelay turns AI CLI subscriptions, OAuth credentials, API keys, and compatible upstream services into one managed API layer. It proxies Claude Code, Gemini CLI, OpenAI Codex, Qwen, iFlow, Kimi, Antigravity, xAI/Grok, OpenCode Go, ClinePass, Ollama Cloud, Bedrock, Amp, Vertex, OpenAI-compatible clients, and other AI coding tools through a unified endpoint, then adds routing groups, failover, request logging, quota control, model pricing, image-generation support, content moderation, online updates, /manage web hosting, and terminal management workflows around that traffic.

It is built to be operated by more than one person. Tenants, users, roles, and a fine-grained permission model (governance.tenants, models.write, providers.test, …) decide which pages, buttons, and actions each account gets, and every security-sensitive change lands in an audit log. Portal accounts let end users hold several API keys under one identity and check their own usage without an admin in the loop.

The current runtime data stack is PostgreSQL 15+, Redis 7+, and Ent ORM. PostgreSQL is the source of truth for runtime data; Redis is used for cache, locks, limits, queues, and rebuildable state.

┌───────────────────────┐         ┌──────────────┐         ┌────────────────────┐
│   AI Coding Tools     │         │              │         │  Upstream Providers │
│                       │         │              │ ──────▶ │  Google Gemini      │
│  Claude Code          │ ──────▶ │   CliRelay   │ ──────▶ │  OpenAI / Codex    │
│  Gemini CLI           │         │   :8317      │ ──────▶ │  Anthropic Claude  │
│  OpenAI Codex         │         │              │ ──────▶ │  Qwen / iFlow      │
│  Amp CLI / IDE        │         │              │ ──────▶ │  Antigravity/xAI   │
│  Any OAI-compatible   │         └──────────────┘         │  Vertex / Bedrock  │
└───────────────────────┘                                  │  OpenCode/Cline    │
                                                           │  Ollama / Amp      │
                                                           └────────────────────┘

✨ Key Features

🔌 Multi-Provider Proxy Engine

Feature Description
🌐 Unified Endpoint One http://localhost:8317 fronts Gemini, Claude, Codex, Qwen, iFlow, Kimi, Antigravity, xAI/Grok, Vertex, Bedrock, OpenCode Go, ClinePass, Ollama Cloud, OpenAI-compatible upstreams, and Amp integration
⚖️ Smart Load Balancing Round-robin or fill-first scheduling across multiple API keys for the same provider
🧭 Group & Path Routing Bind channels into groups, restrict API keys to allowed groups, and expose custom path namespaces for teams or workloads
🔄 Auto Failover Automatically switches to backup channels when quotas are exhausted or errors occur
🧠 Multimodal Support Full support for text + image inputs, image-generation routing, function calling (tools), and streaming SSE responses
🔗 OpenAI-Compatible Works with any upstream that speaks the OpenAI Chat Completions protocol

📊 Request Logging & Monitoring (PostgreSQL)

Feature Description
📝 Full Request Capture Every API request is logged to PostgreSQL with timestamp, model, tokens (in/out/reasoning/cache), latency, status, and source channel
💬 Message Body Storage Full request/response message content captured in compressed PostgreSQL storage, with separate retention for content vs. metadata
🔍 Advanced Querying Filter logs by API Key, model, status, time range with efficient pagination (LIMIT/OFFSET)
📈 Analytics Aggregation Pre-computed dashboards: daily trends, model distribution, hourly heatmaps, per-key statistics
🏥 Health Score Engine Real-time 0–100 health score considering success rate, latency, active channels, and error patterns
📡 WebSocket Monitoring Live system stats streamed via WebSocket: CPU, memory, goroutines, network I/O, DB size
🗄️ Ent + PostgreSQL Uses PostgreSQL 15+ as the runtime primary database with Ent-generated schema metadata

🏛️ Multi-Tenancy & Governance

Feature Description
🏢 Tenant Lifecycle Create tenants and manage their lease periods; runtime data is scoped by tenant end to end
👤 User Management Manage the accounts inside the active tenant, with password policy and reset flows
🎭 Role Permissions Fine-grained resource.action permissions (governance.tenants, models.write, providers.test, …) decide which pages, buttons, and actions an account can reach
🧾 Audit Logs Security-sensitive account and tenant changes are recorded and reviewable in the panel
🧭 Menu Management Curate which navigation entries a tenant sees, keeping menus aligned with granted permissions

🔐 API Key & Portal Accounts

Feature Description
🔑 API Key CRUD Create, edit, delete API keys via Management API — each with custom name, notes, and independent enable/disable toggle
🧑‍💼 Portal Accounts Group several API keys under one end-user account, so a person is managed once instead of key by key
📊 Per-Key Quotas Set max token / request quotas per key with automatic enforcement
🔁 Period Quota Resets Reset spending quotas for a chosen period, for a whole account or a single owned key
⏱️ Rate Limiting Per-key rate limiting (requests per minute/hour)
🧩 Permission Profiles Reusable profiles bind scoped channel access and model permissions to keys
🔒 Key Masking API keys are always displayed masked (sk-***xxx) in UI and logs
🌍 Public Lookup Page End users can query their own usage stats and request logs via a public self-service page (no login required)

🔗 Provider Channel Management

Feature Description
📋 Multi-Tab Config Manage channels organized by provider type: Gemini, Claude, Codex, OpenCode Go, ClinePass, Ollama Cloud, Vertex, Bedrock, OpenAI Compatible, and Ampcode
🏷️ Channel Naming Each channel can have a custom name, notes, proxy URL, custom headers, and model alias mappings
🧩 Reusable Proxy Pool Maintain outbound proxy entries once and attach them to OAuth/auth channels when needed
⏱️ Latency Tracking Average latency (latency_ms) tracked per channel with visual indicators
🔄 Enable/Disable Individually toggle channels on/off without deletion
🚫 Model Exclusions Exclude specific models from a channel (e.g., block expensive models on backup keys)
🧾 Model Library Sync Maintain custom models and sync model IDs/pricing from OpenRouter for quota accounting
📊 Channel Stats Per-channel success/fail counts and model availability displayed on each channel card

🛡️ Security & Authentication

Feature Description
🔐 OAuth Support Native OAuth flows for Gemini, Claude, Codex, Qwen, iFlow, Antigravity, Kimi, and xAI/Grok, plus device/browser/cookie variants where supported
🪪 Identity Fingerprints Centralize upstream identity metadata so providers receive consistent client fingerprints
🧹 Content Moderation Build reusable moderation profiles, test them against sample content, and bind them

readme truncated — read the full docs on github

Frequently asked questions

Is CliRelay free to use?

CliRelay is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does CliRelay do?

Self-hosted AI gateway for coding CLIs — one OpenAI/Claude/Gemini/Codex-compatible endpoint, with a multi-tenant web console, request logs, and spend quotas.

What is CliRelay written in?

CliRelay is primarily written in Go. Its source is publicly available at https://github.com/kittors/CliRelay, and it has 1,011 GitHub stars.