Deploy OneHub
Access all LLMs through the standard OpenAI API format,Analytics & billing.
Redis
Just deployed
/data
MySQL
Just deployed
/var/lib/mysql
OneHub
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
| Dependency | Required | Purpose |
|---|---|---|
| MySQL | Yes | Stores users, channels, API keys, configuration, and usage data. |
| Redis | Yes | Caching, rate limiting, sessions, and performance optimization. |
Deployment Dependencies
| Resource | Link |
|---|---|
| GitHub Repository | https://github.com/martialbe/one-hub |
| Docker Image | https://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
| Setting | Value |
|---|---|
| Proxy Type | HTTP Proxy |
| Target Port | 3000 |
Environment Variables
Deploy MySQL and Redis services first, then configure the following Railway Variables.
| Variable | Required | Description |
|---|---|---|
SESSION_SECRET | Yes | Secret used for web session encryption. |
USER_TOKEN_SECRET | Yes | Secret used to generate user API tokens. |
SQL_DSN | Yes | MySQL connection string using Railway reference variables. |
REDIS_CONN_STRING | Yes | Redis connection string using Railway reference variables. |
PORT | Yes | Internal 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
- Add a MySQL service to your Railway project.
- Railway automatically provides the required connection variables.
- Configure the
SQL_DSNvariable using Railway reference variables.
Example:
SQL_DSN=${{MySQL.MYSQLUSER}}:${{MySQL.MYSQLPASSWORD}}@tcp(${{MySQL.MYSQLHOST}}:${{MySQL.MYSQLPORT}})/${{MySQL.MYSQL_DATABASE}}
Redis
- Add a Redis service.
- 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:
- Open your Railway service.
- Navigate to Settings → Networking.
- Click Generate Domain.
- Open the generated Railway URL.
The One Hub web dashboard will appear.
Initial Setup
After logging in to the dashboard:
- Create an administrator account if prompted.
- Configure your preferred AI providers.
- Add API Keys for providers such as OpenAI, Anthropic, Gemini, Azure OpenAI, DeepSeek, Grok, Claude, Mistral, or other supported services.
- Configure channels and model mappings.
- Create users or API Tokens.
- 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
