Sub2API
Self-hosted gateway that redistributes AI subscriptions as token-billed API keys, with upstream ToS risk on the user.
What it is
Sub2API is an open-source gateway that turns subscriptions to AI products such as Claude, OpenAI, Gemini, and Grok into API services. The README positions it as a "subscription quota distribution" platform: an official subscription account is attached on the upstream side, the gateway generates a batch of platform API Keys, and handles authentication, billing, load balancing, and request forwarding in one place, so multiple users can share the same subscription. The stack is a Go backend with a Vue frontend, data is stored in PostgreSQL and Redis, and Docker deployment is officially provided.
How it runs
The project ships with a Dockerfile, Makefile, and a deploy directory; the README does not give a complete startup command sequence, so specific configuration follows the repository's deploy directory. It has three runtime dependencies: PostgreSQL 15+, Redis 7+, and Docker. Once started, the gateway serves both the backend API and the Vue admin panel, and subscription accounts and API Keys are both managed in the panel.
Core mechanics
- Subscription quota distribution: Supports two kinds of upstream accounts, OAuth and API Key; the quota of one subscription is split across multiple platform users by request.
- Token-level billing: Records and calculates cost by token usage, with a built-in payment system, making it easy to build a small usage-billed relay of your own.
- Smart scheduling: Automatically picks upstream accounts and keeps sticky sessions; there are also two-tier concurrency limits per user and per account, plus configurable request and token rate limiting.
- Protocol compatibility: Exposes interfaces compatible with OpenAI and other protocols externally; native tools such as Claude Code and Codex can connect just by changing the Base URL.
Who it's for
People who hold a Claude or ChatGPT subscription and want to split the quota for a team to share; developers who want to build their own API relay station and bill users by usage are equally suited — payment and rate limiting are already done for you.
Usage boundaries
The project states that using it may violate the terms of service of upstream providers such as Anthropic, and risks such as account bans and service interruptions are borne entirely by the user; the official stance only endorses technical learning and research use, and explicitly states that no form of commercial operation has ever been authorized. Self-hosting means the backend, database, and deployment all have to be maintained by yourself; the accompanying proxy and top-up third-party services are sponsors in the README rather than required components.