Part 1 left you with a working private API. Great for scripts and editor tools, awkward for actual chat. curl doesn't remember conversations, can't switch models mid-thread, isn't fun to use on a phone.
Open WebUI is a self-hosted ChatGPT-style UI that speaks the OpenAI-compatible API LiteLLM is already exposing. The clean way to add it: drop two more containers into the same compose file (Open WebUI itself, plus a second Tailscale sidecar for the chat hostname). Nothing about part 1's API endpoint changes — you just gain a second URL for chat.
Who this helps
What you get
https://ai-chat.tail-abc.ts.net — for the chat UIPrerequisites
~/local-ai/docker-compose.yml + .env files from part 1Two more containers join the private Docker network: Open WebUI (the chat app itself) and ts-chat (a second Tailscale sidecar that exposes Open WebUI under its own tailnet hostname). Open WebUI becomes one of LiteLLM's clients, just like any other OpenAI-compatible app.
Two new containers (highlighted with NEW). LiteLLM and the engine from part 1 are unchanged. The two sidecars expose two different tailnet hostnames; both ultimately terminate at LiteLLM, which terminates at the engine.
Six steps. Enable LiteLLM's key database, mint a virtual key for Open WebUI to use, mint a second Tailscale auth key for the chat sidecar, write the chat sidecar's serve config, add two services to the compose file, claim admin and verify.
Virtual keys live in a database. Part 1 didn't set one up — the master key alone was enough. Open WebUI will use a virtual key, so we need to wire that up now. (Part 3 leans on this same setup for friend keys, so you're getting a head start.)
LiteLLM's standard image expects Postgres — its Prisma migrations are Postgres-flavored and don't apply cleanly to SQLite. Add a tiny Postgres sidecar to your compose file. It runs alongside Ollama and LiteLLM on the same private network; nothing is exposed to the host or the tailnet.
Edit ~/local-ai/docker-compose.yml. Add this db service alongside your existing services, and add a top-level volumes section if you don't have one yet:
services:
# ... existing ts-ai, litellm, ollama ...
db: # NEW
image: postgres:16-alpine
environment:
POSTGRES_USER: litellm
POSTGRES_PASSWORD: litellm
POSTGRES_DB: litellm
volumes:
- litellm-db:/var/lib/postgresql/data
networks: [ai-net]
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U litellm"]
interval: 5s
retries: 10
volumes:
litellm-db: {} # NEW (top-level)
Then update the litellm service block to know about the database. The existing depends_on: [ollama] (short list form) is incompatible with adding a healthcheck-gated dependency, so convert it to the long object form below — both entries together:
litellm:
# ... existing config ...
environment:
- LITELLM_MASTER_KEY=${LITELLM_MASTER_KEY?required}
- DATABASE_URL=postgresql://litellm:litellm@db:5432/litellm # NEW
depends_on: # REPLACES [ollama] short form
ollama:
condition: service_started # same behavior as the old list form
db:
condition: service_healthy # wait for pg_isready before booting
Don't add a database_url line to litellm-config.yaml. Prisma reads DATABASE_URL directly from the container's environment, and LiteLLM does the same — putting the URL in both places causes a known startup bug where the YAML value (literally os.environ/DATABASE_URL) gets re-exported over the env var, and Prisma then fails validation with "the URL must start with postgresql://". Compose env wins; leave the YAML alone.
general_settings:
master_key: os.environ/LITELLM_MASTER_KEY
# database_url intentionally NOT here — env var alone is correct
Bring up the new service and recreate LiteLLM:
cd ~/local-ai
docker compose up -d
docker compose logs --tail=30 litellm
# Look for "Applied migration(s)..." (Prisma running schema setup on first boot)
# and "Application startup complete." with no DB errors.
Why Postgres for a home setup? Overkill on the surface, but the LiteLLM image ships with Postgres-flavored migrations baked in. Trying to use SQLite leaves the schema half-applied — the connection succeeds but tables are missing, which presents as the (misleading) "DB not connected" error. Postgres is the documented happy path and the container footprint is small (~30 MB image, idle CPU).
Open WebUI will talk to LiteLLM as a client. We could give it the master key, but cleaner is to give it its own virtual key — that way you can revoke or rotate Open WebUI's access independently.
# From the home server (or any tailnet device with curl access):
curl -X POST https://ai-rig.tail-abc.ts.net/key/generate \
-H "Authorization: Bearer sk-your-master-key" \
-H "Content-Type: application/json" \
-d '{"models": ["llama-3.2-3b"], "key_alias": "open-webui"}'
# Returns: { "key": "sk-...", ... }
Save that sk- key — it goes in the next step's env vars.
If you see "DB not connected", the previous step didn't take. Confirm database_url is in litellm-config.yaml, that the litellm container restarted, and that docker compose logs litellm shows no DB errors at startup.
The new chat sidecar registers as its own tailnet device, so it needs its own auth key. Admin console → Settings → Auth keys → Generate. Single-use is fine; tag it tag:ai (same as ts-ai).
Append to your existing ~/local-ai/.env:
TS_AUTHKEY_CHAT=tskey-auth-XXXXX
OPENWEBUI_KEY=sk-virtual-key-from-step-1
Create ~/local-ai/serve-config-chat.json. Same shape as the part 1 serve config, but forwards to open-webui instead of litellm:
{
"TCP": { "443": { "HTTPS": true } },
"Web": {
"${TS_CERT_DOMAIN}:443": {
"Handlers": { "/": { "Proxy": "http://open-webui:8080" } }
}
}
}
Open ~/local-ai/docker-compose.yml and add these inside the existing services: block (don't replace anything from part 1):
open-webui:
image: ghcr.io/open-webui/open-webui:main
environment:
- OPENAI_API_BASE_URL=http://litellm:4000/v1
- OPENAI_API_KEY=${OPENWEBUI_KEY?required}
- WEBUI_URL=https://ai-chat.tail-abc.ts.net
volumes:
- open-webui-data:/app/backend/data
restart: unless-stopped
networks: [ai-net]
depends_on: [litellm]
ts-chat:
image: tailscale/tailscale:latest
hostname: ai-chat
environment:
- TS_AUTHKEY=${TS_AUTHKEY_CHAT?required}
- TS_EXTRA_ARGS=--advertise-tags=tag:ai
- TS_SERVE_CONFIG=/config/serve.json
- TS_STATE_DIR=/var/lib/tailscale
volumes:
- ts-chat-state:/var/lib/tailscale
- ./serve-config-chat.json:/config/serve.json
- /dev/net/tun:/dev/net/tun
cap_add: [net_admin, sys_module]
restart: unless-stopped
networks: [ai-net]
depends_on: [open-webui]
Add the new volume to the bottom volumes: block:
volumes:
ts-state:
ollama-models:
open-webui-data: # NEW
ts-chat-state: # NEW
Bring up the new pieces (existing services are unaffected):
docker compose up -d
docker compose logs -f ts-chat
# Watch for the same registration lines as part 1's ts-ai logs:
# active login: ai-chat.<your-tailnet>.ts.net
# Switching ipn state Starting -> Running
# serve: creating a new proxy handler for http://open-webui:8080
# Startup complete, waiting for shutdown signal
From your laptop, navigate to https://ai-chat.tail-abc.ts.net. Open WebUI's setup screen appears.
Claim the admin account immediately. Open WebUI uses "first user becomes admin" as bootstrap auth. Even though your tailnet ACL gates the URL, you want to own the admin account before anyone else lands on it.
Reference
Verify
https://ai-chat.tail-abc.ts.net from your phonehttps://ai-rig.tail-abc.ts.net) still responds to curl with the master key — chat addition didn't break the APICommon issues
docker compose exec open-webui curl -H "Authorization: Bearer $OPENAI_API_KEY" http://litellm:4000/v1/models."models" array, or use the master key while debugging.tailscale status from another device should list ai-chat.Caveats
Routing
Single hostname with path mounting
Instead of two hostnames (api + chat), put both behind https://ai-rig.tail-abc.ts.net using path-based routing. Works but Open WebUI generally expects to live at the document root, so this needs more careful Serve config and reverse-proxy headers. Two hostnames is the cleaner default.
Capability
Built-in RAG (document chat)
Open WebUI has document upload + retrieval baked in. Upload files in the UI's settings; it handles chunking and retrieval automatically. See the RAG pipeline project for a from-scratch alternative if you want custom logic.
Multi-user
Per-user chat accounts for family
Open WebUI's signup flow can be restricted post-admin-claim. Add accounts for family members; each gets their own chat history. Pair with stricter ACLs to limit who can hit the chat URL in the first place.
Mobile
Install as a phone app (PWA)
Add Open WebUI to your phone's home screen via "Add to Home Screen" in the browser share menu. Behaves like a native app — full-screen, app icon, no browser chrome — and still goes over the tailnet.
You and your devices can chat with your local AI. But what if you want friends to use it without inviting them to your tailnet? Or transparent cloud fallback when local is down or too slow? Or a single endpoint that mixes local + cloud models with per-user keys? That's part 3 — and it's purely configuration changes to the LiteLLM you already have. No new components, no rewiring.
Other follow-ups: