ding113/claude-code-hub
一个现代化的 Claude Code & Codex API 代理服务,提供智能负载均衡、用户管理和使用统计功能。
What it solves
CC Hub solves the problem of managing multiple AI service providers (like Claude, OpenAI, Gemini) from a single team-wide access point. Without it, teams have to juggle different API keys, endpoints, and billing for each provider, and they lack visibility into usage, costs, and reliability. CC Hub provides a unified proxy layer that handles authentication, load balancing, rate limiting, and monitoring, so teams can use AI services safely and observably.
How it works
CC Hub is built with Next.js 16, Hono, PostgreSQL, and Redis. It works as an API proxy: incoming requests from CLI tools or third-party systems hit a Next.js API route, where a pipeline authenticates the API key, assigns a session, applies rate limits, selects a provider based on weighted priority and health, forwards the request, and streams the response back in the original format. Redis stores session context and rate-limit counters (using Lua scripts for atomicity), while PostgreSQL stores logs, usage stats, and configuration. The admin UI lets you manage providers, view dashboards, check leaderboards, and adjust price tables. The proxy supports Claude Code, Codex, Gemini CLI, and any OpenAI-compatible endpoint, with optional HTTP/SOCKS proxy support and model redirection.
Who it’s for
This is for teams or individuals who run their own AI API gateway for internal use. It suits developers who want fine-grained control over multiple AI providers, need cost tracking and usage governance, and want to centralize access for tools like Claude Code, Codex, or Gemini CLI. It also helps platform engineers who need a self-hosted, observable proxy with health checks, circuit breaking, and automated failover.
Highlights
- Smart load balancing – uses weighted priority and grouping, with circuit-breaker protection and up to 3 failover attempts.
- Multi-provider support – connects Claude, Codex, Gemini CLI, and OpenAI-compatible endpoints; supports model redirection and HTTP/HTTPS/SOCKS proxies.
- Fine-grained rate limiting – limits by RPM, cost (5-hour/weekly/monthly), and concurrent sessions; uses Redis Lua scripts for atomicity and fails open if Redis goes down.
- Automated OpenAPI documentation – 39 REST endpoints auto-generated as OpenAPI 3.1.0, with Swagger and Scalar UIs for instant testing.
- Real-time monitoring – dashboard with active sessions, usage leaderboard, decision-chain logs, and provider health tracking.
- Price table management – paginated search with SQL optimization, LiteLLM sync, and quick retrieval even for thousands of models.
- Session management – 5-minute context caching, decision-chain logging, and provider reuse to avoid context loss.
- OpenAI-compatible endpoint – supports /v1/chat/completions with tool calls and reasoning fields passed through unchanged; no cross-format conversion.
Related
- Project
- Project
- Project
- Project
- Project