Skip to content
FossShelf
Home / Categories / For AI Engineers

sub2api

One API gateway for Claude, OpenAI, Gemini, and Grok subscriptions

Replaces Openrouter, Portkey, Litellm, Truefoundry, Aiapi World

46.12K starsLGPL-3.0reviewed 23 Aug 2026last commit 14 Nov 2026
Screenshot of sub2api

Who it's for

Solo developers routing Claude Pro through CLI tools

Developers who pay for Claude Pro but do most work in Claude Code can use Sub2API to route their subscription quota through the CLI without paying separate per-token API costs. Sub2API bridges the gap between the browser-based subscription and the tool's API key expectation.

Skip if you already have a direct Anthropic API account with sufficient credits. The API path avoids the relay infrastructure and ToS risk entirely; Sub2API is most useful when the cost difference between subscription and per-token API pricing is large enough to justify the added complexity.

Small teams sharing AI subscription costs

A team of three to five developers can pool one or two AI subscriptions behind a Sub2API instance, splitting the flat monthly fee instead of each member paying individual API credits. The multi-user carpool feature is designed specifically for this workflow.

Skip if your team uses AI tools at low volume where per-token billing is already inexpensive. The infrastructure overhead of PostgreSQL, Redis, and an application server outweighs the cost saving unless usage volume is high enough that subscription pricing is meaningfully cheaper.

LLMOps engineers experimenting with multi-provider routing

Engineers building agent pipelines or evaluation harnesses can use Sub2API to route requests across Claude, OpenAI, and Gemini through one endpoint, comparing provider behavior without managing separate credentials per model family.

Skip for production LLMOps workloads where provider ToS compliance is a hard requirement. The relay architecture may violate provider agreements, which introduces account risk in regulated or commercial deployment environments.

The problem

Official API access to Anthropic, OpenAI, and Google AI is metered per token. For developers building with AI-assisted tools, costs scale fast: a heavy Claude Code session can consume millions of tokens in a week, and paying per-token API rates for that volume costs significantly more than a flat Pro subscription. The gap is structural. Personal AI subscriptions include quota that browser-based products consume, but development tools (Claude Code, Codex, Gemini CLI) require an API key rather than a browser session. Teams end up paying both: a subscription for manual use and API credits for automated workflows. Developers holding multiple AI subscriptions have capacity sitting unused by the tools they depend on most.

How it works

OpenAI-compatible API endpoint

Exposes all connected subscription accounts behind a single OpenAI-compatible HTTP interface. Tools that already speak the OpenAI protocol (Claude Code, Codex, Gemini CLI) need only a Base URL and API key change to connect, with no modification to the client application.

Multi-provider subscription aggregation

Accepts accounts from Claude, OpenAI, Gemini, and Grok subscriptions simultaneously and routes incoming API requests across them. Developers manage one gateway rather than maintaining separate credentials and endpoint configs for each provider.

Cost-sharing carpool mode

Multiple users share the same subscription quota through one Sub2API instance, splitting the flat monthly cost across a team. One Claude Pro or ChatGPT Plus subscription is distributed across several developers rather than each paying per-token API rates independently.

Go backend with Vue 3 admin interface

The server is written in Go 1.26.5 for low-overhead request proxying, with a Vue 3.4+ web interface for managing accounts, users, and routing configuration. PostgreSQL 15+ stores persistent state; Redis 7+ handles sessions and caching.

Docker-ready deployment stack

The full stack ships as Docker-ready services. Teams with a PostgreSQL database and Redis instance can deploy Sub2API without building from source. Container configuration covers the Go API server, the Vue frontend, and the required data stores.

Features

  • OpenAI-compatible API endpoint
  • Multi-provider subscription aggregation
  • Cost-sharing carpool mode
  • Go backend with Vue 3 admin interface
  • Docker-ready deployment stack

Recommended for this setup

Strengths

  • LGPL-3.0 license with full self-hosting: LGPL-3.0 lets you run Sub2API on your own infrastructure, modify it, and use it in proprietary internal tooling without releasing your source changes. Unlike commercial relay services, there are no per-call fees or subscription costs for the gateway itself.
  • 38,000+ stars and active maintenance: The repository reached 38,787 stars within months of its December 2025 creation and received its last push on 2026-08-22, indicating active development. That adoption rate reflects strong developer demand for subscription-based API relay tooling.
  • Native compatibility with AI coding tools: Sub2API exposes an OpenAI-compatible endpoint, so Claude Code, Codex, and Gemini CLI connect without custom adapters. The GitHub topics list claude-code and codex explicitly, reflecting tested compatibility with the tools developers actually run daily.

Trade-offs

  • Terms of service risk with upstream providers: The README explicitly warns that using Sub2API may violate the terms of service of Anthropic, OpenAI, and other upstream providers. Accounts used through the relay risk suspension or termination. The developers disclaim all liability; each user is responsible for reviewing provider agreements before deploying.
  • Requires PostgreSQL 15+ and Redis 7+: This is not a single-binary or single-container install. Running Sub2API means provisioning and maintaining PostgreSQL and Redis alongside the application server. Teams without existing infrastructure for these services will need to stand them up from scratch.
  • 2,800 open issues relative to project age: The project has 2,800 open issues against 38,787 stars, a ratio that suggests either a high defect rate or an under-resourced maintainer team given the project's rapid growth. Review recent issues before deploying Sub2API in any critical workflow.

Tech stack

Languages
Go, Vue, TypeScript, PLpgSQL, Shell, JavaScript, CSS, Dockerfile, Python, Makefile, HTML, Go Template
Frameworks
Vue
Databases
—
Tooling
—

FAQ

Is Sub2API free to use?

Sub2API itself is LGPL-3.0 licensed and free to self-host. You still need to pay for the underlying AI subscriptions (Claude Pro, ChatGPT Plus, Gemini Pro, etc.) that feed into it. Infrastructure costs for PostgreSQL and Redis are additional. There is no managed hosted version of Sub2API offered by the project maintainers.

Does using Sub2API violate AI provider terms of service?

The README explicitly warns that it may. Anthropic, OpenAI, and other providers have terms of service that may prohibit sharing subscription access or using subscriptions via automated API relay. The developers disclaim all liability for account suspensions or service interruptions. Review each provider's terms before deploying.

What AI providers does Sub2API support?

Based on the README and GitHub topics, Sub2API supports Claude (Anthropic), OpenAI (ChatGPT Plus), Gemini (Google), and Grok. The relay layer exposes an OpenAI-compatible API, so any tool that speaks the OpenAI protocol can connect through it without modification.

What infrastructure does Sub2API require to self-host?

Sub2API requires Docker, PostgreSQL 15+, and Redis 7+. The application server is written in Go 1.26.5. No minimum hardware specification is documented in the project README, but running three services (application server, PostgreSQL, Redis) typically needs at least 2GB of RAM on the host.

What does the LGPL-3.0 license mean for Sub2API users?

LGPL-3.0 lets you run and self-host Sub2API in internal or proprietary tooling without releasing your own source code. If you modify Sub2API itself and distribute those changes, you must release the modifications under LGPL. The project developers also note explicitly that no commercial operation has been authorized based on this project.

Similar tools

More in AI Engineers