Sub2API
An open-source AI API gateway platform that unifies Claude, OpenAI, Gemini, and other AI subscriptions into a single endpoint with quota distribution, billing, and multi-account management.
At a Glance
Fully open-source under LGPL-3.0. Free to self-host, modify, and distribute.
Engagement
Available On
Listed Jul 2026
About Sub2API
Sub2API is an open-source AI API gateway platform built in Go and Vue 3, designed to distribute and manage API quotas from AI product subscriptions. It lets operators pool multiple upstream AI accounts (Claude, OpenAI Codex, Gemini, Grok/xAI, Antigravity) behind a single endpoint and issue API keys to end users. The project is licensed under the GNU Lesser General Public License v3.0 and is actively maintained on GitHub, where it has accumulated over 29,000 stars as of mid-2026.
What It Is
Sub2API sits between end users and upstream AI providers, acting as a relay and quota-distribution layer. Administrators add upstream accounts (via OAuth or API key), and the platform generates API keys for users, tracks token-level usage, enforces concurrency and rate limits, and handles billing. It is self-hosted — operators deploy it on their own Linux servers or via Docker — and is aimed at developers, teams, and relay service operators who want to share or resell AI subscription capacity.
Core Architecture
The platform is built on a modern, containerizable stack:
- Backend: Go 1.25.7 with Gin and Ent ORM
- Frontend: Vue 3.4+, Vite 5+, TailwindCSS (embedded into the binary at build time)
- Database: PostgreSQL 15+
- Cache/Queue: Redis 7+
The gateway core handles intelligent account selection with sticky sessions, per-user and per-account concurrency controls, and configurable rate limiting. A built-in payment system supports EasyPay, Alipay, WeChat Pay, and Stripe for user self-service top-ups without a separate payment service.
Supported Upstream Providers
Sub2API supports a range of upstream AI services:
- Anthropic Claude — via OAuth subscription accounts; compatible with Claude Code CLI
- OpenAI Codex — forwarded as OpenAI-compatible Responses and Chat Completions traffic
- Google Gemini — via
/v1beta/endpoints - Grok / xAI — via PKCE OAuth, supporting models like
grok-4.3andgrok-build-0.1; routes/v1/responses,/v1/messages, and/v1/chat/completionsto xAI - Antigravity — dedicated endpoints at
/antigravity/v1/messages(Claude) and/antigravity/v1beta/(Gemini), with optional hybrid scheduling
Deployment Model
Three deployment paths are documented in the repository:
- Script installation (recommended for Linux) — a one-click
install.shdownloads pre-built binaries, installs to/opt/sub2api, and creates a systemd service. Upgrades are available directly from the admin dashboard. - Docker Compose — includes PostgreSQL and Redis containers; an automated
docker-deploy.shscript generates secure credentials and creates data directories. A local-directory variant (docker-compose.local.yml) simplifies backup and migration. - Build from source — requires Go 1.21+, Node.js 18+, PostgreSQL, and Redis. The frontend is embedded into the Go binary using the
-tags embedbuild flag.
A Simple Mode (RUN_MODE=simple) is available for individual developers or internal teams who want quick access without full SaaS billing features.
Update: v0.1.141
The latest release is v0.1.141, published on 2026-06-30, with the repository last pushed on 2026-07-01. The project has been under rapid development since its creation in December 2025, accumulating over 6,000 forks. Recent additions include built-in payment processing (previously a separate Sub2ApiPay project), Grok/xAI OAuth support with PKCE, Antigravity account integration, a mobile admin console companion app (sub2api-mobile built with Expo + React Native), and a growing ecosystem of community relay services built on top of the platform. The README notes that Sora-related features are temporarily unavailable due to upstream integration issues.
Tradeoffs and Compliance Risks
The README prominently warns that using Sub2API may violate the terms of service of Anthropic and other upstream providers. The project explicitly states it is provided for technical learning and research purposes only, and that all risks from use — including account bans and service interruptions — are borne solely by the user. Security configuration options include CORS allowlists, upstream URL allowlists, response header filtering, Cloudflare Turnstile support, and a circuit breaker for billing errors. HTTP upstream URLs are rejected by default and require explicit opt-in, which the documentation marks as insecure and unsuitable for production.
Community Discussions
Be the first to start a conversation about Sub2API
Share your experience with Sub2API, ask questions, or help others learn from your insights.
Pricing
Open Source
Fully open-source under LGPL-3.0. Free to self-host, modify, and distribute.
- Multi-account management
- API key distribution
- Token-level billing
- Built-in payment system
- Admin dashboard
Capabilities
Key Features
- Multi-account management for upstream AI providers (OAuth and API Key)
- API key generation and distribution for end users
- Token-level usage tracking and billing
- Intelligent account selection with sticky sessions
- Per-user and per-account concurrency limits
- Configurable request and token rate limits
- Built-in payment system (EasyPay, Alipay, WeChat Pay, Stripe)
- Admin dashboard with web UI
- Support for Claude, OpenAI Codex, Gemini, Grok/xAI, and Antigravity
- Grok/xAI OAuth with PKCE
- Antigravity hybrid scheduling mode
- Simple Mode for individual developers
- One-click script installation with systemd service
- Docker Compose deployment with auto-generated credentials
- In-dashboard upgrade and rollback
- External system integration via iframe
- Mobile admin console companion app
- CORS and URL allowlist security controls
- Cloudflare Turnstile support
