🔧 AI Nachrichten GenAI Workflows für Social Media Content(02.09.2026 um 14:00 Uhr)
🪟 Windows TippsLangsamer Start des VLC Media Players beheben(05.09.2026 um 17:17 Uhr)
🪟 Windows Tipps<b>Windows</b> - IT-Administrator.de(04.09.2026 um 04:17 Uhr)
🔧 AI Nachrichten GenAI Workflows für Social Media Content(02.09.2026 um 14:00 Uhr)
🔧 AI Nachrichten GenAI Workflows für Social Media Content(02.09.2026 um 14:00 Uhr)
🪟 Windows TippsLangsamer Start des VLC Media Players beheben(05.09.2026 um 17:17 Uhr)
🪟 Windows Tipps<b>Windows</b> - IT-Administrator.de(04.09.2026 um 04:17 Uhr)
🔧 AI Nachrichten GenAI Workflows für Social Media Content(02.09.2026 um 14:00 Uhr)

26 🕛 kürzlich 10 Min Lesezeit
0

How to Build a Self-Hosted AI Gateway With LiteLLM and Open WebUI

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

If you've ever self-hosted AI tools, you know how quickly things get messy.



One app talks to OpenAI. Another uses Anthropic. You spin up Ollama locally and now there's a third endpoint to manage. Authentication is different everywhere. Switching models means rewriting integration code. And before long, you're spending more time maintaining glue code than actually building anything.



I ran into this exact problem — so I built a cleaner setup.



The idea is simple: put a single gateway in front of every provider, so the rest of your stack only ever talks to one API.



I open-sourced the full working implementation here:




🔗





CODE
├── Docker-compose.yml
├── litellm-config.yml
└── .env






Each file has a distinct job: Docker Compose orchestrates services, LiteLLM config handles routing and model aliases, .env stores secrets and runtime configuration.









Setting Up Environment Variables



Your .env file is where provider credentials live. Create or update it in the project root:




CODE
LITELLM_MASTER_KEY=sk-very-strong-key
OPENAI_API_KEY=...
ANTHROPIC_API_KEY=...
GROQ_API_KEY=...
OLLAMA_CLOUD_API_BASE=https://<host>/v1
OLLAMA_CLOUD_API_KEY=...






A few things that matter more than people expect:





  • LITELLM_MASTER_KEY becomes the authentication layer between Open WebUI and LiteLLM

  • These values should never be committed into Git

  • Weak keys become a real security problem once remote access exists



Even if this starts as a personal setup, treat the environment config like production from day one.









Wiring Docker Compose



The goal here is making sure the containers can talk to each other. Most deployment failures come from small config mismatches rather than Docker itself.



Your Docker-compose.yml should point Open WebUI directly at LiteLLM:




CODE
OPENAI_API_BASE_URL=http://litellm:4000/v1
OPENAI_API_KEY=${LITELLM_MASTER_KEY}






This tells Open WebUI where the gateway lives and which key to use.



LiteLLM should mount the configuration file correctly:




CODE
./litellm-config.yml:/app/config.yaml







⚠️ That filename matters more than it looks. A typo here can cause Docker to create a directory instead of mounting the file — which leads to confusing startup errors later.










Configuring LiteLLM



Inside litellm-config.yml, LiteLLM defines model aliases, provider routing, gateway behavior, and authentication settings.



The most important section is the master key:




CODE
general_settings:
master_key: os.environ/LITELLM_MASTER_KEY






This keeps secrets outside the YAML file and makes credential rotation easier later.



Inside model_list, make sure provider model IDs are current. Model names change more frequently than most people expect — especially across Groq and newer OpenAI releases.









Starting the Stack



Once your config looks right, start everything:




CODE
docker compose up -d --force-recreate






The initial startup may take a minute while Docker pulls images, initializes PostgreSQL, and creates container state.



Verify container health:




CODE
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'






You should see open-webui, litellm, and litellm-db all running.



If a container exits immediately, check its logs before moving forward:




CODE
docker logs <container-name>












Validating the Gateway



Before touching Open WebUI, validate LiteLLM first. The /v1/models endpoint confirms authentication works, providers loaded correctly, and model routing initialized.




CODE
set -a && source .env && \
curl -s http://localhost:4000/v1/models \
-H "Authorization: Bearer $LITELLM_MASTER_KEY"






For readable output:




CODE
set -a && source .env && \
curl -s http://localhost:4000/v1/models \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
| python3 -m json.tool | head -n 80






If this endpoint fails, Open WebUI will almost certainly fail too — so resolve gateway issues first.









Verifying Open WebUI



Once LiteLLM responds correctly, open the interface:




CODE
http://localhost:3000






You should be able to create chats, select models, and send prompts normally.



If the model dropdown is empty, LiteLLM authentication is usually the cause — mismatched master keys, stale model IDs, or invalid provider credentials.









Keeping Provider Models Current



This catches a lot of people off guard: provider model identifiers change more often than you'd think. A deployment that worked perfectly a few months ago can break because a provider deprecated a model name.






Checking Local Ollama Models






CODE
ollama list









Checking Groq Models






CODE
set -a && source .env && \
curl -s https://api.groq.com/openai/v1/models \
-H "Authorization: Bearer $GROQ_API_KEY" \
-H "Content-Type: application/json"






After updating model IDs in litellm-config.yml, recreate the stack:




CODE
docker compose up -d --force-recreate












Secure Remote Access with Cloudflare Tunnel



At this point, the stack only exists locally. The next step is exposing Open WebUI to the internet — without opening inbound ports, exposing your home IP, or managing reverse proxies manually.



Cloudflare Tunnel creates an outbound encrypted connection from your machine to Cloudflare's edge. You get:




  • Automatic HTTPS

  • Hidden origin infrastructure

  • Cloudflare proxy protection

  • Simple DNS management






Move DNS to Cloudflare




  1. Add your domain to Cloudflare

  2. Update nameservers at your registrar

  3. Wait for propagation






Authenticate cloudflared






CODE
cloudflared tunnel login






This opens a browser window for authorization.






Create the Tunnel






CODE
cloudflared tunnel create openwebui






Cloudflare generates a tunnel UUID and a credentials JSON file.






Route a Subdomain



Assuming your domain is chat.yourdomain.tech:




CODE
cloudflared tunnel route dns openwebui chat.yourdomain.tech









Create the Tunnel Configuration



Create ~/.cloudflared/config.yml:




CODE
tunnel: openwebui
credentials-file: ~/.cloudflared/<tunnel-uuid>.json

ingress:
- hostname: chat.yourdomain.tech
service: http://localhost:3000
- service: http_status:404






Replace <tunnel-uuid> with the generated filename.






Run the Tunnel






CODE
cloudflared tunnel run openwebui






For persistent startup on macOS:




CODE
cloudflared service install
cloudflared service start






Running the tunnel as a background service is significantly more reliable than keeping it in a terminal session.









Verifying Remote Access



Quick DNS and connectivity check:




CODE
dig +short chat.yourdomain.tech









CODE
curl -I https://chat.yourdomain.tech







Always use HTTPS for remote access. Cloudflare Tunnel is designed around secure proxied traffic.










Operational Health Checks



Once the stack is stable, this single command gives you a quick overview of everything:




CODE
set -a && source .env && \
echo "== Docker services ==" && \
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' && \
echo "\n== Local Ollama models ==" && \
ollama list && \
echo "\n== Groq model count ==" && \
curl -s https://api.groq.com/openai/v1/models \
-H "Authorization: Bearer $GROQ_API_KEY" \
-H "Content-Type: application/json" \
| python3 -c 'import sys,json; d=json.load(sys.stdin); print(len(d.get("data", [])))' && \
echo "\n== LiteLLM models ==" && \
curl -s http://localhost:4000/v1/models \
-H "Authorization: Bearer $LITELLM_MASTER_KEY"






Even for personal deployments, having this kind of visibility saves a lot of debugging time.









Troubleshooting



Stable deployments drift. Provider APIs change, Docker mounts break, credentials expire, model IDs get deprecated. Here are the most common failure patterns.






Open WebUI Loads but Models Are Missing



Empty dropdowns, missing providers, or authentication errors in LiteLLM logs.




CODE
docker logs --tail 200 litellm






Verify model visibility directly:




CODE
set -a && source .env && \
curl -s http://localhost:4000/v1/models \
-H "Authorization: Bearer $LITELLM_MASTER_KEY"






Typical fixes:




  • Verify OPENAI_API_KEY=${LITELLM_MASTER_KEY}

  • Confirm master_key uses the environment variable

  • Recreate containers:




CODE
docker compose up -d --force-recreate
docker compose restart open-webui









LiteLLM Fails with IsADirectoryError



Docker accidentally created a directory instead of mounting the YAML file.




CODE
ls -la ./litellm-config.yml ./litellm-config.yaml
grep -n "litellm-config" Docker-compose.yml






Correct mount:




CODE
./litellm-config.yml:/app/config.yaml






Then recreate:




CODE
docker compose up -d --force-recreate litellm









Works Locally but Not Through Cloudflare



If local access works but the public hostname fails, focus on the tunnel:




CODE
cloudflared tunnel list
cloudflared tunnel info openwebui
cat ~/.cloudflared/config.yml
dig +short chat.yourdomain.tech
curl -I https://chat.yourdomain.tech






Most remote-access failures come from inactive tunnel connectors, incorrect ingress targets, missing proxied DNS records, or running cloudflared in a temporary terminal session.






Models Appear but Generation Fails



If /v1/models works but prompts fail — provider credentials may be invalid, quotas exhausted, or model IDs no longer exist.




CODE
set -a && source .env && \
env | grep -E '^(OPENAI_API_KEY|GROQ_API_KEY|ANTHROPIC_API_KEY|LITELLM_MASTER_KEY)=' \
| sed 's/=.*/=<set>/'






Then inspect LiteLLM logs:




CODE
docker logs --tail 300 litellm






Refreshing provider model IDs solves this surprisingly often.









Security Recommendations



Once remote access exists, basic hardening matters:




  • Use a strong LITELLM_MASTER_KEY

  • Don't expose LiteLLM directly to the internet

  • Rotate provider API keys periodically

  • Keep CORS rules restrictive



For private or team usage, Cloudflare Access adds identity-aware access control in front of Open WebUI — worth enabling.









Capture a Known-Good Baseline



Once things are stable, save:





  • docker ps output


  • /v1/models output

  • Active model aliases

  • Tunnel status:




CODE
cloudflared tunnel info openwebui






When something breaks later, comparing against a working snapshot is almost always faster than debugging from scratch.









Try It Yourself



The full working implementation — Docker Compose, LiteLLM config, environment setup — is all here:




🔗 .

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 47%
🟡 In Evaluierung 32%
🟢 Keine Auswirkung 16%
Spannende Innovation 5%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Microsoft engineer says “typing code is absolutely over,” and Windows 11 is already being built that way
1 Quelle
GenAI Workflows für Social Media Content
1 Quelle
Langsamer Start des VLC Media Players beheben
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten How to Build a Self-Hosted AI Gateway With LiteLLM and Open WebUI

Thematisch verwandte Begriffe: Build, SelfHosted, Gateway, With · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...