Deploy Unorouter

Self-hosted AI gateway + storefront. One key for 100+ AI providers.

Deploy Unorouter

Just deployed

/data

Just deployed

/data

UnoRouter

Self-hosted AI gateway + front-end. One OpenAI-compatible key that routes to 100+ upstream providers, with a full Next.js dashboard, chat client, model catalog, price comparison, usage-based billing, and public status page.

Two services: gateway (the UnoRouter gateway, a new-api fork) + storefront (Next.js front-end).

Deploy and Host

Host your own UnoRouter on Railway. The template provisions both services from prebuilt images, wires the storefront to the gateway over Railway's private network, and mounts persistent volumes for both services.

Deploy on Railway

Why Deploy

  • One key, 130+ providers — route OpenAI-, Claude- and Gemini-compatible requests through a single gateway with channels, retries and fallbacks.
  • Full dashboard — API keys, usage logs, billing, credits, affiliate and gift cards out of the box.
  • Same-origin proxy — the storefront's server routes proxy dashboard, model and billing calls to the gateway over Railway's private network, so the gateway is never exposed publicly and no gateway token reaches the browser.
  • Model tester + rankings — probe any endpoint with nonce-tagged prompts to verify the model behind it, with a public leaderboard persisted in SQLite.
  • Per-device chat state — chat, characters and presets live in the visitor's browser (SQLocal/OPFS); nothing to migrate.

Common Use Cases

  • Teams that want a single metered AI key across many upstream providers.
  • Self-hosters who want a private OpenAI-compatible endpoint with a real dashboard.
  • Communities running a shared chat client with their own branding and pricing.

Deployment Dependencies

  • Both services come from prebuilt images (ghcr.io/unorouter/new-api, ghcr.io/unorouter/unorouter) — no build step, deploys in under a minute.
  • The gateway keeps its SQLite DB on the gateway-data volume at /data.
  • The storefront keeps its rankings DB on the storefront-data volume at /data; chat state is per-device in the browser.
  • The storefront reaches the gateway via ${{gateway.RAILWAY_PRIVATE_DOMAIN}} — nothing to type.

Architecture

            ┌─────────────┐   private network    ┌─────────────┐
  browser ─▶│  storefront │ ────────────────────▶│   gateway   │──▶ 100+ upstream providers
            │  (Next.js)  │   http://gateway:    │ (new-api)   │
            └─────────────│   ...:3000           └─────────────┘
                          │ /api/* BFF proxy injects the gateway key
  • gateway — UnoRouter gateway (new-api fork): model routing, channels, API keys, billing, usage logs, and a relay speaking OpenAI-, Claude- and Gemini-compatible formats. Serves its own admin UI at /.
  • storefront — Next.js front-end: dashboard, chat client, model catalog, price comparison, status page. Server routes act as a backend-for-frontend and proxy to the gateway over the private network.

Features

  • Multi-provider routing with channels, groups, retries and fallbacks
  • OpenAI / Anthropic / Gemini-compatible relay endpoints
  • API key management, quotas, billing, credits, gift cards
  • Usage logs and analytics with per-key granularity
  • Model catalog with price comparison and a public model-tester leaderboard
  • Roleplay-grade chat client: characters, lorebooks, presets, plugins, group chats
  • 18 UI locales

Dependencies for

  • gateway: SQLite (bundled, on volume) or an external MySQL/PostgreSQL via SQL_DSN; optional Redis via REDIS_CONN_STRING for multi-node caching.
  • storefront: reaches the gateway over Railway's private network via INTERNAL_API_URL; persists rankings in SQLite on the volume via TURSO_DATABASE_URL.

About Hosting

  • Volumes: gateway /data (SQLite DB, channel config, usage logs), storefront /data (rankings DB). Railway volumes mount root-owned; both images are configured so a fresh install boots cleanly.
  • Private networking: INTERNAL_API_URL resolves to http://:3000 at deploy time. The gateway is never publicly exposed unless you add a public domain to it.
  • First run: create the admin account at the gateway's public URL (the dashboard is served by the gateway itself; first user becomes root with password 123456 — change it immediately after first login).

Configuration

VariableServiceDefaultDescription
SESSION_SECRETgatewayauto (${{secret(48)}})Signs gateway sessions and OAuth state.
FRONTEND_BASE_URLgatewayauto (${{RAILWAY_PUBLIC_DOMAIN}})Absolute base for callback/share URLs.
TZgatewayUTCTimezone for usage-log timestamps.
SQL_DSNgateway(empty → SQLite)Optional external MySQL/PostgreSQL.
REDIS_CONN_STRINGgateway(empty → memory)Optional Redis for multi-node caching.
SESSION_SECRETstorefrontauto (${{secret(48)}})Seals storefront session cookies (min 32 chars).
NEXT_PUBLIC_URLstorefrontauto (${{RAILWAY_PUBLIC_DOMAIN}})Public origin for links, canonical URLs, cookie scope.
NEXT_PUBLIC_API_URLstorefrontauto (${{RAILWAY_PUBLIC_DOMAIN}})Origin shown in API docs / direct browser calls.
NEXT_PUBLIC_APP_NAMEstorefrontUnoRouterBrand name in header, titles, SEO.
NEXT_PUBLIC_SUPPORT_EMAILstorefrontsupport@example.comSupport contact in help links.
NEXT_PUBLIC_CARDS_URLstorefrontautoGift-card store origin.
INTERNAL_API_URLstorefrontauto (${{gateway.RAILWAY_PRIVATE_DOMAIN}})Gateway private-domain proxy target.
TURSO_DATABASE_URLstorefrontfile:/data/storefront.dbRankings SQLite file on the volume.
RAILWAY_RUN_UIDstorefront0Distroless nonroot image + root-owned volume: must run as root.

Health checks: gateway GET /api/status (200 on a fresh install before any account exists), storefront GET /api/ops/health (reports db + upstream checks).

Quick Start

  1. Click Deploy on Railway — the form pre-fills every variable (secrets auto-generate, cross-service refs auto-wire).
  2. Wait for both services to turn green (healthchecks: /api/status, /api/ops/health).
  3. Open the gateway domain → log in with root / 123456 → change the password immediately (Users → root → edit).
  4. Add a channel in the gateway (Channels → add: pick a provider, paste its API key, choose models).
  5. Create an API key (Tokens → add token) and start proxying: curl /v1/chat/completions -H "Authorization: Bearer " ...
  6. Open the storefront domain → the dashboard, model catalog and chat client are live. Chat runs per-device in the browser and proxies through the storefront's /api/* routes; log in to the dashboard to create keys without leaving the storefront.

License

UnoRouter storefront: AGPL-3.0. Gateway (new-api): Apache-2.0. This template's glue files: MIT.


Template Content

More templates in this category

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

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

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

codestorm
76