What is LiteLLM?
Every team using LLMs converges on the same needs: one endpoint instead of five SDKs, per-team API keys instead of the shared provider key in a Slack DM, budgets before the invoice surprise, and a log of who spent what on which model. LiteLLM is the open-source gateway that does exactly this - an OpenAI-compatible proxy in front of 100+ providers.
This template runs the database-backed mode on a managed Postgres: virtual keys, teams, budgets, and spend logs all persist, and models are managed in the admin UI (/ui) with no config file - STORE_MODEL_IN_DB keeps provider credentials encrypted in the database.
The hosted alternatives take a cut or meter your logs; OpenRouter adds 5.5% on credits, Portkey meters logged requests. A self-hosted gateway charges neither - your provider keys, your spend caps, LAN latency from the agents in your project.
What you get
- OpenAI-compatible /v1 endpoint for 100+ providers (Anthropic, OpenAI, Gemini, Bedrock, Mistral, …)
- Virtual keys with per-key/team budgets, rate limits, and model allowlists
- Spend tracking per key, team, and model in Postgres
- Fallbacks, retries, and load balancing across deployments
- Admin UI at /ui - add models and mint keys without redeploys
- No config.yaml: models and encrypted provider keys live in the DB
How it runs on Lyngbak
| Service | Role | Public |
|---|---|---|
litellm | proxy + admin UI (:5000, key-authenticated) | yes |
db | Postgres - managed service on Lyngbak, container locally | no |
Before you deploy
LITELLM_MASTER_KEYadmin key - must start with sk-
LITELLM_SALT_KEYencrypts stored provider keys (openssl rand -hex 32); set before adding the first model, cannot rotate after
Sizing and billing
2 GiB suits a single proxy instance for team workloads (official prod guidance is 4 GiB per worker - size up under heavy concurrency). The container is stateless; Postgres holds everything.
A resource is a flat monthly price, with RAM and disk add-ons when the stack needs a little more than a tier, and room for your own apps on a larger one. On Usage Billing each service takes the smallest size that fits it and is billed by the second it runs, so a stopped stack stops costing CPU and RAM. Its 5 GiB of volumes cost $0.15 per GiB a month ($0.75/mo) for as long as they exist. One workspace can use both. See pricing
Compared with the managed service
| Service | Plan | Price | Includes |
|---|---|---|---|
| OpenRouter | pay-as-you-go | Usage-based | 5.5% fee on credit purchases on top of provider model prices |
| Portkey | Production | $49/mo | 100k logs/mo, then $9 per extra 100k; 30-day retention |
A self-hosted gateway adds no percentage fee and no log metering - your provider keys, your spend caps, LAN latency to your apps. Prices from each vendor's pricing page, June 2026.
Run it locally first
The same compose file runs with plain Docker Compose. Clone the template source, copy .env.example to .env, and run docker compose up -d.
Questions
How does this compare to OpenRouter?
OpenRouter is excellent for instant multi-model access but adds a 5.5% fee on credits and routes your traffic through their infrastructure. Self-hosted LiteLLM uses your own provider keys at raw provider prices, keeps prompts inside your network, and adds the team controls (budgets, virtual keys) OpenRouter does not.
Do my existing OpenAI-SDK apps work with it?
Yes - that is the design. Point base_url at your gateway (http://litellm:5000/v1 in-project, or the public domain) with a virtual key, and the same SDK call can hit Claude, GPT, or Gemini depending on the model name and your routing config.
Where do provider API keys live?
Encrypted in Postgres using LITELLM_SALT_KEY, managed through the admin UI. Generate the salt key before adding the first model and never rotate it - it cannot be changed once credentials are stored.
Is it safe to expose the proxy publicly?
Every request requires a key (master or virtual), so the public domain is usable by external clients. For purely internal use, in-project apps can call http://litellm:5000 and you can keep usage gated by virtual keys per team or agent.
Does it pair with the other LLM templates here?
Naturally: point agent-box, OpenClaw, or Hermes at the gateway for spend caps per agent, and send LiteLLM callbacks to the langfuse template for tracing - the whole LLM platform, self-hosted in one project.