Lessons Learnt Self-hosting an AI Assistant

A few months ago, I built a fully self-hosted AI assistant running inside my organisation’s Azure infrastructure. The goal was simple. Give our staff an internal ChatGPT-like experience, backed by enterprise authentication, with data privacy guarantees, and the flexibility to plug in any LLM or search provider we wanted.
I chose OpenWebUI as the front end. It is open source, extensible, lightweight, and flexible enough to integrate with the rest of the platform. What started as a small experiment on my mac quickly turned into a production-ready deployment. Below is a breakdown of the architecture, the decisions, the rough edges, and the lessons learnt along the way.
If you are planning to self-host your own AI assistant, I hope this saves you time.
Why Self Host an AI Assistant
There are a few practical reasons why self-hosting made sense for me.
- Control. I wanted full control over routing, security, access, and plugins.
- Flexibility. I could mix and match models. GPT-5 for general tasks, DeepSeek R1 for reasoning, Perplexity for web search, GPT-Image-1 for generation.
- Integration. Running RAG, SSO, logging, and custom document pipelines is easier when the platform runs inside your stack.
- Cost and performance optimisation. You decide caching strategies, autoscaling, replica counts, and model tier choices.
OpenWebUI offers a clean, extensible interface while letting you connect whatever backends you want. That became the foundation.
Architecture Overview
The system is built on top of:
- Azure Kubernetes Service (AKS) for container orchestration
- Helm charts for deployment and configuration
- PostgreSQL as the persistent store for OpenWebUI
- Azure AI Foundry for provisioning LLM Endpoints
- LiteLLM Proxy deployed inside AKS for Reasoning models
- Perplexity API for real time web search
- Azure Entra ID for SSO
- Nginx Ingress Controller for load balancing, SSL, and DNS
- Apache Tika for RAG document parsing
The GitHub repo for OpenWebUI lives here: https://github.com/open-webui/open-webui
There may be a few questions about my choice here. Let me explain:
- Why LiteLLM Proxy? At the time of deployment, OpenWebui did not support LLMs that used Responses API which the reasoning models like O3 did not support.
- Why Apache Tika? It’s a service available out of the box in OpenWebui Helm charts. Extending OpenWebui was as simple as enabling it in values.yaml
Step 1: Deploying OpenWebUI on AKS Using Helm
OpenWebUI ships with a working Helm chart. This made deployment much more easier as long as you had a working AKS cluster. If don’t have AKS setup, that will form the bulk of your work. I would advise to engage with your Infrastructure / Platforms team to set up the foundational configuration.
Create the AKS Cluster
az aks create \
--name ai-assistant \
--resource-group ai-rg \
--node-count 3 \
--node-vm-size Standard_D4s_v5 \
--enable-managed-identityAdd Helm Repo and Install
helm repo add openwebui https://helm.openwebui.com
helm repo update
helm install ai-ui openwebui/open-webui \
--namespace ai \
--create-namespace \
--values values.yamlYour values.yaml is where most of the heavy lifting happens. Mine included PostgreSQL connection strings, SSO configs, ingress details, and model routing.
Some useful configurations I would recommend enabling on your setup:
OpenWebui:
- ENABLE_WEBSOCKET_SUPPORT: For session management, websocket coordination, and state synchronisation. Makes the whole experience butter smooth.
- VECTOR_DB: Set value as pgvector, unless you would like to setup and use your own Vector database.
- WEB_SEARCH_ENGINE: Use Perplexity API which gave us the best results among those available.
Postgresql:
- PgBouncer: Improve idle connections and short-lived connections at the database server.
- pgvector: Install the extension in Postgresql for similarity search capabilities used by RAG.
Step 2: Setting up LiteLLM Proxy
To deploy LiteLLM Proxy in Kubernetes using Helm, you can rely on its official Helm chart. Documentation here.
helm pull oci://ghcr.io/berriai/litellm-helm
# Pulled: ghcr.io/berriai/litellm-helm:0.1.2
# Digest: sha256:7d3ded1c99c1597f9ad4dc49d84327cf1db6e0faa0eeea0c614be5526ae94e2a
tar -zxvf litellm-helm-0.1.2.tgz
helm install litellm-proxy ./litellm-helm \
--set masterkey="sk-your-master-key" \
--namespace ai \
--create-namespaceAfter deployment you can port-forward or expose the service externally; by default the proxy listens on port 4000. At this point LiteLLM acts as a unified LLM gateway: you can define which models it proxies (via a config.yaml or environment variables), and your upstream applications like OpenWebui, can then make standard OpenAI-style requests against LiteLLM, which handles routing, load balancing, credential management, optional rate limiting or spend tracking, and service orchestration across multiple underlying LLM providers. I configured Deepseek R1 reasoning model as a proxy that was provisioned through our Azure AI Foundry service.
Step 3: Integrating AI Models
OpenWebUI talks to model providers through simple JSON configs. I wired four backends:
Azure AI Foundry
- GPT-5
- GPT-4o
- DeepSeek R1
Perplexity AI API Platform
- Search API — Sonar
Both Azure AI Foundry and Perplexity AI API platform are inherently Secure and Private which are important for Organisations from a data security standpoint.
Step 4. SSO Integration with Entra ID
This part took some fiddling, but once configured, it felt seamless.
App Registration
- Register a new application in Azure Entra ID.
- Add redirect URI:
https://your-domain.com/oauth/callback - Generate a client secret.
- Then, update the values in Helm chart's values.yaml as below:
auth:
oidc:
enabled: true
clientId: ${AZURE_OIDC_CLIENT_ID}
clientSecret: ${AZURE_OIDC_SECRET}
providerName: AZURE
providerUrl: https://login.microsoftonline.com/<tenant-id>/v2.0/.well-known/openid-configuration
scopes: "openid email profile"Once deployed, users are able to log in using Microsoft SSO.
Step 5. Nginx Ingress + DNS
A clean ingress setup can also be defined in Kubernetes Helm chart:
ingress:
enabled: true
class: "nginx"
annotations:
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
host: "ai.mycompany.com"
tls: true
existingSecret: "openwebui-tls"You can enable TLS with Azure Key Vault certs or cert-manager.
Nginx also plays nice with WebSockets which OpenWebUI uses.
What I Learned
A few lessons that might save you hours:
1. LiteLLM is underrated
It pulled all my model providers behind a single clean endpoint, which made routing and failover much simpler. My initial goal was just to expose reasoning models, but in hindsight LiteLLM works far better as a central hub. You configure every LLM backend once, and OpenWebUI gets a unified interface without any extra wiring.
2. Use managed PostgreSQL
Skip self-hosting PostgreSQL on AKS unless you actively want operational pain. Use a managed Postgres service instead, and make sure PgBouncer and pgvector are enabled. Beyond that, the default configuration is more than enough.
3. SSO first, then expose publicly
Too many deployments expose Nginx first and bolt security later. Do the opposite.
4. RAG is only as good as your parsing
Tika performed far better once I tuned memory limits and adjusted chunking behaviour. It does ship with a default 5 MB upload cap, and in practice you need to size the Kubernetes pod properly. Expect to allocate extra CPU or memory if you want it to handle heavier document loads reliably.
5. Autoscaling matters
Traffic spikes would trigger sudden bursts of model activity, which made an HPA setup essential. With 15–20 concurrent users, the cluster would hit its limits quickly, so I added autoscaling to ensure pods could size themselves appropriately with sensible requests and limits. I also defined clear scale-up and scale-down rules to keep the experience smooth during peak and quiet periods. If you introduce HPA, remember that your storage configuration will likely need adjustments as well. Here are the settings I ended up using:
# HPA
autoscaling:
enabled: true
maxReplicas: 4
minReplicas: 1
targetCPUUtilizationPercentage: 75
targetMemoryUtilizationPercentage: 80
behavior:
scaleUp:
stabilizationWindowSeconds: 60
policies:
- type: Percent
value: 50
periodSeconds: 60
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 25
periodSeconds: 60
# Storage
persistence:
enabled: true
size: 20Gi
accessModes:
- ReadWriteMany
storageClass: "azureblob-nfs-premium"
selector: {}
annotations: {}
provider: localFinal Thoughts
Self-hosting an AI assistant is not just a fun engineering project. It changes how teams interact with knowledge, code, documents, and operational tasks. With OpenWebUI, Azure Kubernetes Service, and a few integrations, you can build a highly capable AI platform without depending entirely on SaaS offerings.
If you are a developer or an AI enthusiast thinking about bringing an assistant closer to your data, this setup is a great starting point. The pieces fit together cleanly and almost everything is customisable.