Scripts2026年7月2日·1 分钟阅读

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 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 66/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Sub2API
先审查命令
npx -y tokrepo@latest install cf58cb67-7631-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产