Railway

Deploy MetApi

Meta-gateway for AI APIs with smart routing & auto check-ins

Deploy MetApi

Just deployed

/app/data

Deploy and Host MetApi on Railway

MetApi is an open-source AI gateway and model aggregation platform that unifies multiple AI providers and API gateways behind a single OpenAI-compatible endpoint. It provides intelligent model routing, centralized account management, automatic failover, balance monitoring, scheduled check-ins, and a web dashboard for managing AI infrastructure from one place.

About Hosting MetApi

Hosting MetApi on Railway provides a production-ready environment for running your own AI aggregation gateway without managing servers. Railway can deploy the official Docker image, automatically provision networking, and expose the application over HTTPS with a public domain.

MetApi stores its configuration, routing rules, credentials, logs, and SQLite database locally, making a Railway Volume essential for persistent storage. While SQLite is the default database, MySQL and PostgreSQL are also supported for external deployments. Railway Variables simplify secret management for administrator authentication, proxy access, scheduled jobs, and notification services, allowing you to securely operate a centralized AI gateway with minimal infrastructure management.

Common Use Cases

  • Centralize multiple AI providers behind a single OpenAI-compatible API
  • Intelligent routing and failover across AI gateway services
  • Monitor balances, models, and API usage from a unified dashboard

Dependencies for MetApi Hosting

DependencyRequiredPurpose
Railway VolumeYesStores the SQLite database, encrypted credentials, logs, and runtime data
SQLiteYes (default)Default application database
MySQL or PostgreSQLOptionalExternal database backend
Docker ImageYesDeploys the MetApi application

Deployment Dependencies

ResourceLink
GitHub Repositoryhttps://github.com/cita-777/metapi
Docker Hubhttps://hub.docker.com/r/1467078763/metapi

Implementation Details

Docker

MetApi provides an official Docker image:

1467078763/metapi:latest

Railway deploys the official Docker image directly, so no custom build or start commands are required.

Public Networking
SettingValue
Proxy TypeHTTP Proxy
Target Port4000

Generate a Railway domain from Settings → Networking → Generate Domain after deployment.

Environment Variables

Important

AUTH_TOKEN is required for your first login.

After deployment, sign in to the dashboard using the value configured for AUTH_TOKEN. Replace the default change-me-admin-token before deploying to production.

VariableRequiredDescription
AUTH_TOKENYesAdministrator login token used for the initial dashboard login.
PROXY_TOKENYesBearer token used by downstream /v1/* proxy requests.
ACCOUNT_CREDENTIAL_SECRETYes (Production)Encryption key for stored credentials. Generate a unique 32+ byte random secret and do not reuse AUTH_TOKEN.
PORTYesInternal application listening port. Use 4000.
DATA_DIRYesDirectory used for persistent application data.
TZNoTime zone for scheduled jobs and logs.
CHECKIN_CRONNoSchedule for automatic daily check-ins.
BALANCE_REFRESH_CRONNoSchedule for automatic balance refresh.
WEBHOOK_URLNoWebhook notification endpoint.
BARK_URLNoBark notification URL.
SERVERCHAN_KEYNoServerChan notification key.
TELEGRAM_ENABLEDNoEnable Telegram notifications.
TELEGRAM_BOT_TOKENNoTelegram bot token.
TELEGRAM_CHAT_IDNoTelegram chat ID.

Raw Editor example:

AUTH_TOKEN=your-secure-admin-token
PROXY_TOKEN=your-secure-proxy-token
ACCOUNT_CREDENTIAL_SECRET=your-32-byte-random-secret

PORT=4000
DATA_DIR=/app/data
TZ=UTC

CHECKIN_CRON=0 8 * * *
BALANCE_REFRESH_CRON=0 * * * *
Persistent Storage

A Railway Volume is required.

Open your Railway service and navigate to:

Settings → Volumes → Add Volume

Mount the volume at:

/app/data

Configure:

DATA_DIR=/app/data

This directory stores the SQLite database, encrypted credentials, routing configuration, logs, and runtime data. Without a Railway Volume, this data will be lost when the container is recreated.

Database

MetApi uses SQLite by default and requires no additional database service.

If preferred, you can deploy a Railway MySQL or PostgreSQL service and configure the appropriate database connection variables according to the project's documentation.

Build & Start

The official Docker image contains everything required to run MetApi.

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.

First Login

Use the value of AUTH_TOKEN as the administrator login token.

For example:

AUTH_TOKEN=my-secure-admin-token

Log in using:

my-secure-admin-token

If you later change the administrator token from the MetApi Settings page, use the updated token for all future logins.

Why Deploy MetApi 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 MetApi 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
Matomo Analytics + MariaDB
Privacy-friendly analytics with MariaDB and persistent volumes.

leodev
0
View Template
Bugsink
Self-hosted Error Tracking. Sentry-SDK compatible

zǝʇɹoɔ oɓıɹpoɹ
18
View Template
SubTrackr
Self-hosted Subscription Tracker

amnesia
3