AgentConn
S

sub2api

Coding Free

About sub2api

sub2api (Wei-Shaw/sub2api, also branded Sub2API-CRS2) is an open-source API relay service that lets developers and small teams pool their AI subscriptions — Claude, OpenAI, Gemini, Antigravity — behind a single OpenAI-compatible endpoint. Written in Go and self-hosted, sub2api solves two problems at once: vendor switching (route requests to whichever provider has capacity, cheapest pricing, or the right model) and cost amortization (multiple users share one or more subscriptions instead of each maintaining separate accounts). Originated in the Chinese developer community and rapidly spreading globally — the repo passed 15K stars on April 24, 2026 with sustained +250 to +400 stars/day for the third week. Native tool compatibility means any client expecting an OpenAI-compatible endpoint (Claude Code, Codex, Cursor, custom agents) just works. Open source, MIT licensed, single-binary deployment.

Key Features

  • Multi-vendor relay — Claude, OpenAI, Gemini, Antigravity behind one endpoint
  • OpenAI-compatible API surface — drop-in for any OpenAI-SDK client
  • Subscription pooling — multiple users share access via one provider account
  • Cost-sharing groups (拼车) — split subscription cost across team members
  • Provider failover and rate-limit handling — automatic routing on errors
  • Native tool support — Claude Code, Codex, Cursor work without modification
  • Single Go binary — self-hosted, no Python runtime, no cloud lock-in
  • Open source, MIT licensed

Overview

sub2api occupies a specific economic niche that the major AI vendors have left open: subscription-tier pricing rewards heavy individual users but punishes light users and small teams. A solo developer paying $200/month for Claude Pro might use 30% of their quota; a five-person team paying five separate $200/month subscriptions wastes most of the spend. sub2api lets that team run one Pro subscription through a self-hosted relay, shared across all five developers, with usage tracking, rate-limit fairness, and provider failover.

The repo is published by Wei-Shaw and originated in the Chinese developer community — the term “拼车” (literally “carpool”) in the README signals the cultural framing: subscription-sharing is normalized as cost-amortization, not piracy. The English description (“one-stop open-source relay service, unified access for Claude, OpenAI, Gemini, Antigravity subscriptions”) makes the same offer to global developers.

Why It Matters

The vendor-lock-in critique of major AI subscription products has, until recently, been theoretical. sub2api is part of a small but growing class of tools — alongside cc-switch, OpenRouter, and various proxy services — that operationalize the critique. If you can route any agent request to any provider, billing through any subscription, the vendor’s pricing power weakens.

The repo also carries political weight in the OpenClaw discourse: when Anthropic changes pricing, terms, or rate limits, users with sub2api can immediately reroute to alternative providers without rewriting their agent integrations. cc-switch handles the multi-CLI configuration problem; sub2api handles the multi-provider runtime problem. Together they form an “agent infrastructure independence” stack.

Key Capabilities

OpenAI-compatible endpoint: sub2api exposes a /v1/chat/completions endpoint that any OpenAI SDK client can hit. Claude Code, Codex, Cursor, custom agents — they all work without code changes, just an environment variable swap.

Multi-vendor routing: Route requests to specific providers by model name, by cost, by latency, or via a configured fallback chain. If Claude returns a 529, the request transparently falls back to GPT-5.5 or Gemini 3.

Subscription pooling: Connect one or more subscription accounts (Claude Pro, ChatGPT Plus, Gemini Advanced) and pool the quota across users. Per-user usage tracking, configurable rate limits, fair queueing under contention.

Cost-sharing groups: The “拼车” feature lets a small team formally split costs — each user has a sub-account, the relay tracks usage, and the bill divides proportionally at month-end.

Self-hosted single binary: Download the Go binary, configure providers via YAML, run on any Linux/macOS/Windows machine. No Docker required, no cloud account, no telemetry.

Getting Started

# Download binary from releases
curl -L https://github.com/Wei-Shaw/sub2api/releases/latest/download/sub2api-linux-amd64 -o sub2api
chmod +x sub2api
# Configure providers in config.yaml, then run
./sub2api serve

Point any OpenAI-compatible client at http://localhost:8080/v1 with a sub2api-issued key. From there, the relay handles provider routing, failover, and quota distribution automatically.

Who It’s For

Small teams (2-10 developers) who want to share AI subscriptions without each member paying separately. Solo developers with side projects who want to consolidate Claude, OpenAI, and Gemini access through one billing surface and one client config. Agent builders who need multi-provider failover for production reliability. Anyone whose workflow has been disrupted by AI vendor pricing or policy changes and who wants the operational option to switch providers in seconds.

Similar Agents