{"slug": "open-source-project-no-73-sub2api-all-in-one-claude-openai-gemini-subscription", "title": "Open Source Project (No.73): Sub2API - All-in-One Claude/OpenAI/Gemini Subscription-to-API Relay", "summary": "Sub2API is an open-source AI API gateway platform developed in Go that consolidates multiple AI subscriptions (such as Claude Pro, OpenAI Plus, and Gemini) into a single, unified API endpoint. It features multi-account management, token-level billing, smart scheduling, and built-in payment support, enabling efficient resource sharing and cost distribution across teams or individual users. The project, maintained by Wei-Shaw and licensed under LGPL-3.0, has garnered over 22,000 GitHub stars and supports rapid deployment via one-click script installation or Docker Compose.", "body_md": "Introduction\n\"Fluidize your AI subscription quotas and maximize the value of every penny.\"\nThis is the No.73 article in the \"One Open Source Project per Day\" series. Today, we are exploring Sub2API (also known as CRS2).\nWith the rise of native AI power-tools like Claude Code and GitHub Copilot, many developers find themselves with multiple AI subscriptions (such as Claude Pro or OpenAI Plus). However, these subscriptions often come with usage limits or idle quotas. How can you consolidate these scattered subscription resources and distribute costs efficiently across different tools and users? Sub2API provides a perfect open-source solution.\nIt is more than just a simple forwarder; it is a full-featured API proxy platform that handles the entire pipeline — from account management and quota distribution to automated billing and built-in payments. It is particularly well-suited for team sharing, \"carpooling\" (shared-cost usage), or individual multi-account integration.\nWhat You Will Learn\n- The core positioning of Sub2API and the pain points it solves.\n- Supported mainstream models and subscription types.\n- Core features: Multi-account management, intelligent scheduling, and Token-level billing.\n- Rapid deployment methods: Script installation and Docker Compose.\n- How to use Sub2API to build your own AI API relay service.\nPrerequisites\n- Basic understanding of AI model APIs (OpenAI, Claude, Gemini, etc.).\n- Fundamental Linux command-line experience.\n- Familiarity with Docker or containerized deployment concepts.\nProject Background\nProject Overview\nSub2API is an AI API gateway platform developed in Go. Its core logic is to \"pool\" AI subscriptions from various channels (including OAuth-authenticated accounts, Session Keys, or standard API Keys).\nWith Sub2API, you can:\n-\nAggregate Resources: Plug in multiple Claude Pro or OpenAI accounts and output a single, unified standard API.\n-\nShare Costs: Supports a \"carpooling\" mechanism with a built-in billing system to charge by usage.\n-\nSeamless Integration: The generated APIs work flawlessly with native tools like Claude Code, OpenClaw, and more, without complex client-side configuration.\nAuthor/Team\n-\nMaintained by: Wei-Shaw\n-\nEcosystem: The project enjoys active community support, including a mobile admin console (sub2api-mobile) and other surrounding tools.\nProject Data\n- 📄 Core Repository: Wei-Shaw/sub2api\n- 🛠️ Tech Stack: Go (Gin, Ent), Vue 3, PostgreSQL, Redis\n- 📄 License: LGPL-3.0\n- 📈 Stats: Over 22k Stars on GitHub (Note: May include historical repository data or high community interest).\nMain Features\nCore Utility\nSub2API solves the \"resource island\" problem in AI usage:\nUpstream Account Pool (Claude, OpenAI, Gemini)\n↓ Integration\nSub2API Platform Layer (Auth, Billing, Load Balancing, Session Persistence)\n↓ Unified Distribution\nDownstream Applications (IDEs, Chat clients, Scripts)\nKey Features\n-\nMulti-Account Management: Supports various upstream account types and automatically handles session persistence.\n-\nPrecise Billing: Token-level usage tracking and cost calculation with customizable rates.\n-\nSmart Scheduling: Supports Sticky Sessions and load balancing to ensure continuity in long conversations.\n-\nBuilt-in Payment System: Native support for Alipay, WeChat Pay, Stripe, etc., allowing users to top up autonomously.\n-\nConcurrency & Rate Limiting: Configure per-user and per-account limits to protect your resources.\n-\nAdmin Dashboard: Provides an intuitive Web UI for real-time monitoring and management.\nQuick Start\nMethod 1: One-Click Script Installation (Recommended)\nRecommended for clean Ubuntu/Debian systems:\ncurl -sSL https://raw.githubusercontent.com/Wei-Shaw/sub2api/main/deploy/install.sh | sudo bash\nNotes:\n- Requires PostgreSQL 15+ and Redis 7+ to be pre-installed.\n- The script installs the binary to\n/opt/sub2api\nand creates a systemd service.\nMethod 2: Docker Compose Deployment\n# Create deployment directory\nmkdir -p sub2api-deploy && cd sub2api-deploy\n# Download and run deployment preparation script\ncurl -sSL https://raw.githubusercontent.com/Wei-Shaw/sub2api/main/deploy/docker-deploy.sh | bash\n# Spin up services\ndocker compose up -d\nOnce installed, access the admin dashboard at http://YOUR_SERVER_IP:8080\n.\nDetailed Analysis\nArchitecture: Why is this more than just a Reverse Proxy?\nThe design priority of Sub2API is \"Account State Management.\" Traditional reverse proxy tools (like Nginx) lack the ability to understand application-layer sessions.\n-\nSticky Sessions:\nFor tools like Claude Code that require context continuity, Sub2API uses the\nsession_id\nin the Header to lock a request to a specific upstream account, ensuring conversations aren't interrupted by account switching.\nNote: If using Nginx as a reverse proxy, ensure underscores_in_headers on;\nis enabled to support session headers.\nPooling Logic:\nThe system abstracts multiple accounts into a single \"resource pool.\" When one account hits a Rate Limit, the scheduler automatically routes traffic away from it, maximizing uptime.\nIntegrated Ecosystem:\nWhile most relay tools require an external payment gateway, Sub2API’s built-in integration significantly reduces the operational complexity for small teams or community-led \"carpools.\"\nTechnical Stack\n-\nBackend: Go ensures high concurrency handling and ease of deployment.\n-\nDatabase: PostgreSQL handles complex relationships and billing records.\n-\nCache: Redis manages rate limiting and real-time state synchronization.\nAddress and Resources\nOfficial Resources\nTarget Audience\n-\nCarpool Leads: Organizers looking to split the cost of Claude/OpenAI Plus.\n-\nDevelopers / Power Users: Individuals wanting to consolidate multiple account quotas for native CLI tools.\n-\nInternal Enterprise Teams: Teams needing to distribute and audit AI resource usage internally.\nSummary and Outlook\nKey Takeaways\n-\nClear Focus: Specialized in converting subscription-based quotas into standard API services.\n-\nAll-in-One: A closed-loop for management, scheduling, billing, and payments.\n-\nDeployment Friendly: Multiple options including script-based and Docker-based setups.\n-\nReliable Performance: Built on a solid Go/PostgreSQL/Redis foundation suitable for medium-to-large distribution.\nOne-Sentence Review\nSub2API is currently the most tightly integrated open-source solution combining \"resource aggregation\" with a \"commercial model,\" making it a powerful tool for achieving \"subscription freedom.\"\nVisit my homepage for more useful insights and interesting products.", "url": "https://wpnews.pro/news/open-source-project-no-73-sub2api-all-in-one-claude-openai-gemini-subscription", "canonical_source": "https://dev.to/wonderlab/open-source-project-no73-sub2api-all-in-one-claudeopenaigemini-subscription-to-api-relay-235n", "published_at": "2026-05-23 00:37:58+00:00", "updated_at": "2026-05-23 01:02:06.601942+00:00", "lang": "en", "topics": ["artificial-intelligence", "large-language-models", "open-source", "developer-tools", "cloud-computing"], "entities": ["Sub2API", "CRS2", "Claude", "OpenAI", "Gemini", "Claude Code", "GitHub Copilot", "Docker"], "alternates": {"html": "https://wpnews.pro/news/open-source-project-no-73-sub2api-all-in-one-claude-openai-gemini-subscription", "markdown": "https://wpnews.pro/news/open-source-project-no-73-sub2api-all-in-one-claude-openai-gemini-subscription.md", "text": "https://wpnews.pro/news/open-source-project-no-73-sub2api-all-in-one-claude-openai-gemini-subscription.txt", "jsonld": "https://wpnews.pro/news/open-source-project-no-73-sub2api-all-in-one-claude-openai-gemini-subscription.jsonld"}}