ScriptsJul 2, 2026·2 min read

Sub2API — Unified Relay for Multiple AI Subscription Endpoints

An open-source relay platform that unifies Claude, OpenAI, Gemini, and other AI subscriptions into a single API endpoint with account sharing support.

Agent ready

Review-first install path

This asset needs a review step. The copied prompt tells the agent to dry-run, show the writes, then proceed only after confirmation.

Needs Confirmation · 66/100Policy: confirm
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
Sub2API
Review-first command
npx -y tokrepo@latest install cf58cb67-7631-11f1-9bc6-00163e2b0d79 --target codex

Dry-run first, confirm the writes, then run this command.

Introduction

Sub2API is an open-source relay platform written in Go that consolidates multiple AI provider subscriptions into a single unified API endpoint. It supports Claude, OpenAI, Gemini, and other providers, enabling teams to share and manage AI access through one gateway.

What Sub2API Does

  • Proxies requests to multiple AI providers through a single endpoint
  • Supports load balancing across multiple subscription accounts
  • Provides token usage tracking and quota management per account
  • Offers an OpenAI-compatible API format for broad tool compatibility
  • Enables team access sharing with per-user rate limiting

Architecture Overview

Sub2API is a stateless Go binary that acts as a reverse proxy. Incoming API requests are routed to the appropriate provider based on model name and configuration rules. Account credentials are stored in a YAML config file and rotated automatically when rate limits are hit. The relay translates between provider-specific API formats and presents a unified OpenAI-compatible interface.

Self-Hosting & Configuration

  • Build from source with Go 1.21+ or use pre-built Docker images
  • Configure provider accounts and credentials in config.yaml
  • Set per-account rate limits and priority ordering
  • Enable optional authentication for downstream clients
  • Deploy behind a reverse proxy for TLS termination

Key Features

  • Single endpoint for Claude, OpenAI, Gemini, and more
  • Automatic failover and load balancing across accounts
  • OpenAI-compatible API format for broad tool compatibility
  • Per-user and per-account usage tracking
  • Lightweight Go binary with minimal resource requirements

Comparison with Similar Tools

  • LiteLLM — Python-based proxy with more features; Sub2API is Go-native and lighter
  • OpenRouter — managed service; Sub2API is fully self-hosted
  • Portkey AI Gateway — enterprise-focused; Sub2API is simpler to deploy
  • one-api — similar concept; Sub2API focuses on subscription-based account management

FAQ

Q: Does Sub2API store my API keys securely? A: Keys are stored in the config file. Use file permissions and secrets management for production deployments.

Q: Can I use it with tools that expect an OpenAI API? A: Yes. Sub2API exposes an OpenAI-compatible endpoint, so most tools work without modification.

Q: How does load balancing work? A: Requests are distributed across configured accounts based on priority and remaining quota.

Q: Is there a web dashboard? A: The project focuses on the API relay. Usage metrics are available via API endpoints for integration with external dashboards.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets