I Built a Self-Hosted ChatGPT on My Laptop. Here's What Broke.
From DevOps to AI Platform Engineering — Part 1 I'm a DevOps engineer. I've spent years running Kubernetes clusters, writing Terraform and keeping production alive. Lately, every j
The architecture
</h2> <p><a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnkhborf5dgf9oecqowyo.png" class="article-body-image-wrapper"><img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnkhborf5dgf9oecqowyo.png" alt="OzAI architecture: browser, VS Code and scripts talk to a LiteLLM gateway in Docker Compose, which calls Ollama running natively on the macOS host" width="799" height="453"></a></p> <ul> <li> <strong>Ollama</strong> runs the models. It runs natively on macOS, not in Docker (more on that below).</li> <li> <strong>LiteLLM</strong> is the gateway: an OpenAI-compatible API with per-user virtual keys, model allow-lists, rate limits and a request log in Postgres.</li> <li> <strong>Open WebUI</strong> is a ChatGPT-style UI that talks only to the gateway.</li> <li> <strong>SearXNG</strong> is a self-hosted search engine, so the model can answer questions about recent events.</li> <li> <strong>Grafana</strong> shows dashboards built on the gateway's request log (part 2).</li> </ul> <p>Everything except Ollama runs in Docker Compose and binds to <code>127.0.0.1</code> only. Nothing is exposed to the internet yet.</p> <p><strong>Decision #1: Ollama runs on the host, not in a container.</strong> Docker on macOS runs containers inside a Linux VM with no access to the Apple GPU. Ollama in a container would run on the CPU only. On the host it uses Metal, and the containers reach it at <code>host.docker.internal:11434</code>. It looks less tidy in a compose file, but it's the difference between a usable system and an unusable one.</p> <h2>Step 1: How fast is a laptop, really?
</h2> <p>Before building anything, I measured. Here is one request per model, 200 max tokens, no concurrency:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>Model Disk Cold load Prompt eval Generation qwen2.5-coder:3b (Q4) 1.9 GB 2.1 s 120 tok/s 53.3 tok/s qwen3:8b (Q4_K_M) 5.2 GB 3.9 s 87 tok/s 22.4 tok/s </code></pre> </div> <p>Two things surprised me:</p> <ul> <li> <strong>The 8B model is less than half as fast as the 3B one.</strong> Generating tokens is limited by memory bandwidth, not compute. For every token, the model's weights have to be read from memory again. A model 2.7× bigger is roughly 2.4× slower.</li> <li> <strong>22 tokens per second is fine for one person.</strong> That's faster than most people read. The real question is what happens with more than one user, which comes later.</li> </ul> <p>Quantization (<code>Q4_K_M</code> = roughly 4 bits per weight) is what makes an 8B model fit in 5.2 GB at all. Without it, the same model needs around 16 GB just for its weights, which is all the RAM in this laptop.</p> <h2>Step 2: A gateway, not just a model
</h2> <p>Running a model is easy. Letting <em>other people</em> use it safely is the platform engineering part, and that's where LiteLLM comes in.</p> <p>The model list maps friendly names to real models:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight yaml"><code><span class="na">model_list</span><span class="pi">:</span> <span class="pi">-</span> <span class="na">model_name</span><span class="pi">:</span> <span class="s">ozai</span> <span class="c1"># fast chat</span> <span class="na">litellm_params</span><span class="pi">:</span> <span class="na">model</span><span class="pi">:</span> <span class="s">ollama_chat/qwen3:8b</span> <span class="na">api_base</span><span class="pi">:</span> <span class="s">http://host.docker.internal:11434</span> <span class="na">reasoning_effort</span><span class="pi">:</span> <span class="s">none</span> <span class="na">num_ctx</span><span class="pi">:</span> <span class="m">8192</span> <span class="pi">-</span> <span class="na">model_name</span><span class="pi">:</span> <span class="s">ozai-think</span> <span class="c1"># same model, thinking on</span> <span class="na">litellm_params</span><span class="pi">:</span> <span class="na">model</span><span class="pi">:</span> <span class="s">ollama_chat/qwen3:8b</span> <span class="na">api_base</span><span class="pi">:</span> <span class="s">http://host.docker.internal:11434</span> <span class="na">num_ctx</span><span class="pi">:</span> <span class="m">8192</span> <span class="pi">-</span> <span class="na">model_name</span><span class="pi">:</span> <span class="s">ozai-coder</span> <span class="na">litellm_params</span><span class="pi">:</span> <span class="na">model</span><span class="pi">:</span> <span class="s">ollama_chat/qwen2.5-coder:3b</span> <span class="na">api_base</span><span class="pi">:</span> <span class="s">http://host.docker.internal:11434</span> </code></pre> </div> <p>Then every client gets its own virtual key with its own limits:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>curl localhost:4000/key/generate <span class="se">\</span> <span class="nt">-H</span> <span class="s2">"Authorization: Bearer </span><span class="nv">$LITELLM_MASTER_KEY</span><span class="s2">"</span> <span class="se">\</span> <span class="nt">-d</span> <span class="s1">'{"key_alias":"demo-friend","models":["ozai"],"rpm_limit":10}'</span> </code></pre> </div> <p>I tested it the way I'd test any API gateway:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>No key -> 401 Friend key asking for ozai-coder -> 403 (not on its allow-list) 12 requests in a minute, limit 10 -> 9 x 200, then 429 (one earlier request counted in the same window) </code></pre> </div> <p>Any tool that speaks the OpenAI API can now use OzAI by changing two settings: the base URL and the key. That turned out to matter a lot for the IDE integration below.</p> <h2>What broke (the useful part)
</h2> <p>Nothing below threw an error. Every one of these problems showed up as "it works, but badly."</p> <h3>- A "thinking" model made every answer take two minutes
- A $0 budget blocked everything
- The UI was quietly competing with its own users
- More users don't get more throughput
- The model is confidently wrong, and has no idea what day it is
- The bug with no error: silent prompt truncation
- IDE integration: the gateway was the wrong path for autocomplete
What I'd tell another DevOps engineer
</h2> <ol> <li> <strong>The gateway is where your skills transfer.</strong> Keys, quotas, rate limits, routing, request logs: this is API platform work you already know. The model is just another upstream.</li> <li> <strong>Measure before you optimize.</strong> One table of tokens per second at 1, 2, 4 and 8 users explained more than any blog post I read.</li> <li> <strong>LLMs fail quietly.</strong> Truncated prompts, empty answers caused by thinking, confident hallucinations. None of them return a 500. Your monitoring has to look at token counts and answer quality, not just status codes.</li> <li> <strong>Small local models are fast and cheap, but not reliable as a source of facts.</strong> Give them context (search, documents) instead of trusting what they remember.</li> </ol> <h2>What's next
</h2> <ul> <li> <strong>Part 2: observability and load testing.</strong> A Grafana dashboard for TTFT, latency percentiles and tokens per second, built from the gateway's request log. Plus why LiteLLM's Prometheus metrics weren't an option.</li> <li> <strong>Part 3: from laptop to production.</strong> vLLM on Amazon EKS with GPU nodes, autoscaling on queue depth with KEDA, and the cost of self-hosting compared with paying per token.</li> </ul> <p>All configs, benchmarks and notes are in the repo: <strong><a href="https://github.com/ozy31/self-hosted-llm-platform" rel="noopener noreferrer">github.com/ozy31/self-hosted-llm-platform</a></strong></p> <p><em>If you're making the same move from DevOps into AI infrastructure, I'd like to hear what surprised you.</em></p>Original source
Tags
Related Articles
Continue reading with these similar posts

Apple’s M5 MacBook Air is down to its lowest price since July
Read Apple’s M5 MacBook Air is down to its lowest price since July and explore its linked sources.

🏈 Connelly: How CFB Week 10's top games were won
From Notre Dame's CJ Carr to Alabama's consistency, we examine the keys to victory on a statement Saturday.

Harbaugh: Giants pulled recent offer for RB Taylor but 'things do change'
The Giants pulled a recent trade offer for Jonathan Taylor, according to coach John Harbaugh, who added that doesn't mean a deal is completely off the table.

Reaves steps into Luka's shoes, drops 43 in win vs. Pistons
Austin Reaves did his best Luka Doncic impression with the MVP candidate resting vs. the Pistons on Sunday, scoring 43 points in the 121-116 win.

Giants' Nabers takes issue with Fox telecast after body-language comments
Malik Nabers took issue with Fox play-by-play man Joe Davis and analyst Greg Olsen for criticizing his body language during the Giants' win Sunday.

Bears' Williams undeterred by career-high 4 INTs: 'Going to keep grippin' it, keep rippin' it'
Caleb Williams refused to let his four interceptions rattle his confidence as he put the Bears in position to beat the Buccaneers on a walk-off field goal.