Railway

Deploy sub2api-railway-template

Subscription to API Conversion Platform

Deploy sub2api-railway-template

Just deployed

/data

/var/lib/postgresql/data

weishaw/sub2api:latest

weishaw/sub2api:latest

Just deployed

Deploy and Host Sub2API on Railway

Sub2API is a high-performance AI API gateway for managing, distributing, and billing usage across subscription-based AI accounts. It helps teams centralize API access, enforce quotas, track token consumption, and route requests intelligently across multiple upstream providers from a single deployable platform.

About Hosting Sub2API

Hosting Sub2API requires more than just running a container. A production-ready deployment needs a fast application layer, persistent database storage, and an in-memory cache for rate limiting, session handling, and request coordination. This Railway template provisions a complete Sub2API stack, including the official Sub2API application, PostgreSQL for durable data storage, and Redis for caching and quota enforcement. Railway connects these services over its private network for secure, low-latency communication without extra networking setup. Auto-generated secrets such as JWT and TOTP encryption keys are also created during deployment, helping you launch quickly with a secure default configuration.

Common Use Cases

  • Team Quota Sharing: Pool multiple AI subscription accounts and distribute API access to internal users or teams with usage controls.
  • Cost and Usage Tracking: Monitor token-level consumption and calculate usage across projects, departments, or clients.
  • High-Availability API Gateway: Route requests across multiple upstream accounts with rate limiting, sticky sessions, and centralized authentication.

Dependencies for Sub2API Hosting

  • PostgreSQL 15+: Used as the primary database for users, API keys, billing records, and system configuration.
  • Redis 7+: Used for caching, distributed rate limiting, queue management, and session-related workloads.
  • Docker: Sub2API is deployed using the official weishaw/sub2api:latest image.

Deployment Dependencies

Implementation Details

This template provisions the following services automatically:

  • Sub2API Gateway — Core application including backend and web UI
  • PostgreSQL Database — Persistent relational storage linked through Railway private networking
  • Redis Cache — High-speed in-memory store for rate limiting and queue operations
  • Auto-generated Secrets — Secure values such as JWT_SECRET, TOTP_ENCRYPTION_KEY, and database credentials generated at deploy time

After deployment:

  1. Open your Railway project.
  2. Select the Sub2API service.
  3. Go to Settings and click Generate Domain.
  4. Visit the generated domain to open the Sub2API setup wizard.
  5. Configure your admin account and complete initial setup.

Why Deploy Sub2API on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Sub2API on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

weishaw/sub2api:latest

weishaw/sub2api:latest

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
View Template
openui
Deploy OpenUI: AI-powered UI generation with GitHub OAuth and OpenAI API.

zexd
View Template
firecrawl
firecrawl api server + worker without auth, works with dify

Rama