[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-204":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":9,"totalLinesOfCode":9,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":9,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":9,"pushedAt":9,"updatedAt":34,"readmeContent":35,"aiSummary":36,"trendingCount":16,"starSnapshotCount":16,"syncStatus":37,"lastSyncTime":38,"discoverSource":39},204,"sub2api","Wei-Shaw\u002Fsub2api","Wei-Shaw","Sub2API is an open-source relay platform that unifies Claude, OpenAI, Gemini, and Antigravity subscriptions into a single endpoint. It supports account sharing and cost-sharing, with seamless native tool compatibility.",null,"https:\u002F\u002Fgithub.com\u002FWei-Shaw\u002Fsub2api","Go",27186,5492,52,1214,0,232,1923,7207,1313,45,false,"main",[25,26,27,28,29,30,31,32,33],"2api","antigravity2api","claude","claude-code","codex","crs","gemini","cc2api","crs2","2026-06-12 02:00:09","# Sub2API\n\n\u003Cdiv align=\"center\">\n\n[![Go](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FGo-1.25.7-00ADD8.svg)](https:\u002F\u002Fgolang.org\u002F)\n[![Vue](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FVue-3.4+-4FC08D.svg)](https:\u002F\u002Fvuejs.org\u002F)\n[![PostgreSQL](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPostgreSQL-15+-336791.svg)](https:\u002F\u002Fwww.postgresql.org\u002F)\n[![Redis](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FRedis-7+-DC382D.svg)](https:\u002F\u002Fredis.io\u002F)\n[![Docker](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDocker-Ready-2496ED.svg)](https:\u002F\u002Fwww.docker.com\u002F)\n\n\u003Ca href=\"https:\u002F\u002Ftrendshift.io\u002Frepositories\u002F21823\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Ftrendshift.io\u002Fapi\u002Fbadge\u002Frepositories\u002F21823\" alt=\"Wei-Shaw%2Fsub2api | Trendshift\" width=\"250\" height=\"55\"\u002F>\u003C\u002Fa>\n\n**AI API Gateway Platform for Subscription Quota Distribution**\n\nEnglish | [中文](README_CN.md) | [日本語](README_JA.md)\n\n\u003C\u002Fdiv>\n\n> **Sub2API officially uses only the domains `sub2api.org` and `pincc.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.**\n\n---\n\n## Demo\n\nTry Sub2API online: **[https:\u002F\u002Fdemo.sub2api.org\u002F](https:\u002F\u002Fdemo.sub2api.org\u002F)**\n\nDemo credentials (shared demo environment; **not** created automatically for self-hosted installs):\n\n| Email | Password |\n|-------|----------|\n| admin@sub2api.org | admin123 |\n\n## Overview\n\nSub2API 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.\n\n## Features\n\n- **Multi-Account Management** - Support multiple upstream account types (OAuth, API Key)\n- **API Key Distribution** - Generate and manage API Keys for users\n- **Precise Billing** - Token-level usage tracking and cost calculation\n- **Smart Scheduling** - Intelligent account selection with sticky sessions\n- **Concurrency Control** - Per-user and per-account concurrency limits\n- **Rate Limiting** - Configurable request and token rate limits\n- **Built-in Payment System** - Supports EasyPay, Alipay, WeChat Pay, and Stripe for user self-service top-up, no separate payment service needed ([Configuration Guide](docs\u002FPAYMENT.md))\n- **Admin Dashboard** - Web interface for monitoring and management\n- **External System Integration** - Embed external systems (e.g. ticketing) via iframe to extend the admin dashboard\n\n## ❤️ Sponsors\n\n> [Want to appear here?](mailto:support@pincc.ai)\n\n\u003Ctable>\n\u003Ctr>\n\u003Ctd width=\"180\" align=\"center\" valign=\"middle\">\u003Ca href=\"https:\u002F\u002Fshop.pincc.ai\u002F\">\u003Cimg src=\"assets\u002Fpartners\u002Flogos\u002Fpincc-logo.png\" alt=\"pincc\" width=\"150\">\u003C\u002Fa>\u003C\u002Ftd>\n\u003Ctd valign=\"middle\">\u003Cb>\u003Ca href=\"https:\u002F\u002Fshop.pincc.ai\u002F\">PinCC\u003C\u002Fa>\u003C\u002Fb> is the official relay service built on Sub2API, offering stable access to Claude Code, Codex, Gemini and other popular models — ready to use, no deployment or maintenance required.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\n\u003Ctr>\n\u003Ctd width=\"180\">\u003Ca href=\"https:\u002F\u002Fwww.packyapi.com\u002Fregister?aff=sub2api\">\u003Cimg src=\"assets\u002Fpartners\u002Flogos\u002Fpackycode.png\" alt=\"PackyCode\" width=\"150\">\u003C\u002Fa>\u003C\u002Ftd>\n\u003Ctd>Thanks to PackyCode for sponsoring this project! PackyCode is a reliable and efficient API relay service provider, offering relay services for Claude Code, Codex, Gemini, and more. PackyCode provides special discounts for our software users: register using \u003Ca href=\"https:\u002F\u002Fwww.packyapi.com\u002Fregister?aff=sub2api\">this link\u003C\u002Fa> and enter the \"sub2api\" promo code during first recharge to get 10% off.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\n\u003Ctr>\n\u003Ctd width=\"180\">\u003Ca href=\"https:\u002F\u002Fpoixe.com\u002Fi\u002Fsub2api\">\u003Cimg src=\"assets\u002Fpartners\u002Flogos\u002Fpoixe.png\" alt=\"PoixeAi\" width=\"150\">\u003C\u002Fa>\u003C\u002Ftd>\n\u003Ctd>Thanks to Poixe Ai for sponsoring this project! Poixe AI provides reliable LLM API services. You can leverage the platform's API endpoints to seamlessly build AI-powered products. Additionally, you can become a vendor by providing AI API resources to the platform and earn revenue. Register through the exclusive \u003Ca href=\"https:\u002F\u002Fpoixe.com\u002Fi\u002Fsub2api\">sub2api\u003C\u002Fa> referral link and receive a bonus of $5 USD on your first top-up.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\n\u003Ctr>\n\u003Ctd width=\"180\">\u003Ca href=\"https:\u002F\u002Fctok.ai\">\u003Cimg src=\"assets\u002Fpartners\u002Flogos\u002Fctok.png\" alt=\"CTok\" width=\"150\">\u003C\u002Fa>\u003C\u002Ftd>\n\u003Ctd>Thanks to CTok.ai for sponsoring this project! CTok.ai is dedicated to building a one-stop AI programming tool service platform. We offer professional Claude Code packages and technical community services, with support for Google Gemini and OpenAI Codex. Through carefully designed plans and a professional tech community, we provide developers with reliable service guarantees and continuous technical support, making AI-assisted programming a true productivity tool. Click \u003Ca href=\"https:\u002F\u002Fctok.ai\">here\u003C\u002Fa> to register!\u003C\u002Ftd>\n\u003C\u002Ftr>\n\n\u003Ctr>\n\u003Ctd width=\"180\">\u003Ca href=\"https:\u002F\u002Fcode.silkapi.com\u002F\">\u003Cimg src=\"assets\u002Fpartners\u002Flogos\u002Fsilkapi.png\" alt=\"silkapi\" width=\"150\">\u003C\u002Fa>\u003C\u002Ftd>\n\u003Ctd>Thanks to SilkAPI for sponsoring this project! \u003Ca href=\"https:\u002F\u002Fcode.silkapi.com\u002F\">SilkAPI\u003C\u002Fa> is a relay service built on Sub2API, specializing in providing high-speed and stable Codex API relay.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\n\u003Ctr>\n\u003Ctd width=\"180\">\u003Ca href=\"https:\u002F\u002Fylscode.com\u002F\">\u003Cimg src=\"assets\u002Fpartners\u002Flogos\u002Fylscode.png\" alt=\"ylscode\" width=\"150\">\u003C\u002Fa>\u003C\u002Ftd>\n\u003Ctd>Thanks to YLS Code for sponsoring this project! \u003Ca href=\"https:\u002F\u002Fylscode.com\u002F\">YLS Code\u003C\u002Fa> is dedicated to building secure enterprise-grade Coding Agent productivity services, offering stable and fast Codex \u002F Claude \u002F Gemini subscription services along with pay-as-you-go API options for flexible choices. Register now for a limited-time 3-day Codex trial bonus!\u003C\u002Ftd>\n\u003C\u002Ftr>\n\n\u003Ctr>\n\u003Ctd width=\"180\">\u003Ca href=\"https:\u002F\u002Fwww.aicodemirror.com\u002Fregister?invitecode=KMVZQM\">\u003Cimg src=\"assets\u002Fpartners\u002Flogos\u002FAICodeMirror.jpg\" alt=\"AICodeMirror\" width=\"150\">\u003C\u002Fa>\u003C\u002Ftd>\n\u003Ctd>Thanks to AICodeMirror for sponsoring this project! AICodeMirror provides official high-stability relay services for Claude Code \u002F Codex \u002F Gemini CLI, with enterprise-grade concurrency, fast invoicing, and 24\u002F7 dedicated technical support. Claude Code \u002F Codex \u002F Gemini official channels at 38% \u002F 2% \u002F 9% of original price, with extra discounts on top-ups! AICodeMirror offers special benefits for sub2api users: register via \u003Ca href=\"https:\u002F\u002Fwww.aicodemirror.com\u002Fregister?invitecode=KMVZQM\">this link\u003C\u002Fa> to enjoy 20% off your first top-up, and enterprise customers can get up to 25% off!\u003C\u002Ftd>\n\u003C\u002Ftr>\n\n\u003Ctr>\n\u003Ctd width=\"180\">\u003Ca href=\"https:\u002F\u002Faigocode.com\u002Finvite\u002FSUB2API\">\u003Cimg src=\"assets\u002Fpartners\u002Flogos\u002Faigocode.png\" alt=\"AIGoCode\" width=\"150\">\u003C\u002Fa>\u003C\u002Ftd>\n\u003Ctd>Thanks to AIGoCode for sponsoring this project! AIGoCode is an all-in-one platform that integrates Claude Code, Codex, and the latest Gemini models, providing you with stable, efficient, and highly cost-effective AI coding services. The platform offers flexible subscription plans, zero risk of account suspension, direct access with no VPN required, and lightning-fast responses. AIGoCode has prepared a special benefit for sub2api users: if you register via \u003Ca href=\"https:\u002F\u002Faigocode.com\u002Finvite\u002FSUB2API\">this link\u003C\u002Fa>, you'll receive an extra 10% bonus credit on your first top-up!\u003C\u002Ftd>\n\u003C\u002Ftr>\n\n\u003Ctr>\n\u003Ctd width=\"180\">\u003Ca href=\"https:\u002F\u002Fshop.bmoplus.com\u002F?utm_source=github\">\u003Cimg src=\"assets\u002Fpartners\u002Flogos\u002Fbmoplus.jpg\" alt=\"bmoplus\" width=\"150\">\u003C\u002Fa>\u003C\u002Ftd>\n\u003Ctd>Huge thanks to BmoPlus for sponsoring this project! BmoPlus is a highly reliable AI account provider built strictly for heavy AI users and developers. They offer rock-solid, ready-to-use accounts and official top-up services for ChatGPT Plus \u002F ChatGPT Pro (Full Warranty) \u002F Claude Pro \u002F Super Grok \u002F Gemini Pro. By registering and ordering through \u003Ca href=\"https:\u002F\u002Fshop.bmoplus.com\u002F?utm_source=github\">BmoPlus - Premium AI Accounts & Top-ups\u003C\u002Fa>, users can unlock the mind-blowing rate of 10% of the official GPT subscription price (90% OFF)\u003C\u002Ftd>\n\u003C\u002Ftr>\n\n\u003Ctr>\n\u003Ctd width=\"180\">\u003Ca href=\"https:\u002F\u002Fbestproxy.com\u002F?keyword=a2e8iuol\">\u003Cimg src=\"assets\u002Fpartners\u002Flogos\u002Fbestproxy.png\" alt=\"bestproxy\" width=\"150\">\u003C\u002Fa>\u003C\u002Ftd>\n\u003Ctd>Thanks to Bestproxy for sponsoring this project! \u003Ca href=\"https:\u002F\u002Fbestproxy.com\u002F?keyword=a2e8iuol\">Bestproxy\u003C\u002Fa> provides high-purity residential IPs with dedicated one-IP-per-account support. By combining real home networks with fingerprint isolation, it enables link environment isolation and reduces the probability of association-based risk control.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\n\u003Ctr>\n\u003Ctd width=\"180\">\u003Ca href=\"https:\u002F\u002Fpateway.ai\u002F?ch=1tsfr51\">\u003Cimg src=\"assets\u002Fpartners\u002Flogos\u002Fpateway.png\" alt=\"pateway\" width=\"150\">\u003C\u002Fa>\u003C\u002Ftd>\n\u003Ctd>Thanks to PatewayAI for sponsoring this project! PatewayAI is a premium model API relay service provider built for heavy AI developers, focused on direct official connections. Offering the full Claude series and Codex series models, 100% sourced directly from official providers — no dilution, no substitution, open to verification. Billing is fully transparent with token-level invoices that can be audited line by line.\nEnterprise-grade high concurrency is also supported, with a dedicated management platform for enterprise clients. Enterprise customers can sign formal contracts and receive invoices. Visit the official website for more details and contact information.\nRegister now via \u003Ca href=\"https:\u002F\u002Fpateway.ai\u002F?ch=1tsfr51\">this link\u003C\u002Fa> to receive $3 in trial credits. User top-ups start as low as 60% off, and referring friends earns both parties rewards — referral bonuses up to $150.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\n\u003C\u002Ftable>\n\n## Ecosystem\n\nCommunity projects that extend or integrate with Sub2API:\n\n| Project | Description | Features |\n|---------|-------------|----------|\n| ~~[Sub2ApiPay](https:\u002F\u002Fgithub.com\u002Ftouwaeriol\u002Fsub2apipay)~~ | ~~Self-service payment system~~ | **Now Built-in** — Payment is now integrated into Sub2API, no separate deployment needed. See [Payment Configuration Guide](docs\u002FPAYMENT.md) |\n| [sub2api-mobile](https:\u002F\u002Fgithub.com\u002Fckken\u002Fsub2api-mobile) | Mobile admin console | Cross-platform app (iOS\u002FAndroid\u002FWeb) for user management, account management, monitoring dashboard, and multi-backend switching; built with Expo + React Native |\n\n## Tech Stack\n\n| Component | Technology |\n|-----------|------------|\n| Backend | Go 1.25.7, Gin, Ent |\n| Frontend | Vue 3.4+, Vite 5+, TailwindCSS |\n| Database | PostgreSQL 15+ |\n| Cache\u002FQueue | Redis 7+ |\n\n---\n\n## Nginx Reverse Proxy Note\n\nWhen using Nginx as a reverse proxy for Sub2API (or CRS) with Codex CLI, add the following to the `http` block in your Nginx configuration:\n\n```nginx\nunderscores_in_headers on;\n```\n\nNginx drops headers containing underscores by default (e.g. `session_id`), which breaks sticky session routing in multi-account setups.\n\n---\n\n## Deployment\n\n### Method 1: Script Installation (Recommended)\n\nOne-click installation script that downloads pre-built binaries from GitHub Releases.\n\n#### Prerequisites\n\n- Linux server (amd64 or arm64)\n- PostgreSQL 15+ (installed and running)\n- Redis 7+ (installed and running)\n- Root privileges\n\n#### Installation Steps\n\n```bash\ncurl -sSL https:\u002F\u002Fraw.githubusercontent.com\u002FWei-Shaw\u002Fsub2api\u002Fmain\u002Fdeploy\u002Finstall.sh | sudo bash\n```\n\nThe script will:\n1. Detect your system architecture\n2. Download the latest release\n3. Install binary to `\u002Fopt\u002Fsub2api`\n4. Create systemd service\n5. Configure system user and permissions\n\n#### Post-Installation\n\n```bash\n# 1. Start the service\nsudo systemctl start sub2api\n\n# 2. Enable auto-start on boot\nsudo systemctl enable sub2api\n\n# 3. Open Setup Wizard in browser\n# http:\u002F\u002FYOUR_SERVER_IP:8080\n```\n\nThe Setup Wizard will guide you through:\n- Database configuration\n- Redis configuration\n- Admin account creation\n\n#### Upgrade\n\nYou can upgrade directly from the **Admin Dashboard** by clicking the **Check for Updates** button in the top-left corner.\n\nThe web interface will:\n- Check for new versions automatically\n- Download and apply updates with one click\n- Support rollback if needed\n\n#### Useful Commands\n\n```bash\n# Check status\nsudo systemctl status sub2api\n\n# View logs\nsudo journalctl -u sub2api -f\n\n# Restart service\nsudo systemctl restart sub2api\n\n# Uninstall\ncurl -sSL https:\u002F\u002Fraw.githubusercontent.com\u002FWei-Shaw\u002Fsub2api\u002Fmain\u002Fdeploy\u002Finstall.sh | sudo bash -s -- uninstall -y\n```\n\n---\n\n### Method 2: Docker Compose (Recommended)\n\nDeploy with Docker Compose, including PostgreSQL and Redis containers.\n\n#### Prerequisites\n\n- Docker 20.10+\n- Docker Compose v2+\n\n#### Quick Start (One-Click Deployment)\n\nUse the automated deployment script for easy setup:\n\n```bash\n# Create deployment directory\nmkdir -p sub2api-deploy && cd sub2api-deploy\n\n# Download and run deployment preparation script\ncurl -sSL https:\u002F\u002Fraw.githubusercontent.com\u002FWei-Shaw\u002Fsub2api\u002Fmain\u002Fdeploy\u002Fdocker-deploy.sh | bash\n\n# Start services\ndocker compose up -d\n\n# View logs\ndocker compose logs -f sub2api\n```\n\n**What the script does:**\n- Downloads `docker-compose.local.yml` (saved as `docker-compose.yml`) and `.env.example`\n- Generates secure credentials (JWT_SECRET, TOTP_ENCRYPTION_KEY, POSTGRES_PASSWORD)\n- Creates `.env` file with auto-generated secrets\n- Creates data directories (uses local directories for easy backup\u002Fmigration)\n- Displays generated credentials for your reference\n\n#### Manual Deployment\n\nIf you prefer manual setup:\n\n```bash\n# 1. Clone the repository\ngit clone https:\u002F\u002Fgithub.com\u002FWei-Shaw\u002Fsub2api.git\ncd sub2api\u002Fdeploy\n\n# 2. Copy environment configuration\ncp .env.example .env\n\n# 3. Edit configuration (generate secure passwords)\nnano .env\n```\n\n**Required configuration in `.env`:**\n\n```bash\n# PostgreSQL password (REQUIRED)\nPOSTGRES_PASSWORD=your_secure_password_here\n\n# JWT Secret (RECOMMENDED - keeps users logged in after restart)\nJWT_SECRET=your_jwt_secret_here\n\n# TOTP Encryption Key (RECOMMENDED - preserves 2FA after restart)\nTOTP_ENCRYPTION_KEY=your_totp_key_here\n\n# Optional: Admin account\nADMIN_EMAIL=admin@example.com\nADMIN_PASSWORD=your_admin_password\n\n# Optional: Custom port\nSERVER_PORT=8080\n```\n\n**Generate secure secrets:**\n```bash\n# Generate JWT_SECRET\nopenssl rand -hex 32\n\n# Generate TOTP_ENCRYPTION_KEY\nopenssl rand -hex 32\n\n# Generate POSTGRES_PASSWORD\nopenssl rand -hex 32\n```\n\n```bash\n# 4. Create data directories (for local version)\nmkdir -p data postgres_data redis_data\n\n# 5. Start all services\n# Option A: Local directory version (recommended - easy migration)\ndocker compose -f docker-compose.local.yml up -d\n\n# Option B: Named volumes version (simple setup)\ndocker compose up -d\n\n# 6. Check status\ndocker compose -f docker-compose.local.yml ps\n\n# 7. View logs\ndocker compose -f docker-compose.local.yml logs -f sub2api\n```\n\n#### Deployment Versions\n\n| Version | Data Storage | Migration | Best For |\n|---------|-------------|-----------|----------|\n| **docker-compose.local.yml** | Local directories | ✅ Easy (tar entire directory) | Production, frequent backups |\n| **docker-compose.yml** | Named volumes | ⚠️ Requires docker commands | Simple setup |\n\n**Recommendation:** Use `docker-compose.local.yml` (deployed by script) for easier data management.\n\n#### Access\n\nOpen `http:\u002F\u002FYOUR_SERVER_IP:8080` in your browser.\n\nIf admin password was auto-generated, find it in logs:\n```bash\ndocker compose -f docker-compose.local.yml logs sub2api | grep \"admin password\"\n```\n\n#### Upgrade\n\n```bash\n# Pull latest image and recreate container\ndocker compose -f docker-compose.local.yml pull\ndocker compose -f docker-compose.local.yml up -d\n```\n\n#### Easy Migration (Local Directory Version)\n\nWhen using `docker-compose.local.yml`, migrate to a new server easily:\n\n```bash\n# On source server\ndocker compose -f docker-compose.local.yml down\ncd ..\ntar czf sub2api-complete.tar.gz sub2api-deploy\u002F\n\n# Transfer to new server\nscp sub2api-complete.tar.gz user@new-server:\u002Fpath\u002F\n\n# On new server\ntar xzf sub2api-complete.tar.gz\ncd sub2api-deploy\u002F\ndocker compose -f docker-compose.local.yml up -d\n```\n\n#### Useful Commands\n\n```bash\n# Stop all services\ndocker compose -f docker-compose.local.yml down\n\n# Restart\ndocker compose -f docker-compose.local.yml restart\n\n# View all logs\ndocker compose -f docker-compose.local.yml logs -f\n\n# Remove all data (caution!)\ndocker compose -f docker-compose.local.yml down\nrm -rf data\u002F postgres_data\u002F redis_data\u002F\n```\n\n---\n\n### Method 3: Build from Source\n\nBuild and run from source code for development or customization.\n\n#### Prerequisites\n\n- Go 1.21+\n- Node.js 18+\n- PostgreSQL 15+\n- Redis 7+\n\n#### Build Steps\n\n```bash\n# 1. Clone the repository\ngit clone https:\u002F\u002Fgithub.com\u002FWei-Shaw\u002Fsub2api.git\ncd sub2api\n\n# 2. Install pnpm (if not already installed)\nnpm install -g pnpm\n\n# 3. Build frontend\ncd frontend\npnpm install\npnpm run build\n# Output will be in ..\u002Fbackend\u002Finternal\u002Fweb\u002Fdist\u002F\n\n# 4. Build backend with embedded frontend\ncd ..\u002Fbackend\ngo build -tags embed -o sub2api .\u002Fcmd\u002Fserver\n\n# 5. Create configuration file\ncp ..\u002Fdeploy\u002Fconfig.example.yaml .\u002Fconfig.yaml\n\n# 6. Edit configuration\nnano config.yaml\n```\n\n> **Note:** The `-tags embed` flag embeds the frontend into the binary. Without this flag, the binary will not serve the frontend UI.\n\n**Key configuration in `config.yaml`:**\n\n```yaml\nserver:\n  host: \"0.0.0.0\"\n  port: 8080\n  mode: \"release\"\n\ndatabase:\n  host: \"localhost\"\n  port: 5432\n  user: \"postgres\"\n  password: \"your_password\"\n  dbname: \"sub2api\"\n\nredis:\n  host: \"localhost\"\n  port: 6379\n  password: \"\"\n\njwt:\n  secret: \"change-this-to-a-secure-random-string\"\n  expire_hour: 24\n\ndefault:\n  user_concurrency: 5\n  user_balance: 0\n  api_key_prefix: \"sk-\"\n  rate_multiplier: 1.0\n```\n\n### Sora Status (Temporarily Unavailable)\n\n> ⚠️ Sora-related features are temporarily unavailable due to technical issues in upstream integration and media delivery.\n> Please do not rely on Sora in production at this time.\n> Existing `gateway.sora_*` configuration keys are reserved and may not take effect until these issues are resolved.\n\nAdditional security-related options are available in `config.yaml`:\n\n- `cors.allowed_origins` for CORS allowlist\n- `security.url_allowlist` for upstream\u002Fpricing\u002FCRS host allowlists\n- `security.url_allowlist.enabled` to disable URL validation (use with caution)\n- `security.url_allowlist.allow_insecure_http` to allow HTTP URLs when validation is disabled\n- `security.url_allowlist.allow_private_hosts` to allow private\u002Flocal IP addresses\n- `security.response_headers.enabled` to enable configurable response header filtering (disabled uses default allowlist)\n- `security.csp` to control Content-Security-Policy headers\n- `billing.circuit_breaker` to fail closed on billing errors\n- `server.trusted_proxies` to enable X-Forwarded-For parsing\n- `turnstile.required` to require Turnstile in release mode\n\n**⚠️ Security Warning: HTTP URL Configuration**\n\nWhen `security.url_allowlist.enabled=false`, the system performs minimal URL validation by default, **rejecting HTTP URLs** and only allowing HTTPS. To allow HTTP URLs (e.g., for development or internal testing), you must explicitly set:\n\n```yaml\nsecurity:\n  url_allowlist:\n    enabled: false                # Disable allowlist checks\n    allow_insecure_http: true     # Allow HTTP URLs (⚠️ INSECURE)\n```\n\n**Or via environment variable:**\n\n```bash\nSECURITY_URL_ALLOWLIST_ENABLED=false\nSECURITY_URL_ALLOWLIST_ALLOW_INSECURE_HTTP=true\n```\n\n**Risks of allowing HTTP:**\n- API keys and data transmitted in **plaintext** (vulnerable to interception)\n- Susceptible to **man-in-the-middle (MITM) attacks**\n- **NOT suitable for production** environments\n\n**When to use HTTP:**\n- ✅ Development\u002Ftesting with local servers (http:\u002F\u002Flocalhost)\n- ✅ Internal networks with trusted endpoints\n- ✅ Testing account connectivity before obtaining HTTPS\n- ❌ Production environments (use HTTPS only)\n\n**Example error without this setting:**\n```\nInvalid base URL: invalid url scheme: http\n```\n\nIf you disable URL validation or response header filtering, harden your network layer:\n- Enforce an egress allowlist for upstream domains\u002FIPs\n- Block private\u002Floopback\u002Flink-local ranges\n- Enforce TLS-only outbound traffic\n- Strip sensitive upstream response headers at the proxy\n\n```bash\n# 6. Run the application\n.\u002Fsub2api\n```\n\n#### Development Mode\n\n```bash\n# Backend (with hot reload)\ncd backend\ngo run .\u002Fcmd\u002Fserver\n\n# Frontend (with hot reload)\ncd frontend\npnpm run dev\n```\n\n#### Code Generation\n\nWhen editing `backend\u002Fent\u002Fschema`, regenerate Ent + Wire:\n\n```bash\ncd backend\ngo generate .\u002Fent\ngo generate .\u002Fcmd\u002Fserver\n```\n\n---\n\n## Simple Mode\n\nSimple Mode is designed for individual developers or internal teams who want quick access without full SaaS features.\n\n- Enable: Set environment variable `RUN_MODE=simple`\n- Difference: Hides SaaS-related features and skips billing process\n- Security note: In production, you must also set `SIMPLE_MODE_CONFIRM=true` to allow startup\n\n---\n\n## Antigravity Support\n\nSub2API supports [Antigravity](https:\u002F\u002Fantigravity.so\u002F) accounts. After authorization, dedicated endpoints are available for Claude and Gemini models.\n\n### Dedicated Endpoints\n\n| Endpoint | Model |\n|----------|-------|\n| `\u002Fantigravity\u002Fv1\u002Fmessages` | Claude models |\n| `\u002Fantigravity\u002Fv1beta\u002F` | Gemini models |\n\n### Claude Code Configuration\n\n```bash\nexport ANTHROPIC_BASE_URL=\"http:\u002F\u002Flocalhost:8080\u002Fantigravity\"\nexport ANTHROPIC_AUTH_TOKEN=\"sk-xxx\"\n```\n\n### Hybrid Scheduling Mode\n\nAntigravity accounts support optional **hybrid scheduling**. When enabled, the general endpoints `\u002Fv1\u002Fmessages` and `\u002Fv1beta\u002F` will also route requests to Antigravity accounts.\n\n> **⚠️ Warning**: Anthropic Claude and Antigravity Claude **cannot be mixed within the same conversation context**. Use groups to isolate them properly.\n\n### Known Issues\n\nIn Claude Code, Plan Mode cannot exit automatically. (Normally when using the native Claude API, after planning is complete, Claude Code will pop up options for users to approve or reject the plan.)\n\n**Workaround**: Press `Shift + Tab` to manually exit Plan Mode, then type your response to approve or reject the plan.\n\n---\n\n## Project Structure\n\n```\nsub2api\u002F\n├── backend\u002F                  # Go backend service\n│   ├── cmd\u002Fserver\u002F           # Application entry\n│   ├── internal\u002F             # Internal modules\n│   │   ├── config\u002F           # Configuration\n│   │   ├── model\u002F            # Data models\n│   │   ├── service\u002F          # Business logic\n│   │   ├── handler\u002F          # HTTP handlers\n│   │   └── gateway\u002F          # API gateway core\n│   └── resources\u002F            # Static resources\n│\n├── frontend\u002F                 # Vue 3 frontend\n│   └── src\u002F\n│       ├── api\u002F              # API calls\n│       ├── stores\u002F           # State management\n│       ├── views\u002F            # Page components\n│       └── components\u002F       # Reusable components\n│\n└── deploy\u002F                   # Deployment files\n    ├── docker-compose.yml    # Docker Compose configuration\n    ├── .env.example          # Environment variables for Docker Compose\n    ├── config.example.yaml   # Full config file for binary deployment\n    └── install.sh            # One-click installation script\n```\n\n## Disclaimer\n\n> **Please read carefully before using this project:**\n>\n> :rotating_light: **Terms of Service Risk**: Using this project may violate Anthropic's Terms of Service. Please read Anthropic's user agreement carefully before use. All risks arising from the use of this project are borne solely by the user.\n>\n> :book: **Disclaimer**: This project is for technical learning and research purposes only. The author assumes no responsibility for account suspension, service interruption, or any other losses caused by the use of this project.\n\n---\n\n## Star History\n\n\u003Ca href=\"https:\u002F\u002Fstar-history.com\u002F#Wei-Shaw\u002Fsub2api&Date\">\n \u003Cpicture>\n   \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"https:\u002F\u002Fapi.star-history.com\u002Fsvg?repos=Wei-Shaw\u002Fsub2api&type=Date&theme=dark\" \u002F>\n   \u003Csource media=\"(prefers-color-scheme: light)\" srcset=\"https:\u002F\u002Fapi.star-history.com\u002Fsvg?repos=Wei-Shaw\u002Fsub2api&type=Date\" \u002F>\n   \u003Cimg alt=\"Star History Chart\" src=\"https:\u002F\u002Fapi.star-history.com\u002Fsvg?repos=Wei-Shaw\u002Fsub2api&type=Date\" \u002F>\n \u003C\u002Fpicture>\n\u003C\u002Fa>\n\n---\n\n## License\n\nThis project is licensed under the [GNU Lesser General Public License v3.0](LICENSE) (or later).\n\nCopyright (c) 2026 Wesley Liddick\n\n---\n\n\u003Cdiv align=\"center\">\n\n**If you find this project useful, please give it a star!**\n\n\u003C\u002Fdiv>\n","Sub2API 是一个一站式开源中转服务平台，旨在统一接入 Claude、OpenAI、Gemini 和 Antigravity 等 AI 服务的订阅，支持拼车共享以更高效地分摊成本。项目使用 Go 语言开发，并集成了 Vue、PostgreSQL 和 Redis 等技术栈，提供 Docker 部署方案。其核心功能包括多账户管理、API Key 分发、精准计费、智能调度、并发控制和速率限制等，内置支付系统支持多种支付方式。此外，还提供了管理员仪表盘和外部系统集成能力。适用于需要对多个 AI 服务进行统一管理和成本优化的场景，如企业级应用、开发者社区或研究机构。",2,"2026-06-11 02:31:32","trending"]