The app does the maths. The model writes the answer.

Seven AI services became one engine at a Swedish public housing company. Each question goes to a model by how sensitive its data is, and confidential data only reaches a model they host themselves.

A Swedish public housing company had seven separate AI services, each with its own answer to the question "where does our data go?". I replaced them with one engine that every app on their platform calls. It took about three weeks from plan to a working engine, a chat, a standard for apps and the first app in test.

Two rules

The app does the maths, the model writes the answer. When someone asks about rents, cases or properties, the app that owns the data looks up and calculates the numbers. The model only turns them into a readable answer, and the engine checks the numbers in the answer against the app's own data before it goes out.

The data decides the model. Every question gets a classification: confidential, internal or external. Confidential data is only ever sent to a model the company hosts on its own servers. The rest can go to OpenAI or Anthropic. If the right model isn't available, the engine switches to one that is approved for that class, never to one that isn't.

Where the classification comes from

Not from guessing at the prompt. Each app declares the classification of its data, and there is also a central register. The engine takes the stricter of the two. An app can't talk its way down to a less careful model, and a register entry that is out of date can't either.

One engine instead of seven

  • One stream for every model. OpenAI, Anthropic and the self-hosted model sit behind the same interface. Models are configuration, not code, so changing one is a setting.
  • Answers with sources. Documents are searched in the same Postgres database (pgvector), and every answer shows what it is based on.
  • Permissions follow the user. The engine asks the apps as the person who asked the question, so nobody gets an answer built on data they couldn't open themselves.
  • One place for policy. Which model may see what, and what was asked, lives in one engine instead of seven.

A standard, so the next app is built the same way

Apps connect through MCP with a small standard: the app exposes what it can calculate, the engine decides which model may phrase it. I packaged the standard, and a check for it, as a plugin for coding agents, so whoever builds the next app gets the same rules without reading a document first.

The self-hosted model

The confidential path runs on a 35B open-weights model on their own servers, set up with a tool I wrote that turns a bare GPU server into a monitored LLM service with one command. That is a post of its own.

What I'd tell another team

Start from the classification policy, not from the model. Once it is clear which data may go where, the architecture mostly follows.