Railway

Deploy OneHub

Access all LLMs through the standard OpenAI API format,Analytics & billing.

Deploy OneHub

Just deployed

/data

Just deployed

/var/lib/mysql

Just deployed

Deploy and Host One Hub on Railway

One Hub is an AI gateway built on top of One API that provides a unified OpenAI-compatible interface for dozens of AI providers. It enables centralized API key management, user authentication, usage tracking, model routing, billing, monitoring, and support for multiple LLM providers through a single endpoint.

About Hosting One Hub

Railway provides an easy way to deploy One Hub together with its required infrastructure. This template deploys the official Docker image and connects it to Railway-managed MySQL and Redis services for persistent data storage and caching. Railway automatically handles networking, HTTPS, deployments, and environment variables, allowing you to focus on configuring AI providers and managing API access. Once deployed, administrators can access the web dashboard to create users, manage API keys, configure model providers, monitor usage, and expose a single OpenAI-compatible API endpoint for applications.

Common Use Cases

  • Centralize access to multiple AI providers behind a single OpenAI-compatible API.
  • Manage API keys, users, quotas, billing, and model routing from one dashboard.
  • Build AI applications that can switch between providers without changing client code.

Dependencies for One Hub Hosting

DependencyRequiredPurpose
MySQLYesStores users, channels, API keys, configuration, and usage data.
RedisYesCaching, rate limiting, sessions, and performance optimization.

Deployment Dependencies

ResourceLink
GitHub Repositoryhttps://github.com/martialbe/one-hub
Docker Imagehttps://ghcr.io/martialbe/one-api

Implementation Details

Docker

This template deploys the official Docker image:

ghcr.io/martialbe/one-api:latest

Railway pulls the prebuilt image directly.

Public Networking

SettingValue
Proxy TypeHTTP Proxy
Target Port3000

Environment Variables

Deploy MySQL and Redis services first, then configure the following Railway Variables.

VariableRequiredDescription
SESSION_SECRETYesSecret used for web session encryption.
USER_TOKEN_SECRETYesSecret used to generate user API tokens.
SQL_DSNYesMySQL connection string using Railway reference variables.
REDIS_CONN_STRINGYesRedis connection string using Railway reference variables.
PORTYesInternal application port.

Raw Editor example:

SESSION_SECRET=9g7vyfrrs8mdivw5lgyy4lspnkegbvs8h1tibzkxkwm26jgljelhjb0lmh37vaoi

USER_TOKEN_SECRET=z67nyjojh8vq8w9jnfdc0876xnmorp91jy31qh3dln1pkksgoi521x7zfgbep7cc

SQL_DSN=${{MySQL.MYSQLUSER}}:${{MySQL.MYSQLPASSWORD}}@tcp(${{MySQL.MYSQLHOST}}:${{MySQL.MYSQLPORT}})/${{MySQL.MYSQL_DATABASE}}

REDIS_CONN_STRING=redis://:${{Redis.REDIS_PASSWORD}}@${{Redis.REDISHOST}}:${{Redis.REDISPORT}}

PORT=3000

Persistent Storage

No Railway Volume is required.

Application data is stored in MySQL, while Redis is used for caching and runtime data.

Database

One Hub requires both MySQL and Redis.

MySQL

  1. Add a MySQL service to your Railway project.
  2. Railway automatically provides the required connection variables.
  3. Configure the SQL_DSN variable using Railway reference variables.

Example:

SQL_DSN=${{MySQL.MYSQLUSER}}:${{MySQL.MYSQLPASSWORD}}@tcp(${{MySQL.MYSQLHOST}}:${{MySQL.MYSQLPORT}})/${{MySQL.MYSQL_DATABASE}}

Redis

  1. Add a Redis service.
  2. Configure the Redis connection string.

Example:

REDIS_CONN_STRING=redis://:${{Redis.REDIS_PASSWORD}}@${{Redis.REDISHOST}}:${{Redis.REDISPORT}}

Build & Start

This template uses the official Docker image.

No custom build or start commands are required.

Accessing the Application

After deployment:

  1. Open your Railway service.
  2. Navigate to Settings → Networking.
  3. Click Generate Domain.
  4. Open the generated Railway URL.

The One Hub web dashboard will appear.

Initial Setup

After logging in to the dashboard:

  1. Create an administrator account if prompted.
  2. Configure your preferred AI providers.
  3. Add API Keys for providers such as OpenAI, Anthropic, Gemini, Azure OpenAI, DeepSeek, Grok, Claude, Mistral, or other supported services.
  4. Configure channels and model mappings.
  5. Create users or API Tokens.
  6. Start sending OpenAI-compatible requests through your One Hub endpoint.

Supported Providers

One Hub supports many AI providers, including:

  • OpenAI
  • Azure OpenAI
  • Anthropic
  • Gemini
  • Claude
  • DeepSeek
  • Grok
  • Mistral
  • Cohere
  • Cloudflare AI
  • Stability AI
  • Amazon Bedrock
  • Baidu Wenxin
  • Zhipu AI
  • Moonshot
  • MiniMax
  • Midjourney (Proxy)
  • Suno
  • Tencent Hunyuan
  • Baichuan
  • Qwen
  • Xunfei Spark
  • And many more.

Key Features

  • OpenAI-compatible API
  • Multi-provider AI gateway
  • User management
  • API key management
  • Usage statistics
  • Billing and quota management
  • Dynamic model routing
  • Automatic model synchronization
  • Telegram Bot integration
  • Prometheus monitoring
  • Redis caching
  • MySQL persistence
  • Rate limiting
  • WebAuthn login support
  • Payment support

Why Deploy One Hub 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 One Hub 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

More templates in this category

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

okisdev
113
View Template
stella
Self-host stella with web, API, Postgres, Redis, and object storage.

Jan Kubica
1
View Template
Hermes Agent | OpenClaw Alternative with Dashboard
Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

codestorm
56