Claude Code Hub AI API Proxy for Teams Deploy in Minutes

10月19日 Published inAI Service Tools

Claude Code Hub is an AI API proxy platform designed for teams and enterprises. It eliminates the friction of managing multiple AI providers by providing a unified endpoint for all of them. Smart load balancing, multi-tenant control, full API key lifecycle management, real-time monitoring, and cost analytics come standard—all wrapped in a modern, intuitive UI. Deploy with a single command and take full control over your model pricing and API complexity.

1. One API to Rule Them All

Manage OpenAI, Claude, Gemini, and other models through a single interface. Stop jumping between fragmented dashboards and disparate endpoints. By integrating once, you significantly reduce long-term development and maintenance overhead.

2. Intelligent Load Management

Distribute traffic according to custom weights. Automatic failover ensures high availability even if a specific provider experiences downtime. Session stickiness prevents user disconnections during model switches, maintaining a seamless experience mid-task.

3. Multi-Tenant Architecture

Designed for organizational hierarchies. Assign granular permissions and usage quotas to specific users or teams. By setting independent limits for different departments, you ensure that high-volume engineering tasks don't exhaust the marketing team's budget.

4. Full Key Lifecycle Management

Manage API keys with ease: generate, rotate, or expire them on demand. Set automated expiration dates to deprecate keys on schedule. Proactive rotation minimizes the "blast radius" should a secret ever be compromised.

5. Real-Time Monitoring and Analytics

Monitor request volume, track spending, and analyze performance via visual dashboards. Gain insights into cost trends, user activity rankings, and provider latency. Identify and resolve failures before they impact your end users.

6. Intuitive Interface

A clean, responsive dashboard built with Shadcn UI, featuring a native dark mode. The interface is optimized for both desktop and mobile use, making it easy to manage your infrastructure from any device without needing a manual.

7. Deploy with a Single Command

Leverage Docker to handle the heavy lifting. A single command spins up the entire stack, including automatic database migrations and health checks. Move from a fresh environment to a functional proxy in minutes.

Deploy Claude Code Hub Fast

You only need Docker and Docker Compose installed to get started.

The docker-compose.yaml file configures both the PostgreSQL database and the core application service:

services:
  postgres:
    image: postgres:18
    container_name: claude-code-hub-db
    restart: unless-stopped
    ports:
      - "35432:5432"
    environment:
      POSTGRES_USER: ${DB_USER:-postgres}
      POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
      POSTGRES_DB: ${DB_NAME:-claude_code_hub}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-postgres} -d ${DB_NAME:-claude_code_hub}"]
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 10s

  app:
    image: zsio/claude-code-hub:latest
    container_name: claude-code-hub-app
    depends_on:
      postgres:
        condition: service_healthy
    env_file:
      - ./.env
    environment:
      NODE_ENV: production
      PORT: 23000
      DSN: postgresql://${DB_USER:-postgres}:${DB_PASSWORD:-postgres}@postgres:5432/${DB_NAME:-claude_code_hub}
    ports:
      - "23000:23000"
    restart: unless-stopped

volumes:
  postgres_data:
    driver: local

Launch the Stack

Open a terminal in the project directory and run:

# Start all services in detached mode
docker compose up -d

# Follow the logs to confirm a successful startup
docker compose logs -f

Verify the Deployment

Run docker compose ps. Both containers should be listed as healthy or running.

Environment Variables

Create a .env file in the project root and configure the following values:

# Admin login token (use a strong password)
ADMIN_TOKEN=!!!change-me-to-a-strong-password!!!

# Database settings
DB_USER=postgres
DB_PASSWORD=!!!change-me!!!
DB_NAME=claude_code_hub
Variable Required Default Purpose
ADMIN_TOKEN change-me Token for admin dashboard access.
DB_USER postgres Database username.
DB_PASSWORD postgres Database password. Change this for production.
DB_NAME claude_code_hub Name of the database.
AUTO_MIGRATE true Automatically runs DB migrations on startup.

Routine Commands

# View logs
docker compose logs -f          # All services
docker compose logs -f app      # Application only
docker compose logs -f postgres # Database only

# Restart services
docker compose restart          # Restart everything
docker compose restart app      # Restart application only

# Stop services
docker compose stop             # Stop containers (preserves state)
docker compose down             # Stop and remove containers

# Update to the latest version
docker compose pull
docker compose up -d

# Database Backup
docker exec claude-code-hub-db pg_dump -U postgres claude_code_hub > backup_$(date +%Y%m%d_%H%M%S).sql

# Database Restore
docker exec -i claude-code-hub-db psql -U postgres claude_code_hub < backup.sql

# Reset (Warning: This deletes all data)
docker compose down -v

Using Claude Code Hub

First Login

Navigate to http://localhost:23000 and log in using the ADMIN_TOKEN defined in your .env file.

Add AI Providers

  1. Go to Settings → Provider Management and click Add Provider.
  2. This proxy is designed for APIs compatible with the Claude Code format (e.g., Zhipu GLM, Kimi, Packy). To use Gemini, OpenAI, or Ollama, first deploy claude-code-router to translate the protocols, then point Claude Code Hub to that router’s address.

Create Users and Keys

Add a User
  1. Go to Settings → User Management and click Add User.
  2. Enter a name, description, RPM (requests per minute) limit, and a daily USD quota.
Generate an API Key
  1. Locate the user in the list and click Generate Key.
  2. Provide a name and optional expiration date.
  3. Copy the key immediately. It is only displayed once for security reasons.

Using the Proxy API

Point your API clients to the proxy endpoint. Comprehensive documentation is available at http://localhost:23000/usage-doc.

Monitoring and Stats

  • Request Trends: Visualize usage volume over time.
  • Cost Breakdown: Track total expenditure and distribution across models.
  • User Rankings: Identify your most active users.
  • Provider Performance: Compare latency and success rates between providers.
  • Anomaly Detection: Quickly spot high failure rates or timeouts.

Set Model Pricing

Under Settings → Price Management, define per-token pricing for input and output for each model. The system will automatically calculate usage costs and allow you to export reports for accounting.

Troubleshooting

Reset the Admin Password

Update the ADMIN_TOKEN in your .env file and run docker compose restart app.

Port Conflicts

If a port is already in use, modify the host port mapping in docker-compose.yaml:

services:
  app:
    ports:
      - "8080:23000"   # Change 8080 to any free port

  postgres:
    ports:
      - "15432:5432"  # Change 15432 to any free port

Restart the stack after saving your changes.

Database Migration Issues

First, verify the database connection:

docker compose exec app sh -c 'echo "SELECT version();" | psql $DSN'

Check for specific migration errors in the logs:

docker compose logs app | grep -i migration

You can also attempt to trigger migrations manually:

docker compose exec app pnpm db:migrate
Nginx Reverse Proxy (HTTPS)
server {
    listen 443 ssl http2;
    server_name your-domain.com;

    ssl_certificate /path/to/cert.pem;
    ssl_certificate_key /path/to/key.pem;

    location / {
        proxy_pass http://localhost:23000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
Supported AI Providers

Direct Support: Any provider offering a Claude Code-compatible API.

Indirect Support (via claude-code-router): Zhipu AI (GLM), Moonshot AI (Kimi), Packy, Alibaba Qwen, Baidu Wenxin, and others.

To set up indirect providers, deploy claude-code-router, configure your upstream services there, and then add the router's address as a provider within Claude Code Hub.

Service Health and Tuning
  • Health Checks: Use docker compose ps for status and docker stats for resource consumption.
  • Database Tuning: Periodically run VACUUM ANALYZE and ensure frequently queried columns are indexed.
  • Scalability: For high-traffic environments, consider adding a Redis cache layer and increasing Node.js memory limits.