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
- vorssaint/vorssaint-utilsOne free menu bar app replaces a dozen paid Mac utilities
- Alishahryar1/free-claude-codeA local proxy that lets coding AI agents run on 49 free or cheap model providers instead of one paid service
- freestylefly/awesome-gpt-image-2A library of 532 reverse-engineered prompts that turn GPT-Image2 into a predictable image-making tool
- block/buzzAn open-source workspace where humans and AI agents chat, code, and review in the same rooms
- NousResearch/hermes-agentNous Research's Hermes is an AI agent that gets smarter the more you use it
- virgiliojr94/book-to-skillA tool that turns technical book PDFs into on-demand reference skills for AI coding agents
- VoltAgent/awesome-agent-skillsA single hub collecting over 1000 'how-to' manuals that make AI coding assistants act like experts
- anthropics/claude-plugins-communityA shared shelf where anyone's Claude add-ons get listed for install