How to build a private AI stack

Most guides to self-hosted AI are really guides to self-hosting models: install a inference server, wire a chat interface, talk to a large language model on your own hardware. That stack answers one question, where the model runs. This guide assembles a different stack, the one that answers the question people hit after their first week with an agent: where does the agent live? The answer has layers, a chat layer that is the spine, the agents that occupy it, the model question behind them, the glue that connects everything, and a bill at the end. Each layer below is documented in depth elsewhere in this cluster; this page assembles the whole machine and counts what it costs, honestly.
TL;DR
- The chat layer is the spine of the stack: one self-hosted Mattermost server carries every agent, every transcript and every integration, in a database you hold.
- Three agents cover the three reasons teams put AI in chat: an assistant lane, an always-on lane, and a coding lane, each with a deep guide in this cluster.
- The model question is genuinely optional to self-host: the agents treat models as pluggable providers, and keys to hosted models keep the chat and transcripts yours.
- The glue is where the stack starts feeling alive: scheduled reports, digest channels, workflow triggers, and tool connections, most of it built in.
- Counted honestly, the stack runs at a flat hosting rate plus whatever model usage you choose, with hardware measured in tens of dollars if you want your own.
Layer one: the chat spine
Begin with the layer everything else plugs into, because getting it wrong means migrating every agent later. A self-hosted Mattermost server is the spine for three structural reasons. It is where the transcripts live: every question asked, every file touched, every decision an agent records becomes a row in a PostgreSQL database, on a server and in a region that are yours to pick. It is where the identity model lives: each agent connects as its own bot account, carrying its own membership and rooms, so the workspace's permission system is the security architecture. And it is where the exit lives: export is a database operation, not a negotiation. The team meets all of it through ordinary chat clients, desktop and mobile, which is why adoption is rarely the hard part.
The room architecture follows from the spine. Private channels for the rooms where agents work, because transcripts name systems and plans; membership lists you curate, because a private room is an access decision; and one public digest channel for output the wider team should see, fed on purpose rather than by exposure. The three agent guides each draw this layout for their lane, and the shapes agree: the security model and the channel map are the same drawing.
The free Team Edition build carries all of this, a point worth pausing on because the paid-edition marketing is loud: bot accounts are unlimited, the APIs the agents use are the open ones, and no license is involved in the agent path at all. Where the paid editions matter, and precisely where they do not, is documented in our guide to Mattermost's AI features on the free version. The wider argument for self-hosting the chat layer at all, the training defaults, the vendor chains, the custody question, is made in the platform guide and the two privacy explainers in this cluster.
Layer two: the agents
With the spine standing, the occupants. The three this cluster documents in depth cover the three reasons teams put agents in chat at all.
The assistant lane: Hermes Agent. A platform rather than a single tool, with a gateway that keeps many platform connections open at the same time, per-channel prompts that make one agent behave differently in different rooms, and a home channel where its scheduled work files itself. It is the agent for research, operations and the general pull of a team's day. The deep guide covers the connection, the channel architecture and the security posture: Hermes Agent on Mattermost.
The always-on lane: OpenClaw. A messaging-first assistant whose chat modes decide when it listens, whose direct messages are gated by pairing codes, and whose answers stream into the channel as they form. It is the agent for watching a room, digesting a flow, being present. Its guide covers the modes, the pairing flow and the buttons: OpenClaw on Mattermost.
The coding lane: Pi. A community bridge maps each Pi coding session to its own channel, created automatically, with the whole session streaming in live: the channel list becomes the project list. It is the agent for work that touches a repository. The guide covers the two connection directions and the layout: the Pi agent on Mattermost.
One question makes the lanes concrete. Someone asks, at nine in the morning, what broke overnight. In the assistant lane, a complete reply lands in a thread, from an agent that was mentioned on purpose. In the always-on lane, the answer is already there: the room watched the night, and the digest streamed in as events happened, no question needed. In the coding lane, the answer is a channel, with the session that fixed the thing still streaming in it. Three lanes, one question, three shapes of answer, and a team that knows which room to stand in for which kind of problem.
Choosing between them is a real question with a documented answer, and choosing both is a supported state: the head-to-head lives in the Hermes versus OpenClaw comparison, and coexistence on one server, with the loop protection that keeps bots from talking to each other forever, is covered in every guide.
Layer three: the model question
Under the agents sits the question everyone asks first and can safely ask last: where do the models come from? Every agent in this stack treats models as pluggable providers. Point them at API keys and the agent runs on frontier models while every transcript, memory and decision stays in your infrastructure; the model provider sees requests, not your workspace. Point them at a local inference server and the words never leave your hardware, at the cost of running and supplying that hardware yourself.
What the provider sees is worth stating precisely, because the privacy framing often blurs it. An agent calling a hosted model sends a request and receives a completion; the provider's side of that exchange is the request, not your workspace, your channel map, your member list or your history. Those stay in the database the chat layer owns. Local inference closes the request path too, at the price of feeding and housing the model. The stack's custody does not depend on the choice; its network footprint does.
Both are legitimate private stacks, and the difference is smaller than the homelab guides suggest. The custody that matters most, who holds the transcripts, who holds the memory, who can export everything, is settled at the chat layer regardless of where inference happens. A reasonable assembly order follows from that: secure the spine, add the agents, keep the models wherever your budget and hardware say, and revisit the question whenever the economics move. No guide should pick the provider for you; the honest position is that the architecture does not care, which is the point of the architecture.
Layer four: the glue
The first week with an agent is conversations. The second week is automation, and the stack has more of it built in than most assemblies.
Scheduled work arrives through the agents themselves: Hermes files cron output into its home channel, so a Monday-morning digest of everything that ran, failed or needs a decision is a configuration line, not a project. Outbound delivery in OpenClaw addresses channels and users by name, which turns a public digest channel into a one-line job. Tools connect through the agents' own mechanisms, and the model-context-protocol lane has a precise boundary in this stack: the free Mattermost build's own agent plugin carries real limits, documented in the license guide, while your agents' tool use runs on their own rails and needs nothing from the Mattermost license at all. The channel itself is programmable surface in this stack: opt-in slash commands register an agent's verbs where the team already types, interactive buttons arrive verified, and reactions can carry meaning the agent reads, none of it requiring anyone to leave the chat client, which is the point, because the stack's promise is that the work comes to where the people already are. Where workflows outgrow chat, a self-hosted automation runner bridges the rest of the estate; n8n, which ships a Mattermost node, is the bridge this site offers as an app, and webhook-and-slash-command patterns cover everything else that beeps.
What it costs, counted honestly
What does the stack cost? Assembled on our hosting: a flat monthly rate for the Mattermost side, backups and updates and monitoring included, in whichever of 21 regions you choose. The agents are free and open source. The model budget is whatever you point it at, from nothing, if local inference is your choice, to usage-based spending on hosted providers. Hardware beyond the server is optional; the OpenClaw guide documents an agent gateway running on a computer priced in the tens of dollars, one-time. Three shapes of money, then, and knowing which is which removes most of the surprise: the chat layer is a fixed cost, the same figure every month whether the stack whispers or roars; the agents are a zero, license fees simply do not exist in this assembly; and the models are the variable, the one line you steer, coarse-grained enough that the monthly number follows the decision rather than creeping on its own. Budgets that fail here fail by not deciding the third shape up front. The count that matters is the comparison in kind, not in price: hosted chat platforms bill you nothing and keep the transcripts, and this stack bills a flat rate and keeps nothing.
The growth path
Somewhere on the path, the stack stops being personal and becomes a team system, and the spine carries that transition better than any bolted-on permission layer would: roles and membership live where the transcripts live, an agent's reach is the rooms it was added to, and revoking access is removing a bot from a channel. The growth stages are not re-architecture, they are additions, which is the quiet test of whether a first layer was chosen well.
Stacks that survive start smaller than their ambition. The path this cluster's layouts describe: one agent and one direct-message conversation, to learn the texture. Then a private channel and a mention, to learn the rhythm. Then the second agent in its own room, then scheduled digests, then per-channel prompts that turn rooms into modes. Somewhere in that sequence, the question stops being whether the stack works and becomes what else can live in it, which is the moment the architecture was for. The layouts for each stage are drawn in the three guides, and the trio workspace, all three agents on one server, is the end state they point at.
If you are reading the cluster in order, the path that works: the platform argument first, for the why; the license map second, so the free path is clear; one agent guide next, the lane you need first; the comparison when the second agent is in question; the explainers when someone asks why not just Discord or Slack; and this page whenever the pieces need assembling into one picture again. Every page links the others where the argument hands off, so any entry point eventually reaches the whole.
This page is the assembly view. The depth lives in the layer guides: the platform argument, the Hermes, OpenClaw and Pi guides, the comparison, the license map, and the privacy record in twoexplainers. A cluster is a stack you can read.
Questions people ask about the stack
What is a private AI stack?
Four layers under your control: a chat layer that holds the transcripts, agents that do the work, models that power them, and glue that automates the connections. The defining property is custody, not where inference happens.
Which layer do I build first?
The chat layer. It is the spine every agent plugs into, and choosing it well means never migrating the agents. Everything else can be re-pointed later.
Do I need to run my own models?
No. The agents treat models as pluggable providers, so API keys to hosted models keep the stack private where it counts, in the transcripts and memory, while local inference is an option when hardware and budget say so.
Which agent should I start with?
By lane: an assistant for research and operations, an always-on presence for watching and digesting, a coding bridge for repository work. The comparison guide walks the head-to-head, and starting with one is the documented path.
Does the chat layer need a license?
No. The free Team Edition build carries the APIs, unlimited bot accounts and the export path the agents use. The paid AI features are a separate lane, mapped in the license guide.
Is one server enough for several agents?
Yes, that is the natural shape: each as its own bot account, in its own rooms, with built-in loop protection keeping bot-to-bot conversations bounded.
What holds the transcripts?
Your Mattermost database holds them, on your rented server, inside your chosen region. Agent memory stays on the hardware each agent runs on, and nothing routes through a third-party chat cloud.
How do scheduled reports reach the team?
Through the agents' own mechanisms: a home channel that files cron output, and outbound delivery that addresses channels and users by name. A public digest channel fed from private work rooms is a one-line pattern.
What does MCP mean in this stack?
A tool-connection lane with a precise boundary: the chat platform's own MCP endpoint sits in the paid editions, while the agents' tool use runs on their own rails and needs no Mattermost license. The license guide draws the line exactly.
Can automation outside chat join the stack?
Yes. Webhooks and slash commands cover most integrations, and a self-hosted automation runner with a Mattermost node, n8n among them, bridges the rest of the estate.
What does the whole thing cost per month?
A flat hosting rate for the chat layer, free and open-source agents, and a model budget you set, from zero with local inference to usage-based with hosted providers. Hardware beyond the server is optional and cheap.
Can it run on modest hardware?
The chat layer is a managed service or a small server. Agent gateways are light by design; one is documented running on a computer priced in the tens of dollars, because the heavy part, the models, can live elsewhere.
Is this stack private where it counts?
Custody is the test: transcripts in your database, memory on your machines, export as a file operation. With API models, providers see requests; with local models, nothing leaves. The explainers in this cluster document what the hosted alternatives do.
What breaks first, and what then?
Transport and identity, in practice: a bot loses membership, a token expires, a proxy drops a websocket. Each guide carries a troubleshooting table, and the pattern is consistent, probe the connection before touching configuration.
Can I start with one agent and one conversation?
That is the documented starting shape: a direct message, one lane, one rhythm learned before rooms and schedules and second agents join. The growth path is drawn in the guides.
Does the stack hold anything hostage if we exit?
Yes, structurally: the chat layer exports as a database, the agents keep their configuration and memory on their own hardware, and no layer in the stack has a lock on another.
Try managed Mattermost hosting for 7 days
Sources
- DANIAN, the private chat platform for AI agents (the platform argument)
- DANIAN, the Hermes Agent deep guide
- DANIAN, the OpenClaw deep guide
- DANIAN, the Pi agent deep guide
- DANIAN, Hermes Agent versus OpenClaw
- DANIAN, Mattermost AI features on the free version (the license map)
- DANIAN, the Slack training explainer
- DANIAN, the Discord safety explainer
- DANIAN, managed Mattermost Team Edition



