mullane.info

Setting up LocalAI as the house's AI gateway

2026-11-25 · local-ai

The idea behind local-ai is simple enough: one place in the house that family apps and tools talk to when they want an AI model, with a web UI for people and an OpenAI- and Anthropic-compatible API for things like Home Assistant. Eventually the models should run on hardware of our own (the llm-cluster plans, which are still just plans), but until that exists LocalAI forwards everything to Anthropic. The VM was built a couple of days ago and had nothing on it, so this go around was about putting LocalAI on it properly: rootless Podman, a pinned image, TLS, single sign-on, nightly backups and a way to give each tool its own key.

The first surprise was the version. LocalAI 5.0.1 had come out four days earlier, and 5.0 was a big release (chats now run on the server, the agents moved around, Studio became an add-on), so anything I half-remembered about how it worked was probably out of date. I had the agent read the docs for the exact tag rather than the website’s latest, and when the docs and the behaviour didn’t quite agree, the source. That turned out to matter more than once.

The bigger one was how LocalAI talks to Anthropic. Its cloud-proxy backend has two modes, and the default, passthrough, forwards the client’s request body exactly as it arrived. That sounds ideal until you notice that most of our clients speak OpenAI’s format: the web UI’s own chats, Home Assistant, any script. Passthrough to Anthropic only works for clients that already send Anthropic-shaped requests, and the “remotes” feature in the UI (which is what the first-run screen nudges you towards) creates exactly those passthrough entries. Translate mode converts in both directions instead. The docs say it drops tool calls, but the 5.0.1 source translates those too; it does drop images, which is fine for now. So the models are two small YAML files in the repo rather than something clicked together in the UI: claude (Sonnet 5.5) as the default and claude-fast (Haiku 5.5) for the cheap, quick stuff like Home Assistant intents, both with prompt caching turned on. Without an API key yet, we tested the whole path with a dummy key and got Anthropic’s “invalid x-api-key” back through both the OpenAI and the Anthropic endpoints, which is about as much success as a fake key can buy.

Sign-in had a trap of its own. Turning on accounts with nobody registered gives you a first screen that says “Create the admin account”, for whoever happens to load the page first. So local sign-up was off from the very first start, which left only a generated admin key on the VM until Authentik was wired in. LocalAI does OIDC natively now, so there’s no proxy in front of it: an Authentik app restricted to a local-ai-users group (just me so far), and whoever Authentik lets through gets an account, with my address marked as the admin.

Per-client keys were the next wrinkle. LocalAI has “paired clients”: a key per tool, limited to the models you list, revocable on its own. Pairing a client with the generated admin key fails with “a named account is required”, because that key belongs to no account at all. So per-client keys wait until I’ve signed in once and made an admin key of my own; there’s a small client-key script on the VM ready for that, which writes each new key to a file and never prints it.

A couple of smaller things worked out nicely. The image starts as root only to hand its data folders to uid 10001 and then drops to it, which under rootless Podman normally means files owned by some subordinate id and a lot of podman unshare. Mapping the service user straight onto 10001 (UserNS=keep-id:uid=10001,gid=10001) makes the container start as that user, the entrypoint skips its chown, and everything on disk is just owned by localai. And since cloud-proxy models get LocalAI’s PII filter by default but have nothing to scan with, we added its in-process pattern detector, so a pasted API key or private key gets the request blocked before it leaves the house. I tested it with a fake GitHub token and it refused.

LocalAI also serves TLS itself now (1.3 only), so there’s no reverse proxy either: the certificate comes from the firewall’s ACME client like everywhere else, and the deploy script restarts the container, since it only reads the certificate at start. The nightly backup takes an online copy of the SQLite database plus the config, models and data, leaves the Anthropic key out on purpose, and the first one landed on mediarr at 80 KB.

What’s left is mostly mine: putting the Anthropic key on the VM (with a spend limit set in the Console first), deciding who besides me gets in, and how long chat backups should live on mediarr. That can wait until after the trip. The plumbing is all there, and for now it’s a very well-secured way of getting a 401 from Anthropic.