Client work

In-house AI

A self-hosted assistant for teams that need chat and document Q&A without sending files to a third-party model.

In-house AI architecture, animated: a question travels from your browser through Cloudflare Access and an outbound-only tunnel into a private Docker network on your machine. Open WebUI searches documents in Postgres with pgvector, LiteLLM sends the question to a local model in Ollama (or vLLM on bigger hardware), and the answer streams back the same way. External models are off unless you add one, and nothing is listening for inbound connections.
Follow one question through the stack. It reaches the chat app through a tunnel that dials out, so no inbound ports are open, the gateway hands it to a model on your hardware, and the answer streams back the same way. External models stay off unless you add one.

DOCKER · OLLAMA · LITELLM · PGVECTOR · CLOUDFLARE TUNNEL

The problem

I built In-house AI for a client, then released it as open source. The problem it solves is a common one: a small agency or a regulated practice with folders full of contracts, finances, HR records, and client files. An AI assistant would save them hours every week. But pasting those files into a public chatbot is out of the question, and they don’t want yet another company storing their conversations.

What I built

In-house AI is a private, ChatGPT-style assistant that runs on hardware the team already owns, from a laptop with no graphics card to a server full of GPUs. One Docker Compose file starts everything: the chat app (Open WebUI), a model gateway (LiteLLM), local models (Ollama), and a database (PostgreSQL with pgvector) for chats and documents. A one-time job downloads two small models to get you started, Qwen3 4B for chat and nomic-embed-text for searching documents.

The model, the document search, and the data all stay on that machine. No outside AI provider is set up. Adding one is a deliberate choice, never a default. Each person’s documents are kept separate, and sign-ups close after the first admin account. The setup guide includes a check for it: sign in as a second user and confirm they can’t see the first user’s files.

Asking questions about your documents

Upload contracts, policies, or client files into a knowledge base, pick it in a chat, and ask a question. A local model turns the question into numbers, pgvector finds the closest passages in documents that person is allowed to see, and the chat model reads the question plus the top three passages. The answer streams back with citations that link to the source.

All of it goes through the gateway, never straight to the model server, so swapping a model never touches the chat app.

How In-house AI answers a question about your documents, animated: you ask, a local model embeds the question, pgvector finds the closest passages, the local chat model reads the question plus the top three passages, and the answer streams back with citations. Every step runs on your machine. Reading the prompt is the slow step: for about 3,500 tokens the first word arrives after about 30 seconds on a laptop with a 4 GB GPU and about 1 minute 45 seconds on a CPU-only laptop.
One question over your documents, step by step. Everything runs on the machine, and reading the retrieved passages is the slow part on small hardware.

Keeping it private

Nothing on the machine is open to the internet. No port is published to the network, and the chat app is also bound to localhost only. For access from outside, a Cloudflare Tunnel connects outward, and Cloudflare Access checks who you are before you even see the login page.

There’s an honest trade-off: Cloudflare can see the traffic as it passes through. For stricter data, switch to Tailscale, which is end-to-end encrypted and only sees who connected, or keep it on the office network only. The tunnel and Tailscale are both optional extras you switch on. Setup still needs internet access to download the software and models.

How fast it really is

I wrote a small benchmark and ran it on two ordinary laptops with the same 4-billion-parameter model: one with a 4 GB GTX 1650 graphics card, and one with no graphics card at all. Short chats feel quick on both, with the first word arriving in under a second.

Reading long prompts is the slow part, and a question over documents makes a long prompt. With about 3,500 tokens, roughly a 2,000-word document, the GPU laptop takes around 30 seconds before it starts answering, and the CPU-only one takes about 1 minute 45 seconds. That’s why the setup guide suggests keeping the number of retrieved passages low on small hardware.

Those numbers measure the model on the hardware. A real question in the chat adds the embedding and the search, so the wait you see is a little longer.

Room to grow

When the team outgrows it, the gateway can switch to vLLM on bigger machines. It’s one entry in a config file, and the chat app keeps asking for the same model name, so nothing else changes.

LiteLLM gateway’s Models + Endpoints screen listing two models served locally by Ollama: local-chat (Qwen3 4B Instruct) and local-embed (nomic-embed-text)
LiteLLM puts every local model behind one private, OpenAI-style API, with keys and budgets. Swapping a model is one entry in its config file.
In-house AI chat in Open WebUI: a vocabulary-practice request answered by the local-chat model running on the team’s own hardware
Day to day, the team chats in Open WebUI against a local model. Prompts and answers never leave the machine.

Whether the answers are right

I checked whether the retrieved passage was the right one, and whether the answer used it correctly. The harder run is the one to publish. Same CPU-only ThinkPad, same two models (Qwen3 4B Instruct and nomic-embed-text), temperature 0, top 3 from pgvector. The chat model is told to use only those passages and to say when they don’t contain the answer. Open WebUI’s file splitter was not part of either run.

The harder set has sixteen passages, each with two facts, and several are written to echo the question while stating the wrong number. Twelve questions are paraphrased. Two ask for things the handbook never mentions.

Check Harder set Easier set
Right passage first (hit@1) 9/12 (0.75) 11/11
Right passage in the top 3 12/12 11/11
MRR 0.86 1.00
Required fact in the answer 9/12 11/11
Handbook is silent, and the model said so 2/2 2/2
Answers fully correct, refusals included 11/14 (0.79) 13/13

The three misses:

  • Vacation days. A sick-leave passage copied the question (“standard week rather than reduced hours,” “vacation”) and said that balance is not vacation. It ranked first. The 18-day passage was second. The model said the handbook doesn’t say.
  • Parental leave. The right passage was first (“main carer… 16 weeks… still be paid”). The model still refused, because the question said “the parent who stays home with a new child.”
  • Production pager. The right passage was third. The model answered “48 hours” from a passage about swapping the on-call week. That number is in the retrieved text, so a check that only asks “did this number appear in the passages?” still passes. Grounded is not the same as correct.

One answer that scored as correct also dragged in an extra fact: the vacation-notice reply added “the other parent can take 4 weeks,” which was in the top 3 but not about the question.

The easier run, one fact per short paragraph and questions in the handbook’s own words, stayed perfect. That shows the pipeline works when the wording matches. It is the weaker claim.

Both runs are benchmarks/eval_rag.py. Raw scores for the harder run are in benchmarks/eval/results-hard.json, with its handbook in corpus_hard.json. The easier ones are corpus.json and results.json.

What I left out on purpose

Dedicated tracing tools, GPU monitoring, and personal-data masking aren’t included. Teams that self-host usually have their own preferences, and every extra layer is more to install, secure, and maintain.

Tracing needs no extra service to start with. The LiteLLM gateway sits in front of every model call, so it already records each one: model, tokens, latency, status and errors, in the Postgres the stack already runs. You view them in its admin page or through its API. Prompts and answers are not stored unless you switch that on.

Add a dedicated tracing tool when you need to follow one request across several calls, read and score real conversations, or compare prompt versions. To see who asked you don’t need one: by default every call arrives under Open WebUI’s one key, but Open WebUI can forward the user’s identity to LiteLLM. A dedicated tool costs extra services and keeps conversations in a second place, so most teams running the assistant for others can skip it. LiteLLM can send calls to tools such as Langfuse through its callbacks if you do need one.

What’s public

The product site, with a setup guide that covers installing with or without the script, is at inhouse-ai.razajahangir.dev. The full setup is on GitHub, MIT licensed: the compose file, the gateway config, the benchmark with its raw results, and the security notes. The software it’s built on keeps its own terms. Passwords and keys stay in a private settings file that never gets committed.