CliRelay
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?
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.
Overview of CliRelay
What it is
CliRelay is a self-hosted AI gateway for coding CLIs. It provides a single OpenAI/Claude/Gemini/Codex-compatible endpoint that routes requests from tools like Claude Code, Codex CLI, and Gemini CLI to upstream AI accounts or provider API keys. It includes a multi-tenant web console for managing accounts, viewing request logs, and setting spend quotas. It is a heavily extended fork of CLIProxyAPI, rebuilt with a production management layer, a web control panel, and day-2 operations. PostgreSQL 15+ is the source of truth for runtime data, and Redis 7+ holds caches, locks, rate limits, queues, and other rebuildable state.
Key features
- One endpoint supporting multiple providers: Claude, Codex, Gemini CLI, Antigravity, Vertex, Bedrock, xAI/Grok, Qwen, Kimi, iFlow, OpenCode Go, ClinePass, Ollama Cloud, and any OpenAI-compatible upstream, speaking OpenAI Chat/Responses, Anthropic Messages, and Gemini protocols.
- Routing with channel groups, custom paths, round-robin/fill-first/session-sticky scheduling, cooldowns, and automatic failover to healthy accounts.
- Observability: a monitor center with health score, per-minute live traffic, P50–P99 latency, time to first token, failure analysis, portal user → model → channel traffic flow, and a searchable request log with tokens, latency, and cost.
- Spend control: client keys grouped under portal accounts, reusable permission profiles, daily/period/lifetime quotas, RPM and TPM limits, per-model pricing, and one-click period resets.
- Multi-tenant architecture: tenants, users, roles, resource.action permissions, a curated menu per tenant, and an audit trail for security-sensitive changes.
- Web control panel at /manage for adding accounts via guided sign-in or credential import, editing config visually, managing models and pricing, and checking for updates, available in English, Simplified Chinese, and Russian.
Use cases
- Teams that want to share a single AI gateway for coding CLIs while keeping tenant accounts, keys, and data separate.
- Organizations that need to monitor and control spending on AI coding tools across multiple users and projects.
- Developers who want to route requests from multiple AI coding CLIs through a single endpoint with automatic failover and protocol translation.
Getting started
See the repository README for installation and quick-start instructions.
License and pricing
License: MIT. Pricing: open source.
這是什麼
CliRelay 是一個自託管的 AI 閘道,專為程式碼 CLI 工具設計。它提供一個統一的 OpenAI/Claude/Gemini/Codex 相容端點,將來自 Claude Code、Codex CLI、Gemini CLI 等工具的請求路由到上游的 AI 帳戶或提供者 API 金鑰。它包含一個多租戶的網頁控制台,用於管理帳戶、檢視請求日誌以及設定花費配額。它是 CLIProxyAPI 的一個大幅擴展分支,重新建構了生產管理層、網頁控制面板和營運功能。PostgreSQL 15+ 是執行時期資料的真實來源,Redis 7+ 則負責快取、鎖定、速率限制、佇列和其他可重建的狀態。
主要功能
- 單一端點支援多個提供者:Claude、Codex、Gemini CLI、Antigravity、Vertex、Bedrock、xAI/Grok、Qwen、Kimi、iFlow、OpenCode Go、ClinePass、Ollama Cloud 以及任何 OpenAI 相容的上游,支援 OpenAI Chat/Responses、Anthropic Messages 和 Gemini 協定。
- 路由功能包含頻道群組、自訂路徑、輪詢/優先填滿/工作階段黏著排程、冷卻時間以及自動故障轉移到健康帳戶。
- 可觀測性:監控中心提供健康分數、每分鐘即時流量、P50–P99 延遲、首個 token 時間、失敗分析、入口使用者 → 模型 → 頻道流量流程,以及可搜尋的請求日誌,包含 token 數、延遲和成本。
- 花費控制:用戶端金鑰歸屬於入口帳戶、可重複使用的權限設定檔、每日/週期/終身配額、RPM 和 TPM 限制、按模型定價以及一鍵重置週期。
- 多租戶架構:租戶、使用者、角色、resource.action 權限、每個租戶的策展選單以及安全敏感變更的稽核軌跡。
- 網頁控制面板位於 /manage,可透過引導式登入或憑證匯入新增帳戶、視覺化編輯設定、管理模型和定價、檢查更新,支援英文、簡體中文和俄文。
使用情境
- 希望共用單一 AI 閘道進行程式碼 CLI 工具,同時保持租戶帳戶、金鑰和資料分離的團隊。
- 需要監控和控制多個使用者與專案中 AI 程式碼工具花費的組織。
- 想要透過單一端點路由來自多個 AI 程式碼 CLI 的請求,並具備自動故障轉移和協定轉換功能的開發者。
快速開始
請參閱儲存庫的 README 以取得安裝和快速開始說明。
授權與價格
授權:MIT。價格:開源。
Based on the project's public README and repository metadata.