sub2api
by Wei-Shaw
Sub2API-CRS2 is a one-stop open source transfer service that allows Claude, Openai, Gemini, and Antigravity subscriptions to be connected in a unified manner, supports carpooling, allocates costs more efficiently, and uses native tools seamlessly.
# Add to your Claude Code skills
git clone https://github.com/Wei-Shaw/sub2apiSub2API
<div align="center">AI API Gateway Platform for Subscription Quota Distribution
English | 中文
</div>Demo
Try Sub2API online: https://demo.sub2api.org/
Demo credentials (shared demo environment; not created automatically for self-hosted installs):
| Email | Password | |-------|----------| | admin@sub2api.com | admin123 |
Overview
Sub2API is an AI API gateway platform designed to distribute and manage API quotas from AI product subscriptions (like Claude Code $200/month). Users can access upstream AI services through platform-generated API Keys, while the platform handles authentication, billing, load balancing, and request forwarding.
Features
- Multi-Account Management - Support multiple upstream account types (OAuth, API Key)
- API Key Distribution - Generate and manage API Keys for users
- Precise Billing - Token-level usage tracking and cost calculation
- Smart Scheduling - Intelligent account selection with sticky sessions
- Concurrency Control - Per-user and per-account concurrency limits
- Rate Limiting - Configurable request and token rate limits
- Admin Dashboard - Web interface for monitoring and management
Tech Stack
| Component | Technology | |-----------|------------| | Backend | Go 1.25.5, Gin, Ent | | Frontend | Vue 3.4+, Vite 5+, TailwindCSS | | Database | PostgreSQL 15+ | | Cache/Queue | Redis 7+ |
Documentation
- Dependency Security:
docs/dependency-security.md
Deployment
Method 1: Script Installation (Recommended)
One-click installation script that downloads pre-built binaries from GitHub Releases.
Prerequisites
- Linux server (amd64 or arm64)
- PostgreSQL 15+ (installed and running)
- Redis 7+ (installed and running)
- Root privileges
Installation Steps
curl -sSL https://raw.githubusercontent.com/Wei-Shaw/sub2api/main/deploy/install.sh | sudo bash
The script will:
- Detect your system architecture
- Download the latest release
- Install binary to
/opt/sub2api - Create systemd service
- Configure system user and permissions
Post-Installation
# 1. Start the service
sudo systemctl start sub2api
# 2. Enable auto-start on boot
sudo systemctl enable sub2api
# 3. Open Setup Wizard in browser
# http://YOUR_SERVER_IP:8080
The Setup Wizard will guide you through:
- Database configuration
- Redis configuration
- Admin account creation
Upgrade
You can upgrade directly from the Admin Dashboard by clicking the **Check for Updates...