Wei-Shaw/sub2api
A relay server that lets one Claude/OpenAI/Gemini/Grok subscription be shared by many users
Sub2API is a gateway program: you register subscription or API-key accounts for services like Claude, OpenAI, Gemini, and Grok, and it issues separate API keys so multiple users can share the pooled quota. It tracks usage down to the token level for accurate billing and automatically spreads requests across healthy accounts. It's an open-source Go project you self-host via Docker or an install script.
What it does
- Issues individual API keys against a shared pool of subscription accounts and calculates cost at the token level so usage can be split fairly among users
- Supports both OAuth-login accounts and API-key accounts, auto-routes requests to healthy accounts, and enforces per-user and per-account concurrency and rate limits
- Provides compatible endpoints so coding tools like Claude Code, Codex, and Gemini CLI connect the same way they normally would, plus dedicated support for Grok and Antigravity accounts
- Includes a built-in payment system (Alipay, WeChat Pay, Stripe, EasyPay) and an admin dashboard, so users can self-service top up without a separate billing system
- Backend built on Go 1.26.5, Gin, PostgreSQL, and Redis with a Vue 3 frontend, deployable via install script, Docker Compose, or building from source
Why it matters
It's a practical piece of infrastructure for developers or small teams trying to cut costs by pooling expensive AI subscriptions. The README explicitly warns that using it may violate upstream providers' terms of service, so there's real legal and account-ban risk attached.
Terms in this repo
- OAuth · a standard way of delegating login authentication using tokens instead of passwords
- API gateway · a server that centrally handles authentication, billing, and routing for requests to other services
- sticky session · routing a given user's requests to the same account/backend every time
Repository description (English)
Sub2API 一站式开源中转服务,让 Claude、Openai 、Gemini、Grok订阅统一接入,支持拼车共享,更高效分摊成本,原生工具无缝使用。
Open on GitHubTrending repos
- openai/codexOpenAI's coding agent, now runnable straight from your terminal
- cordiverse/cordisA TypeScript framework for snapping feature pieces on and off whenever you need them
- ripienaar/free-for-devA single repo lists every free-tier cloud, API and collaboration tool developers actually need
- multica-ai/andrej-karpathy-skillsA single instruction file that stops AI coding assistants from making silent bad guesses
- eneskirca/nodetermA workspace that puts scattered terminal tabs and AI coding agents on one draggable map
- affaan-m/ECCA toolkit that teaches AI coding agents to work like disciplined engineers
- n8n-io/n8nn8n lets you build automation workflows and AI agents by dragging nodes on a canvas, with code as a fallback
- apache/makaAn AI agent workspace that keeps everything running on your own machine, with every action logged