claude-code-hub  by ding113

AI API proxy platform for unified multi-vendor access

Created 4 months ago
1,478 stars

Top 27.4% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a modern, unified proxy service platform for AI API access, specifically targeting teams that need to manage multiple AI providers like Claude, OpenAI, and Gemini. It offers intelligent load balancing, user management, usage statistics, and a centralized operational dashboard, enabling secure, observable, and cost-effective control over AI service consumption.

How It Works

Built with Next.js 15, Hono, PostgreSQL, and Redis, Claude Code Hub acts as an intelligent API gateway. It employs a sophisticated proxy pipeline that handles authentication, session management, rate limiting (RPM, monetary, concurrency), and dynamic provider selection based on weight, priority, and real-time health status. The system supports multiple AI vendors and offers an OpenAI-compatible endpoint, ensuring seamless integration and flexible routing with features like circuit breaking and automatic failover.

Quick Start & Requirements

The recommended deployment method is Docker Compose, with a one-click deployment script available for Linux/macOS and Windows. Prerequisites include Docker and Docker Compose. For local development, Node.js ≥ 20 or Bun ≥ 1.3 is required. The project provides links to its container image on ghcr.io and a Telegram community group for discussion.

Highlighted Details

  • Intelligent Load Balancing: Utilizes weight, priority, and group scheduling with built-in circuit breaking and up to 3 failovers for robust request handling.
  • Multi-Vendor Management: Integrates Claude, OpenAI Compatible, Gemini CLI, and custom endpoints, supporting model redirection and various proxy types (HTTP/HTTPS/SOCKS).
  • Rate Limiting & Concurrency: Implements multi-dimensional controls including RPM, monetary limits, and concurrent sessions using atomic Redis Lua scripts.
  • Automated OpenAPI Documentation: Generates OpenAPI 3.1.0 documentation automatically, accessible via Swagger and Scalar UI interfaces.
  • Real-time Monitoring: Features a dashboard with active sessions, consumption leaderboards, decision chain logging, and proxy status tracking for operational visibility.
  • Session Management: Includes 5-minute context caching and decision chain logging to optimize vendor switching and maintain audit trails.

Maintenance & Community

The project maintains an active Telegram community group for discussions and support. It acknowledges sponsorships and partnerships with AI API transit services like Cubence, PackyCode, and YesCode, which offer user discounts. Development is also influenced by and contributes to related open-source projects.

Licensing & Compatibility

Claude Code Hub is released under the MIT License, permitting free use and secondary development, provided attribution is maintained. It is compatible with commercial use and closed-source linking under the terms of the MIT license.

Limitations & Caveats

Full functionality, particularly for rate limiting and session statistics, relies on a stable Redis connection; Redis outages trigger a "Fail-Open" strategy, continuing requests but with degraded monitoring. The ADMIN_TOKEN must be securely managed post-deployment. While Docker Compose simplifies setup, understanding the .env configuration is crucial. The system defaults to automatic database migrations on startup, which should be managed manually in production environments.

Health Check
Last Commit

19 hours ago

Responsiveness

Inactive

Pull Requests (30d)
83
Issues (30d)
98
Star History
349 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.