---
title: "Deploy LiteLLM | (Just Updated) AI Gateway, Add Models in the UI, Zero Required Keys"
description: "LiteLLM AI gateway. Keys auto-set, add models in UI, saved in Postgres"
category: "AI/ML"
url: https://railway.com/deploy/litellm-or-just-updated-ai-gateway-add-m
---

# Deploy LiteLLM | (Just Updated) AI Gateway, Add Models in the UI, Zero Required Keys

LiteLLM AI gateway. Keys auto-set, add models in UI, saved in Postgres

**[Deploy LiteLLM | (Just Updated) AI Gateway, Add Models in the UI, Zero Required Keys on Railway](https://railway.com/template/litellm-or-just-updated-ai-gateway-add-m)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/litellm-or-just-updated-ai-gateway-add-m/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** AI/ML

## Template content

### postgres

- **Image:** postgres:17.10-trixie

### litellm

- **Image:** ghcr.io/berriai/litellm-database:v1.104.0@sha256:fbe28229d2d02181c0a7d9df9599de614b491f3d897d2d7da18404f088310218
- **Start command:** `/bin/sh -c 'export UI_USERNAME="${UI_USERNAME:-admin}" STORE_MODEL_IN_DB=True DATABASE_URL="postgresql://postgres:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/postgres"; n=0; until python -c "import socket,os;socket.create_connection((os.environ[\"POSTGRES_HOST\"],5432),3).close()" 2>/dev/null; do n=$((n+1)); [ $n -gt 60 ] && { echo "[railway] postgres unreachable at $POSTGRES_HOST"; exit 1; }; sleep 2; done; echo "[railway] port=$PORT postgres=$POSTGRES_HOST ui_user=$UI_USERNAME store_model_in_db=$STORE_MODEL_IN_DB"; exec litellm --port "$PORT"'`
- **Health check:** /health/readiness
- **Public domain:** Yes

## Documentation

# Deploy and Host LiteLLM on Railway

LiteLLM is an open-source AI gateway: one OpenAI-compatible endpoint in front of 100+ model providers
(OpenAI, Anthropic, Gemini, Bedrock, Azure, OpenRouter, Ollama and more), with virtual API keys, spend
tracking, budgets, rate limits, fallbacks and an admin dashboard.

This template runs LiteLLM v1.104 from the official `litellm-database` image (pinned by digest) next to a
Postgres 17 service with a Railway volume. Nothing has to be typed into the deploy form.

## About Hosting LiteLLM

- **No required fields.** The master key, the encryption salt key and the dashboard password are generated per
  deploy. You do not paste provider keys or a config YAML at deploy time; add models and provider keys in the
  dashboard afterwards.
- **Models and keys live in Postgres.** The start command turns on `STORE_MODEL_IN_DB`, so every model, virtual
  key and budget you create in the dashboard is stored in the database and survives redeploys and restarts.
  Provider keys are encrypted at rest with the generated `LITELLM_SALT_KEY`; do not change that variable after
  you add your first model, or the stored keys can no longer be decrypted.
- **Locked from the first request.** Every API call needs the master key or a virtual key you issued, and the
  dashboard login is `admin` plus the generated `UI_PASSWORD`. Anonymous calls get `401`.
- **Waits for its database.** The start command waits for Postgres on the private network before starting, so
  a first deploy does not fail because the two services booted in a different order.
- **Healthcheck on `/health/readiness`,** which reports the database connection.

## Common Use Cases

- One OpenAI-compatible base URL for every app and agent, so switching provider is a dashboard change
- Per-team and per-project virtual keys with budgets and rate limits
- Fallbacks and load balancing across providers and deployments
- Spend and usage tracking for LLM calls across a team

## Dependencies for LiteLLM Hosting

- A Postgres service (created by the template) with one Railway volume

### Deployment Dependencies

- LiteLLM documentation: https://docs.litellm.ai/
- Source: https://github.com/BerriAI/litellm
- Official image: https://github.com/BerriAI/litellm/pkgs/container/litellm-database

### Implementation Details

| Variable | Purpose |
| --- | --- |
| `LITELLM_MASTER_KEY` | Admin API key (starts with `sk-`), generated per deploy. Send it as `Authorization: Bearer ...`. |
| `LITELLM_SALT_KEY` | Encrypts provider keys stored in Postgres. Generated per deploy; never change it afterwards. |
| `UI_PASSWORD` | Password for the dashboard at `/ui`, user `admin` (set `UI_USERNAME` to change the user). |

Python:

```python
from openai import OpenAI

client = OpenAI(base_url="https://", api_key="")
client.chat.completions.create(model="<a>", messages=[{"role": "user", "content": "hi"}])
```

## Why Deploy LiteLLM 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 LiteLLM 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.
</a>

## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/litellm-or-just-updated-ai-gateway-add-m
