by Wei-Shaw
Sub2API-CRS2 一站式开源中转服务,让 Claude、Openai 、Gemini、Antigravity订阅统一接入,支持拼车共享,更高效分摊成本,原生工具无缝使用。
# Add to your Claude Code skills
git clone https://github.com/Wei-Shaw/sub2apiAI API Gateway Platform for Subscription Quota Distribution
Sub2API officially uses only the domains
sub2api.organdpincc.ai. Other websites using the Sub2API name may be third-party deployments or services and are not affiliated with this project. Please verify and exercise your own judgment.
Try Sub2API online: https://demo.sub2api.org/
Demo credentials (shared demo environment; not created automatically for self-hosted installs):
| Email | Password | |-------|----------| | admin@sub2api.org | admin123 |
Sub2API is an AI API gateway platform designed to distribute and manage API quotas from AI product subscriptions. Users can access upstream AI services through platform-generated API Keys, while the platform handles authentication, billing, load balancing, and request forwarding.
Community projects that extend or integrate with Sub2API:
| Project | Description | Features | |---------|-------------|----------| | Sub2ApiPay | Self-service payment system | Self-service top-up and subscription purchase; supports YiPay protocol, WeChat Pay, Alipay, Stripe; embeddable via iframe | | sub2api-mobile | Mobile admin console | Cross-platform app (iOS/Android/Web) for user management, account management, monitoring dashboard, and multi-backend switching; built with Expo + React Native |
| Component | Technology | |-----------|------------| | Backend | Go 1.25.7, Gin, Ent | | Frontend | Vue 3.4+, Vite 5+, TailwindCSS | | Database | PostgreSQL 15+ | | Cache/Queue | Redis 7+ |
When using Nginx as a reverse proxy for Sub2API (or CRS) with Codex CLI, add the following to the http block in your Nginx configuration:
underscores_in_headers on;
Nginx drops headers containing underscores by default (e.g. session_id), which breaks sticky session routing in multi-account setups.
One-click installation script that downloads pre-built binaries from GitHub Releases.
curl -sSL https://raw.githubusercontent.com/Wei-Shaw/sub2api/main/deploy/install.sh | sudo bash
The script will:
/opt/sub2api# 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:
You can upgrade directly from the Admin Dashboard by clicking the Check for Updates button in the top-left corner.
The web interface will:
# Check status
sudo systemctl status sub2api
# View logs
sudo journalctl -u sub2api -f
# Restart service
sudo systemctl restart sub2api
# Uninstall
curl -sSL https://raw.githubusercontent.com/Wei-Shaw/sub2api/main/deploy/install.sh | sudo bash -s -- uninstall -y
Deploy with Docker Compose, including PostgreSQL and Redis containers.
Use the automated deployment script for easy setup:
# Create deployment directory
mkdir -p sub2api-deploy && cd sub2api-deploy
# Download and run deployment preparation script
curl -sSL https://raw.githubusercontent.com/Wei-Shaw/sub2api/main/deploy/docker-deploy.sh | bash
# Start services
docker compose up -d
# View logs
docker compose logs -f sub2api
What the script does:
docker-compose.local.yml (saved as docker-compose.yml) and .env.example.env file with auto-generated secretsIf you prefer manual setup:
# 1. Clone the repository
git clone https://github.com/Wei-Shaw/sub2api.git
cd sub2api/deploy
# 2. Copy environment configuration
cp .env.example .env
# 3. Edit configuration (generate secure passwords)
nano .env
Required configuration in .env:
# PostgreSQL password (REQUIRED)
POSTGRES_PASSWORD=your_secure_password_here
# JWT Secret (RECOMMENDED - keeps users logged in after restart)
JWT_SECRET=your_jwt_secret_here
# TOTP Encryption Key (RECOMMENDED - preserves 2FA after restart)
TOTP_ENCRYPTION_KEY=your_totp_key_here
# Optional: Admin account
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=your_admin_password
# Optional: Custom port
SERVER_PORT=8080
Generate secure secrets:
# Generate JWT_SECRET
openssl rand -hex 32
# Generate TOTP_ENCRYPTION_KEY
openssl rand -hex
No comments yet. Be the first to share your thoughts!