Every app wants AI now, and each one arrives with its own model, its own API key and its own settings. In our self-hosted app store, three apps (a video editor, an English-practice chat and a music studio) had each loaded their own copy of Whisper, and every new AI feature started with the same question: which key goes where?

So we went the other way: no app holds an AI key, and no app picks a model. Every app and every agent goes through one front door, the AI Hub, and the owner decides there which model answers, what an AI may do, and what is kept on record.

This post walks through how it's built: the doors, the "use" abstraction, the tool layer with a human in the loop, the engines that run on the Mac's GPU and Neural Engine, and the single memory budget that keeps it all on one 24 GB Mac. There's an 8-minute video too, recorded live on the real apps:

TL;DR

  • Apps ask the hub for a use (smart, fast, local, coder, hear, transcribe, listen, speak, music), never a model. The owner maps each use to a model once, for every app.
  • Agents (Claude Code, Codex, Cursor or your own program) get one MCP address that carries the tools of every installed app. Anything that speaks the OpenAI API gets an OpenAI-style door.
  • Every tool is marked read, write or danger. A danger call stops in the hub until a person presses Accept. No prompt can talk its way past that.
  • Apps hold no AI keys: each request carries a 5-minute token signed by the platform that names the app and the person.
  • Models that need the GPU or the Neural Engine run as engines in one small helper on the host, because Docker on a Mac can't reach either.
  • One memory budget for the whole machine: before a big model loads, idle ones leave, least recently used first, never a busy one.
  • It's open source (MIT): ai_hub on GitLab, part of Agentic App Store.

Why one door?

A few numbers from the research behind the video:

  • Netskope now tracks more than 1,600 generative-AI apps, and the average organization logs 223 data-policy violations a month, mostly source code, regulated data and intellectual property. (Netskope, Jan 2026)
  • 29% of employees already turn to AI agents their company never approved, while only 47% of organizations have security controls specific to GenAI. (Microsoft Cyber Pulse, Feb 2026)
  • Trend Micro found 1,467 MCP servers exposed to the internet without basic security controls, nearly triple the count from July 2025. (Trend Micro, Apr 2026)
  • Only 21% of executives say their organization has a mature governance model for agentic AI. (Deloitte, Apr 2026)

And the hopeful one: when a company offers a managed way in, people take it. The share of AI users on personal accounts fell from 78% to 47% in a year (same Netskope report). Banning AI doesn't work. Giving it one governed door does.

The architecture

Architecture of the AI Hub: four doors in, the hub with uses, tools, records and a memory budget, and where the answers are made

Four kinds of callers come in through four doors:

Door Who uses it Endpoint
Apps every app in the store, through the shared library reflex_ddns_auth.ai /api/ai/*
Agents Claude Code, Codex, Cursor, your own MCP client /api/mcp (Streamable HTTP)
OpenAI-style anything you can point at a base URL /api/v1/*
People the assistant inside any app, and a talking AI pages of the hub

Behind the doors the hub keeps four things: the uses and the models they map to, the tools of every installed app, the records, and the memory budget. Below it are the places answers are actually made: Ollama on the same machine, cloud APIs with your own key, the hub's own speech models, and engines on the Mac itself.

1. Apps ask for a use, not a model

This is the idea everything else hangs on. An app never says "Claude Opus" or "qwen2.5:7b". It says what kind of help it needs:

from reflex_ddns_auth import ai # once, next to app = rx.App(...): what this app asks each use for, in plain words ai.uses(app, smart="The assistant panel's answers", coder="Writing or fixing a cell (⌘I)", fast="The grey suggestions while typing") # later, anywhere in the app's backend reply = ai.stream("coder", system="You edit one cell of a notebook...", messages=[{"role": "user", "content": "..."}], user="someone@example.com") async for piece in reply: # the answer as it is written ... reply.model # e.g. "Claude (claude-opus-5-5)", for the app's badge 

On the hub's Uses page the owner decides, once for every app, which model answers each use, plus a backup for chat uses and an override for a single app if needed:

The Uses page: smart, fast, local and coder, each with the model that answers it and a backup

A few things fall out of this almost for free:

  • Swapping models is a setting, not a deploy. In the video I switch fast to another model on the Mac, and every app that asks for fast gets it on its next request.
  • local is enforced by the hub, not by app code. A use marked local can only reach sources on this machine (Ollama, LM Studio), and the hub refuses any cloud model for it.
  • The app explains itself. The words an app gives ai.uses() show up on the hub's page, so the owner sees "Captions from what is said in a project's videos" instead of an opaque API key.
  • Backups are honest. If a use's model can't start answering (its source is down), the backup answers and reply.model names it. An answer that fails halfway fails; it isn't silently stitched together from two models.

The hub reaches models through Anthropic's SDK, Ollama's own chat API, or any OpenAI-style source (OpenAI, OpenRouter, Gemini, Groq, DeepSeek, LM Studio, llama.cpp). Adding a source is a form on a page: a name, an address and a key.

One gotcha worth sharing: Ollama's default context is 4,096 tokens, and it silently drops the start of the chat when you go over. With an app's guide and tool schemas in the prompt, that left almost no room. The hub now asks Ollama for a 16k context on every request.

2. Agents: one MCP address for every app's tools

Apps don't only use AI; they also lend their abilities to it. A tool is one decorator on a function in the app:

from reflex_ddns_auth.tools import tool from reflex_ddns_auth import rooms @tool(app, "cad.run_preview", kind="write", params={"room": "The room."}) async def run_preview(ctx, room: str = "default") -> dict: """Builds the room's model and shows it in every tab of the room.""" async with rooms.change(CadState, room) as cad: # everyone in the room sees the change ... return {"ok": True} 

The app serves /_ddns_tool/manifest and /_ddns_tool/call/<name>, and the hub discovers it through the platform. When you install a new app, its tools simply show up. Agents connect once:

claude mcp add --transport http apps https://ai.reflex-ddns.com/api/mcp \ --header "Authorization: Bearer <token>" 

Each agent gets its own token, named after whoever will use it, and that name is how the AI shows up inside the apps. For everything else there's an OpenAI-compatible door where the "model" is just a use:

curl https://ai.reflex-ddns.com/api/v1/chat/completions \ -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \ -d '{"model": "fast", "messages": [{"role": "user", "content": "Say hello."}]}' 

The Agents page: one MCP address with a token per agent, and the OpenAI-style door

3. A human in the loop, enforced in code

kind is part of the tool's definition: read, write or danger (it also goes out to agents as MCP tool annotations). A danger tool is anything that deletes or replaces someone's work. When a model calls one, the hub doesn't forward the call. It shows the person what would happen and waits:

Wordora's assistant wants to replace a phrase everywhere; nothing happens until the person presses Accept

Accept, Accept all in this chat or Reject. Four minutes without an answer counts as no. A rejected change never reaches the app. The important part is where this lives: in the hub, keyed on the tool's declared kind. It's not an instruction in a system prompt that a clever prompt injection could argue with.

An app can also ask for consent in the middle of a call, for something it only learns at run time (ask_first(ctx, "read the chip's sources")). The hub then shows Allow / Decline, and on Allow it calls again with the person's consent signed into that one call's token.

And because "the AI tried to delete everything and I said no" is exactly what you want to find a week later, every tool call lands in a hash-chained history with the person's answer. I wrote a whole post about that part: My AI agents now leave a receipt.

The history of the AI's actions: danger calls with accepted or rejected, and a Check for the hash chain

4. No keys in apps, records without content

  • Apps hold no AI keys. Every request from an app carries a token signed with the platform's secret. It names the app and the person and expires after 5 minutes, so there is nothing long-lived to steal from an app's container.
  • Every ask is logged as metadata only: when, which door, which app and person, which use, which model answered, how long it took, and what went wrong. Never what was asked or answered. That log keeps 30 days.
  • A passcode locks the hub: locked, every page can be read and nothing can be changed.

5. Engines: when Docker can't reach the chip

Everything in the store runs in Docker. On a Mac that means Linux in a VM, with no access to the GPU or the Neural Engine. For chat that's fine (Ollama runs natively on the host anyway). For speech it wasn't: Whisper large-v3-turbo took about 4 seconds per piece of live microphone on the CPU.

So models that need the machine's own chips run as engines of one small helper on the host (a LaunchAgent on 127.0.0.1:3144, Python standard library only). The hub relays to it the same way it relays chat to Ollama, and the app never knows where its answer was made. Every engine shares one contract: a card that describes it, install, start, stop, settings, and work in one of three shapes:

Shape What it is Example
ask answered at once a piece of a microphone to words
job reports progress, leaves files a song from ACE-Step
stream fed pieces as they come, answers as it goes subtitles while someone is still speaking

The streams don't use WebSockets. Each piece of audio is one small POST on a kept-alive connection, answered with whatever the model has so far. That keeps the helper standard-library-only and adds about 0.1 s end to end, from the app's backend through the hub and the helper.

What we measured on an M4 Pro:

  • Whisper on the GPU (MLX): a live-microphone piece in 0.4 to 0.6 s instead of about 4 s on the CPU, and a 2.5-minute recording in 7 to 8 s instead of 54.
  • Live subtitles on the Neural Engine (Nemotron Speech Streaming, through Core ML in a small Swift worker): first words on screen after about 0.7 s instead of 1.1 s, and 3 of every 100 shown words changed later instead of 34, at about the same accuracy (8.9% word error rate against 8.4%, on Mandarin-accented English read by 40 adults). It holds about 0.7 GB, against 2.5 GB for the Whisper setup.

6. One memory budget for the whole machine

Docker's VM, Ollama's loaded models and the engines all eat the same RAM, and only the hub can see all three. So the hub keeps the budget:

This machine's memory: Docker, the Nemotron engine, and the system, with a log of what left memory to make room

AI may hold the machine's memory, minus Docker's allowance, minus 4 GB for the owner's own programs. Before a model that isn't in memory gets asked, idle holders leave, the one used longest ago first, and a busy one never does. On a 24 GB Mac with an Ollama model and the speech model loaded, the music engine took 73 s to start; with the hub clearing room first, 42 s.

Design choices you might argue with

  • Uses instead of model names. It adds one level of indirection, but in return apps never change when models do, and "keep this data local" becomes a rule the hub enforces instead of a convention every app has to remember.
  • Approval lives in the hub, not in the prompt. It costs a round trip to a human, but the guarantee doesn't depend on the model behaving.
  • The tool history keeps what the AI sent; the ask log keeps no content. That's deliberate: a tool call is an action on someone's data, and you need to see it later. A chat request isn't.
  • HTTP POSTs instead of WebSockets for live audio. Unusual, but it kept the host helper free of dependencies, and the overhead was about 0.1 s.
  • "Claude Code on my computer" as a model source. While I develop, the hub can hand a chat to my own Claude Code session through a Claude Code channel. That's strictly for the owner's own development, behind the passcode; an organization should use an API key, and the hub's docs say so.

If you know LLM gateways like LiteLLM, the routing part will look familiar. What the hub adds is the other half: the apps' tools behind one MCP address with approvals, the speech and music engines on the host's own chips, and one memory budget across all of it.

Try it, and tell me where it breaks

I'd love to hear how others handle this:

  1. How do your internal apps get AI today? A key per app, a gateway, or something else?
  2. Would you let an agent call a destructive tool if a human had to press Accept first, or do you keep agents read-only?
  3. If you run models locally, how do you share one GPU between several apps?