RepoDaily · 2026-08-23 · AI model / Agent framework

Sub2API: Open-Source Go Gateway That Pools Claude, OpenAI, Gemini, and Grok Subscriptions Into One API

#17 AI model / Agent framework Go +264 Wei-Shaw/sub2api Open repository

A Go gateway that pools Claude, OpenAI, Gemini, and Grok subscriptions into one API with cost-sharing — while its own README warns the setup may violate upstream terms of service.

Repo typeAI model / Agent framework
Best forSmall groups already paying for Claude, OpenAI, Gemini, or Grok subscriptions who want to pool quota behind one self-hosted API and keep native clients such as Claude Code and Codex working.
Risk levelHigh — the README itself warns use may violate Anthropic's and other providers' terms
Time to evaluateHalf a day: provision PostgreSQL 15+ and Redis 7+, build the Docker image, wire up one native client

Primary question: Are you willing to accept upstream terms-of-service and account-ban risk in exchange for shared subscription quota behind a single self-hosted endpoint?

87/100

RepoDaily adoption score

RepoDaily rates this as 87/100 (strong) for adoption: evidence, installation path, production risk, differentiation, license clarity, and AI/agent fit are scored from the article sources and adoption notes.

Directional score from RepoDaily sources and adoption notes, not a benchmark.Risk: High
100Evidence quality

5 source(s) across 4 source category/categories, plus a RepoDaily-specific evidence module when available.

100Installability

5 workflow step(s), 4 next-action step(s), and 3 command/install signal(s) were detected.

51Maintenance confidence

Trending momentum is +264 stars, with maintenance/release/issue signals counted when present.

74Production readiness

Risk is marked high, with 4 security note(s) and 4 explicit skip condition(s).

100Differentiation

3 opportunity lens item(s), 4 alternative(s), and 3 type-specific section(s) support differentiation.

82License clarity

License source or license wording is present.

100Agent / AI fit

7 AI/agent-related signal(s) were detected in the article text and metadata.

Project overview

Sub2API calls itself an "AI API Gateway Platform for Subscription Quota Distribution." The Chinese repository description makes the pitch concrete: unify Claude, OpenAI, Gemini, and Grok subscriptions behind one access point, support 拼车-style shared use so a group can split the cost, and keep native tools working without friction. The backend is Go (README badge pins Go 1.26.5) with a Vue 3.4+ admin frontend, and the project targets a very specific pain: per-seat AI subscriptions strand quota on light users while heavy users hit caps mid-task.

On 2026-08-23 the repository ranked 17th on the daily trend list with 264 stars in the measurement window, and the README embeds a Trendshift badge (repository 21823) tracking momentum. The topic list — 2api, cc2api, antigravity2api, crs, crs2, claude-code, codex, gemini — maps almost one-to-one onto converter-style tooling for specific coding assistants. That tells you who this is for: developers already living inside Claude Code and Codex who want their paid subscriptions exposed as an API endpoint they control.

The engineering is disciplined. Beyond the Go/Vue/PostgreSQL/Redis badges, the Dockerfile is a three-stage build: node:24-alpine with pnpm@9 pinned "to match CI and keep builds reproducible" compiles the frontend; golang:1.26.6-alpine cross-compiles a CGO_ENABLED=0 binary; the final image is alpine:3.21. The built frontend is embedded into the Go binary at internal/web/dist behind the embed build tag, so one process serves both API and admin UI. Release engineering is deliberate too: version info resolves through a defined precedence — VERSION build argument, then exact git tag, then cmd/server/VERSION — via scripts/resolve-version.sh.

What sets this repository apart is how blunt the governance section is. The README opens with an "Important Notice" stating that using the project may violate the terms of service of Anthropic and other upstream providers, that it is provided for technical learning and research, that the developers have never authorized any commercial operation based on it, and that account bans, service interruptions, and data loss are the user's risk alone. The code is licensed under GNU LGPL-3.0. Those two facts — solid build engineering and candid legal warnings — frame every decision about this project.

Problem it solves

  • Per-seat AI subscriptions strand unused quota on light users while heavy users hit rate caps mid-task.
  • Native clients such as Claude Code and Codex bind to a specific account; informal sharing means passing credentials around by hand.
  • Commercial relays charge again for model capability a group has already paid for through subscriptions.
  • Small groups lack a self-hosted middle layer that meters shared quota without handing credentials to a third party.

How it works

  1. Self-host the platform: a Go 1.26.5 backend with an embedded Vue 3.4+ admin frontend, backed by PostgreSQL 15+ and Redis 7+ as required services (README badges).
  2. Register upstream subscription accounts (Claude, OpenAI, Gemini, Grok) in the gateway, which presents a unified API surface per the repository description.
  3. Group members draw from the pooled quota through issued API access — the 拼车 (car-pool) sharing model — so subscription cost is split across the group.
  4. Point native tools such as Claude Code or Codex at the gateway so members keep using them without individual account logins (描述中的“原生工具无缝使用”).
  5. Admins operate a compliance surface built into the product: the Dockerfile shows LegalDocumentView.vue importing docs/legal/*.md at build time, compiling legal documents into the admin UI.

Product demo and interface preview

Nagora logo displayed in the Sub2API README partners section
Nagora partner logo — The README ships partner logos such as Nagora under assets/partners/logos/, the same directory that carries the sponsor row surrounding the project. README.md image
Qiniu AI logo displayed in the Sub2API README partners section
Qiniu AI partner logo — Partner logos like Qiniu AI illustrate the commercial relay and cloud services that cluster around this self-hosted gateway. README.md image

Architecture read: what the three-stage Dockerfile reveals

Stage one runs on node:24-alpine and activates pnpm@9 through corepack, pinned specifically "to match CI and keep builds reproducible." Dependencies install from frontend/package.json and frontend/pnpm-lock.yaml with --frozen-lockfile, then the Vue app builds. One telling detail: the Dockerfile comments that LegalDocumentView.vue — described as the admin-compliance gate — imports docs/legal/*.md?raw at build time, so the docs/legal directory must sit beside frontend/ inside the image. Legal text is a compiled-in artifact, not an afterthought.

Stage two runs the Go toolchain on golang:1.26.6-alpine, copies backend/go.mod and backend/go.sum first for layer caching, and cross-compiles with CGO_ENABLED=0, taking GOOS/GOARCH from buildx. The binary is built with -tags embed and stripped with -ldflags="-s -w", and the frontend dist from stage one is copied into internal/web/dist. Stage three lands on alpine:3.21. The file also declares GOPROXY=https://goproxy.cn and GOSUMDB=sum.golang.google.cn as default build arguments — mirrors that make builds deterministic from mainland China — plus a POSTGRES_IMAGE=postgres:18-alpine argument for the database side.

Deployment notes: the stack you must bring

  • Backend Go 1.26.5 and frontend Vue 3.4+ per the README badges.
  • PostgreSQL 15+ and Redis 7+ are required external services, not bundled.
  • Docker is the packaging path ("Docker Ready" badge; the multi-stage Dockerfile is in the repo root).
  • The frontend ships inside the Go binary (internal/web/dist, embed tag), so no separate static-file host is needed.
  • Version string precedence is explicit: VERSION build argument > exact git tag > cmd/server/VERSION, resolved by scripts/resolve-version.sh.
  • Default GOPROXY (goproxy.cn) and GOSUMDB (sum.golang.google.cn) build arguments favor reproducible builds from mainland China networks.

Maintenance and legal risk read

  • The README's Important Notice names Anthropic and other upstream providers whose terms may be violated by using the project.
  • The developers state they have never authorized any commercial operation based on the project; disputes and losses fall on the operator.
  • The disclaimer explicitly covers account bans, service interruptions, and data loss as user-borne risks.
  • LGPL-3.0 Section 4 permits combined works under terms of your choice only with prominent notice of Library use, accompanying license copies, and preserved modification/reverse-engineering rights for Library portions.
  • Version-resolution machinery (build arg > git tag > cmd/server/VERSION) indicates a CI-driven release process rather than ad-hoc builds.

Who should pay attention?

Good fit if

  • Small groups already paying for Claude, OpenAI, Gemini, or Grok subscriptions who want to pool quota and split one bill.
  • Self-hosters comfortable running Go plus PostgreSQL 15+ and Redis 7+ behind Docker.
  • Claude Code and Codex users who want a single endpoint instead of per-member account logins.
  • Researchers studying gateway design: the README frames the project as being for technical learning and research, under LGPL-3.0.

Skip for now if

  • Anyone whose upstream provider terms forbid account or API sharing — the README itself flags possible violations of Anthropic's and other providers' agreements.
  • Commercial operators: the developers explicitly grant no commercial authorization for this project.
  • Groups needing vendor accountability — the disclaimer disclaims liability for bans, interruptions, and data loss.
  • Anyone unwilling to operate their own PostgreSQL and Redis instances.

Risks and cautions

High

The project's own documentation is the strongest risk statement available: it warns that use may breach Anthropic's and other upstream providers' terms, disclaims all liability, and denies commercial authorization.

  • The README's Important Notice states using the project "may violate the terms of service of Anthropic and other upstream providers."
  • The disclaimer assigns account bans, service interruptions, and data loss entirely to the user.
  • The developers state they have never authorized any commercial operation based on the project.
  • Pooling concentrates blast radius: one upstream ban on a shared subscription can cut off the entire group at once.
  • The source pack contains no security-audit or disclosure-policy document, so plan your own review before trusting the gateway with live credentials.
  • The gateway necessarily stores upstream subscription credentials for multiple providers, which makes hardening the PostgreSQL 15+ and Redis 7+ instances critical.
  • The build produces a CGO_ENABLED=0 static binary in a minimal alpine:3.21 final stage, shrinking the runtime surface compared with full-OS images.
  • An admin-compliance gate (LegalDocumentView.vue) renders docs/legal/*.md inside the admin UI, showing legal documents are surfaced to operators rather than buried in the repo.

Alternatives to compare

ApproachWhen to useTrade-off
LiteLLM (Proxy)
You want one OpenAI-format endpoint across many providers with keys and budgets, without subscription pooling.Open-source, self-hosted; you pay upstream usage.
one-api
You want a long-established self-hosted relay management panel for token-style accounts.Open-source, self-hosted; you pay upstream usage.
OpenRouter
You prefer a hosted model catalog with per-token billing and no self-hosting at all.Pay-per-token; no self-hosting.
Sponsored relays (CCTK.AI, OpenModel, ETok.ai)
You want managed relay access to Claude, OpenAI, and Gemini models compatible with Claude Code and Codex, as advertised in the README's sponsor section.Paid plans; affiliate registration links in the README.

What this trend reveals

Quota pooling for small studios

A three-to-ten person group paying for separate Claude, OpenAI, Gemini, and Grok seats can consolidate into pooled access where heavy users absorb idle quota.

Read your provider's user agreement first — the README puts terms-of-service risk entirely on the user — then run one subscription through the gateway before adding members.

Subscription spend consolidation

The gateway gives a single place where pooled consumption lands in the PostgreSQL 15+ database the stack already requires, making one shared bill auditable.

Run a two-week pilot with one subscription and compare per-seat invoices against pooled consumption recorded in the gateway.

Compliance-first internal relay

Because LegalDocumentView.vue compiles docs/legal/*.md into the admin UI, legal review can ship as part of the build rather than as a separate wiki page.

Have counsel review the docs/legal directory and the upstream terms before enabling any shared account, and record sign-off in those same documents.

Best next action

Run a one-subscription pilot inside Docker

Prove the stack and the risk posture with a single account you can afford to lose before any group depends on it.

  1. Read the README's Important Notice and your provider's user agreement; the project states all resulting risk is yours.
  2. Provision PostgreSQL 15+ and Redis 7+ per the README badges, then build the Docker image — the multi-stage Dockerfile produces one CGO_ENABLED=0 binary with the Vue frontend embedded at internal/web/dist.
  3. Register one subscription account whose loss would not hurt; the disclaimer names account bans as a user-borne outcome.
  4. Point a single native client such as Claude Code at the gateway and track usage for two weeks before inviting additional members.

RepoDaily verdict

Technically credible and unusually honest: a three-stage Docker build, trilingual docs, and an LGPL-3.0 license wrapped around a use case the README itself says may breach upstream terms. Adopt it only if you have read those terms and accept account-ban risk; otherwise treat it as a reference design for self-hosted gateway engineering.

Sources