# Self-host LiteLLM proxy

> AI gateway server that puts one OpenAI-compatible API in front of many LLM providers, with virtual keys, spend tracking and an Admin UI. Run your own LiteLLM proxy on an always-on EnvHaven workspace by asking its coding agent: one request installs it, puts it on an HTTPS address and locks it down. What the agent takes care of, and the manual route.

_Updated November 23, 2026_

Running your own LiteLLM proxy usually means a list of server chores: a machine that stays on, Docker or a runtime, a reverse proxy with certificates, a domain, and the settings that make LiteLLM proxy behave behind all of it. On an EnvHaven workspace you skip the list. You ask the coding agent, and it does the work while you watch.

## Just ask your agent

Open a Hobby workspace, tap **Launch** to start any coding agent (Claude Code, Codex, OpenCode or another), and ask it:

```text
Set up LiteLLM proxy on this workspace and give me the link. Follow https://envhaven.com/self-host/litellm.md
```

Then open the link it sends and create your LiteLLM proxy account straight away, before anyone else finds the address. That is the whole request: the address in it is this page's Markdown copy, and the agent follows the instructions for it further down, with every setting LiteLLM proxy's docs require.

## Or keep it private with Tailscale

The preview URL puts LiteLLM proxy on the public internet, which suits something other people need to reach. For an app only you and your household use, your tailnet is the better home: Tailscale gives LiteLLM proxy an HTTPS address that only your own devices, signed in to your Tailscale account, can open. Save a Tailscale auth key in the workspace's **Vars** pane as `TS_AUTHKEY`, and ask the agent:

```text
Set up LiteLLM proxy on my tailnet instead of the preview URL. Follow https://envhaven.com/self-host/litellm.md and https://envhaven.com/guides/self-host-privately-with-tailscale.md
```

- On Plus and Pro, a Tailscale container runs beside LiteLLM proxy, so it keeps its private address through workspace restarts and updates, and every app you set up this way gets an address of its own.
- On Hobby, Tailscale runs in the workspace beside LiteLLM proxy; after a restart or an update, ask the agent to start both again.
- Anything other services have to reach, such as a webhook, still needs a public address. [Keep self-hosted apps private with Tailscale](https://envhaven.com/guides/self-host-privately-with-tailscale) covers both, and what Tailscale's free plan includes.

| At a glance |  |
| --- | --- |
| What it is | AI chat, models and agent tools |
| License | MIT for everything outside litellm/enterprise/, which has its own separate license |
| Runs as | Docker (`docker.litellm.ai/berriai/litellm`) or a native install |
| Memory | Not documented |
| Plan that fits | Hobby or larger |
| Web port | 4000 |
| Documentation | [docs.litellm.ai/docs/proxy/docker_quick_start](https://docs.litellm.ai/docs/proxy/docker_quick_start) |

## What your agent takes care of

- **Installing it.** LiteLLM proxy runs from the official image, `docker.litellm.ai/berriai/litellm`, with its data in folders under `~/apps/litellm`, or without Docker on Hobby.
- **Putting it on an HTTPS address.** The workspace's preview URL serves it, and your own domain can too.
- **Locking it down first.** What LiteLLM proxy's docs say to set before it faces the internet, below.
- **Telling you what to back up**: PostgreSQL data (compose volume postgres_data at /var/lib/postgresql/data; holds virtual keys, models added in the UI and spend logs), .env with LITELLM_MASTER_KEY and LITELLM_SALT_KEY and config.yaml if used ([docs](https://docs.litellm.ai/docs/proxy/docker_quick_start.md)).

### The settings it needs behind a proxy

- `PROXY_BASE_URL`: Base URL of the proxy; it also decides whether session, SSO and SAML cookies are marked Secure. ([docs](https://docs.litellm.ai/docs/proxy/config_settings.md))
- general_settings.trusted_proxy_ranges: CIDR ranges of the load balancer, tunnel or ingress in front of LiteLLM, so the Admin UI sign-in limit sees the real client address; [] when clients connect directly. ([docs](https://docs.litellm.ai/docs/proxy/prod.md))
- `SERVER_ROOT_PATH`: Serves the proxy and Admin UI under a path prefix such as /api/v1 (LiteLLM v1.72.3 and later). ([docs](https://docs.litellm.ai/docs/proxy/custom_root_ui.md))

### Before it faces the internet

- LITELLM_MASTER_KEY is both the management API credential and the default Admin UI password (username admin); set both LITELLM_MASTER_KEY and LITELLM_SALT_KEY before the first start. ([docs](https://docs.litellm.ai/docs/proxy/docker_quick_start.md))
- The environment-based Admin UI login is a shared cleartext credential; the docs describe disabling it once a database admin account exists. ([docs](https://docs.litellm.ai/docs/proxy/security_best_practices.md))
- Swagger UI, ReDoc and the OpenAPI schema are served without authentication unless disabled. ([docs](https://docs.litellm.ai/docs/proxy/security_best_practices.md))
- Give each application its own scoped virtual key instead of the master key so access can be revoked per workload. ([docs](https://docs.litellm.ai/docs/proxy/security_best_practices.md))

## Things to ask next

Everything after the install is one more sentence to the agent. Some that come up:

- "Connect it to the API keys in my Vars pane, and make Claude the default model."
- "Add a second user account for my partner, without admin rights."
- "Move LiteLLM proxy to app.example.com." Add the domain on the dashboard's Domains page with a CNAME to `domains.envhaven.app`, and the agent changes LiteLLM proxy's address settings to match.
- "Update LiteLLM proxy to the latest release." It pulls the new image and recreates the container, data kept.

## Instructions for the agent

The agent reads these from the page's Markdown copy. They also work pasted on their own, if you would rather give them in your own words.

```text
Set up LiteLLM proxy on this workspace and serve it at my preview URL.
- Where Docker has a daemon (Plus and Pro), use Docker Compose with the official image, docker.litellm.ai/berriai/litellm, starting from the docs' compose file: https://github.com/BerriAI/litellm/blob/main/litellm/deploy/docker/docker-compose.quickstart.yml. If `docker compose` is missing, install the Compose plugin into ~/.docker/cli-plugins first.
- The docs' setup includes: postgres (db service, postgres:16; needed for virtual keys, model management in the Admin UI, budgets and spend tracking).
- Keep the compose file in ~/apps/litellm and all of its data in folders there (bind mounts, not named volumes), with restart: unless-stopped on every service.
- This server has no firewall, so publish no port on its public IP, and drop host networking and privileged mode from the docs' compose file. Docker runs on the host: connect this workspace to the compose network and relay my preview URL's port to LiteLLM proxy's port 4000.
- Without Docker (on Hobby, where Docker has no daemon), install it as its docs describe, with `uv tool install 'litellm[proxy]'`, then `litellm --config config.yaml` (Python 3.10 or higher; uv provisions a compatible Python), into ~/apps/litellm with its data, so it survives workspace updates; global installs and system paths do not. Run it in a tmux window named litellm, listening on 0.0.0.0:4000, and point my preview URL at port 4000.
- The preview URL terminates HTTPS in front of LiteLLM proxy: serve plain HTTP on its port, and trust the forwarded headers the relay passes on.
- Set what "The settings it needs behind a proxy" lists on https://envhaven.com/self-host/litellm.md for the preview URL, as LiteLLM proxy's docs describe for running behind a proxy; skip any that apply only when LiteLLM proxy serves HTTPS itself.
- Before the preview URL serves it, apply what "Before it faces the internet" lists on https://envhaven.com/self-host/litellm.md.
- When it answers at the preview URL, send me the link and tell me what to back up.
- If I asked for my tailnet instead of the preview URL, set LiteLLM proxy up the same way but follow https://envhaven.com/guides/self-host-privately-with-tailscale.md for the network: no preview URL, no relay.
```

## What to know

- In Docker, LiteLLM proxy's containers keep running when the workspace restarts or updates. The relay from the preview URL is a process in the workspace, so after a restart or an update, ask the agent to restore it.
- Without Docker, LiteLLM proxy runs as a process in the workspace, so after a restart or an update, ask the agent to start it again.
- Uploads to /v1/files have no size cap by default, so behind Cloudflare the effective cap is its 100 MB request limit; set general_settings.max_file_size_mb at or below 100 to return the app's own 413. ([docs](https://docs.litellm.ai/docs/proxy/config_settings.md))
- Without a database the gateway only checks the master key: no virtual keys, no budget enforcement, no database-backed model management. ([docs](https://docs.litellm.ai/docs/proxy/docker_quick_start.md))
- Docs size memory and connection pools per worker, so running one worker per vCPU on a single VM multiplies the 4Gi starting point. ([docs](https://docs.litellm.ai/docs/proxy/prod.md))
- A workspace has one preview URL and one custom domain, both serving the same port, so it puts one app on a public address at a time.

## Without a workspace

The manual route, on a server you run:

1. Rent a Linux VPS, secure SSH, and create a user for the app.
2. Install Docker and write a compose file from the official image.
3. Put a reverse proxy in front (Caddy, nginx or Traefik), get certificates, and point a domain at the server.
4. Set the proxy settings listed above for that domain, and pass WebSocket upgrades through the proxy if the app uses them.
5. Keep the firewall closed except for the proxy, and schedule backups and updates.

LiteLLM proxy's own [documentation](https://docs.litellm.ai/docs/proxy/docker_quick_start) covers each step for its install methods.

## Sources

Facts about LiteLLM proxy come from its own documentation, checked on 2026-11-23:

- [docs.litellm.ai/docs/proxy/docker_quick_start](https://docs.litellm.ai/docs/proxy/docker_quick_start)
- [docs.litellm.ai/docs/proxy/docker_quick_start.md](https://docs.litellm.ai/docs/proxy/docker_quick_start.md)
- [docs.litellm.ai/docs/proxy/quick_start.md](https://docs.litellm.ai/docs/proxy/quick_start.md)
- [docs.litellm.ai/docs/proxy/config_settings.md](https://docs.litellm.ai/docs/proxy/config_settings.md)
- [docs.litellm.ai/docs/proxy/prod.md](https://docs.litellm.ai/docs/proxy/prod.md)
- [docs.litellm.ai/docs/proxy/custom_root_ui.md](https://docs.litellm.ai/docs/proxy/custom_root_ui.md)
- [docs.litellm.ai/docs/proxy/security_best_practices.md](https://docs.litellm.ai/docs/proxy/security_best_practices.md)

## Keep reading

- [Self-host any app with your agent](https://envhaven.com/self-host)
- [Self-host Open WebUI](https://envhaven.com/self-host/open-webui)
- [Self-host LibreChat](https://envhaven.com/self-host/librechat)
- [Self-host AnythingLLM](https://envhaven.com/self-host/anythingllm)
- [Self-host Dify](https://envhaven.com/self-host/dify)
- [AI agent hosting](https://envhaven.com/guides/ai-agent-hosting)

Source: https://envhaven.com/self-host/litellm
