---
title: "Deploy litellm-source-20260617"
description: "LiteLLM AI gateway with Postgres keys, Redis cache, and spend controls."
category: "AI/ML"
url: https://railway.com/deploy/litellm-source-20260617
---

# Deploy litellm-source-20260617

LiteLLM AI gateway with Postgres keys, Redis cache, and spend controls.

**[Deploy litellm-source-20260617 on Railway](https://railway.com/template/litellm-source-20260617)**

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

## Template content

### litellm

- **Image:** ghcr.io/berriai/litellm:main-stable
- **Start command:** `/bin/sh -lc 'cat > /tmp/litellm_config.yaml <<"YAML"
model_list: []
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  database_url: os.environ/DATABASE_URL
  store_model_in_db: true
  proxy_batch_write_at: 60
  database_connection_pool_limit: 10
litellm_settings:
  cache: true
  cache_params:
    type: redis
    host: os.environ/REDIS_HOST
    port: os.environ/REDIS_PORT
    password: os.environ/REDIS_PASSWORD
  json_logs: true
  set_verbose: false
router_settings:
  routing_strategy: simple-shuffle
  redis_host: os.environ/REDIS_HOST
  redis_port: os.environ/REDIS_PORT
  redis_password: os.environ/REDIS_PASSWORD
YAML
exec litellm --config /tmp/litellm_config.yaml --port 4000 --num_workers 1'`
- **Public domain:** Yes

### postgres

- **Image:** postgres:17

### redis

- **Image:** redis:7
- **Start command:** `/bin/sh -lc 'exec redis-server --appendonly yes --dir /data --requirepass "$REDIS_PASSWORD" --maxmemory-policy noeviction'`

## Documentation

# Deploy and Host LiteLLM Gateway on Railway

Run LiteLLM Proxy as a production-shaped OpenAI-compatible AI gateway with Postgres persistence, Redis coordination, generated admin credentials, and provider-key setup left to the deployer.

## About Hosting LiteLLM on Railway

- `litellm`: public LiteLLM proxy/API/admin service on port `4000`
- `postgres`: private app database for virtual keys, teams, provider config, and spend logs
- `redis`: private cache/routing coordination service
- Generated `LITELLM_MASTER_KEY`, `LITELLM_SALT_KEY`, Postgres password, and Redis password
- No provider API keys are included in the template

## Why Deploy LiteLLM on Railway

LiteLLM gives teams one OpenAI-compatible gateway across OpenAI, Anthropic, Gemini, Bedrock, Azure, OpenRouter, local OpenAI-compatible endpoints, and many other providers. Postgres keeps admin state and spend logs durable, while Redis supports production cache/routing patterns recommended by LiteLLM's own deployment guidance.

## Common Use Cases

- Central AI gateway for apps and agents
- OpenAI-compatible API facade for multiple providers
- Virtual keys with budgets and spend tracking
- Provider-key management without baking provider secrets into app code
- Backend for Open WebUI or internal agent platforms

## Dependencies for LiteLLM Hosting

LiteLLM can run as a single container, but this template includes Postgres and Redis because key management, spend tracking, and production routing/cache behavior depend on durable shared services.

### Deployment Dependencies

- `LITELLM_MASTER_KEY`: generated admin/master key. It starts with `sk-`.
- `LITELLM_SALT_KEY`: generated encryption salt. Do not change it after adding provider keys.
- `DATABASE_URL`: private Postgres connection string.
- `REDIS_HOST`, `REDIS_PORT`, and `REDIS_PASSWORD`: private Redis settings.
- `STORE_MODEL_IN_DB=True`: allows model/provider config to be managed through LiteLLM.

## After Deploy

1. Open the LiteLLM public URL.
2. Use the generated `LITELLM_MASTER_KEY` for admin/API access.
3. Add provider keys through the UI or admin API.
4. Generate virtual keys for apps and teams.
5. Send OpenAI-compatible requests to the Railway URL.

## Support Checklist

If a deploy fails, include all service deployment IDs, `/health/liveliness`, `/health/readiness`, `/ui`, and logs mentioning Postgres migrations, Redis connection, `DATABASE_URL`, `LITELLM_MASTER_KEY`, or `LITELLM_SALT_KEY`.


## 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-source-20260617
