If you lead IT, data or innovation at a hospital, you have probably been asked some version of this: "Can we have ChatGPT for our own policies and protocols, without patient data ever leaving the building?"
Yes. But it is a different project from plugging in an AI service, and the difference decides your budget, your timeline and who needs to be involved. This article walks through what has to be built and the decisions you will face along the way, in plain terms.
If you want the networking background underneath it, see From a Home Router to a Hospital Network.
| Network isolated | Physically air-gapped | |
|---|---|---|
| Internet access | None | None |
| Link to hospital network | Yes, through a firewall | None |
| How doctors use it | Their normal laptops | Dedicated terminals |
| Updates | Controlled internal transfer | Carried in and checked |
The requirement: clinical data never leaves the hospital
A hospital wants an internal assistant. Doctors ask questions in plain language about clinical policy, drug interactions and internal protocols, and get answers drawn from the hospital's own documents, with a link to the source.
One constraint: patient and clinical data must never leave infrastructure the hospital controls.
That sentence rules out almost every quick way of building it.
Why a hosted LLM API is ruled out
- ✕OpenAI GPT-4 API
- ✕Claude API
- ✕Gemini API
- ✕Groq API
Not because these services are insecure, but because using them means:
- Hospital data
- External inference provider
The moment a doctor's question, often with patient details in it, crosses the hospital's firewall to a third party, the requirement is broken. A zero-retention agreement changes the legal position, not where the data went.
So the AI has to run on hardware the hospital owns: an open-weight model from families such as Qwen, Llama or Mistral, chosen by testing it on the hospital's own questions and checking its license. Choosing the model is a small project of its own.
It is worth saying in the first meeting, not three weeks in: GPT-4 itself cannot be installed on hospital servers. Its weights are not available to buy or download.
What "air-gapped" means for an LLM
The word covers two very different setups, and the cost difference between them is large.
Definition 1: an AI network with no internet access. The AI system sits on the hospital network, staff can reach it from their normal computers, but it has no route to the internet.
- Doctors
- Hospital LAN
- AI datacenter
- no route outInternet
Definition 2: a true physical air gap. No connection to the general hospital network at all.
- Normal hospital network
- no physical linkDedicated AI network
The second exists, in defense and some critical infrastructure, but doctors then cannot use the system from their normal laptops. They need dedicated terminals on the isolated network. That is a different product, not the same one with a stricter rule.
Nearly every hospital asking for "air-gapped AI" means the first. Confirm it anyway, in writing: access, updates, layout and cost all depend on the answer. This article assumes Definition 1.
Air-gapped RAG architecture, end to end
- Doctor
- Internal DNS
- Segmentation firewall
- Internal load balancer
- API gateway
- Frontend + IAM
- Backend
- RAG orchestration
- Retrieval
- Embedding model
- Vector database
- Relevant context
- Vector database
- Embedding model
- Generation
- Local LLM
- Answer + citations
- Local LLM
- Retrieval
- RAG orchestration
- Backend
- Frontend + IAM
- API gateway
- Internal load balancer
- Segmentation firewall
- Internal DNS
Every box runs on hospital hardware, inside a part of the network that has no way out to the internet. The sections below explain what each part does and why it is there.
Why RAG needs two models
RAG (retrieval-augmented generation) is not "the AI searches the documents." The AI that writes answers never searches anything. Two different models do two different jobs.
Model 1: the embedding model. It turns text into a list of numbers that captures its meaning, so questions and passages about the same thing end up close together. That is how the system finds the right paragraphs.
- “When should warfarin be stopped before surgery?”
- Embedding modelBGE, E5 or similar
- A list of numbers that captures the meaning
Model 2: the language model. It reads the question plus the passages that were found, and writes the answer.
- Question + the passages that were found
- Local LLMQwen 72B, or whichever wins your testing
- Answer, based on those passages, with citations
Optionally, a third model: a reranker. The first search is fast but rough. A reranker is slower but more accurate, so it is used on a short list:
- Top 30 results from the first search
- Reranker
- Best 5 passages
The sentence that makes this stick:
The embedding model finds information. The language model explains it.
Both must run inside the hospital. A system that hosts the language model locally but sends questions to an outside search service has not solved the problem. Every question still leaves the building, through a different door.
Ingestion and retrieval are two separate pipelines
They run at different times and have different speed needs.
Ingestion: when documents are added or changed.
- Hospital documentPDF, scan, policy doc
- Text extraction / OCR
- Split into passages
- Embedding model
- Vector database
This runs in the background. A few minutes per document is fine.
Retrieval: every time someone asks a question.
- Doctor's question
- Embedding model
- Search for similar passages
- Best passages
- Local LLM
- Answer
This has a doctor waiting, so it has to be fast.
The embedding model appears in both, and it must be exactly the same model and version in both. Changing it later means reprocessing every document, which is worth knowing before you choose.
RAG access control belongs inside retrieval
This is the most important design decision in the system, and the easiest to get wrong.
A simple search finds the passages most similar to the question, with no idea who is asking. The best match might come from a document this doctor has no right to read: another department's records, HR material, a restricted protocol.
Once that passage reaches the language model, the damage is done. Hiding it from the answer afterwards does not help, because the answer has already been written using information the doctor was not allowed to see.
So permissions have to be part of the search itself. The system only searches documents this person is allowed to read:
- Authenticationwho is this?
- Authorizationwhat may they see?
- Retrievalsearch only within that
Never:
- Retrieval
- “Hope the user was allowed to see that”
Two practical consequences. Every document needs its access rules (department, sensitivity) recorded when it is added, because the system cannot filter on information it never stored. And the search technology has to handle these filters properly, or it can quietly return fewer results than it should. (How filtering works in pgvector, and the fix.)
Every box, briefly
Internal DNS. Gives the assistant a name staff can open, such as hospital-ai, that only works inside the hospital network.
Segmentation firewall. Decides which parts of the network may talk to each other:
- ✓Doctors → AI application (HTTPS)
- ✕Doctors → vector database
- ✕Doctors → GPU inference nodes
- ✕AI zone → Internet
The AI servers are physically connected to the hospital network. Their isolation is a firewall rule, not a missing cable, which is why that rule needs regular review.
Internal load balancer. Spreads requests across several copies of the application, so one failing server does not take the assistant down.
- Request
- Load balancer
- Backend 1
- Backend 2
- Backend 3
- Load balancer
API gateway. One place to check who is calling, limit how often, and apply security rules, instead of repeating them in every part of the system.
Identity and access (IAM). Knows each user's department, role and clearance. The search uses this to decide which documents to look in.
Cache. Remembers recent results to keep things fast. It must be set up so one doctor never sees results meant for another.
Message queue. Lines up new documents for processing in the background:
- Upload
- Queue
- Worker
- OCR
- Split
- Embed
- Vector DB
Model storage. An internal copy of every AI model the system uses, so nothing is downloaded from the internet at startup.
Vector database. Stores the passages, their meaning-numbers and their access rules. The specific product matters far less than how the access rules are designed.
Audit log. Who asked what, which documents were used, what was answered, and when. In healthcare this is a compliance requirement (45 CFR 164.312 asks for audit controls). It should be write-once and outside the reach of the application that writes to it.
How a self-hosted LLM runs in production
A large language model does not run inside the application itself. It runs on dedicated GPU servers, managed by an inference server such as vLLM, which shares the GPUs efficiently across many users at once.
- GPU servers
- Inference serversuch as vLLM
- Model loaded from internal storage
- Private AI service inside the hospital
A useful side effect: the private AI service usually works the same way as OpenAI's does. The application talks to it as it would talk to a commercial service, except the address points to the hospital's own datacenter. That keeps the application simple, and makes it cheaper to switch to a better model later.
So the "air gap" does not live in the application. It lives in the network: in the names, the firewall rules, and the fact that there is no route out.
Getting updates into an isolated environment
The AI servers cannot reach the internet, so they cannot download software updates, security patches or new models themselves. Updates arrive through a controlled path instead:
- Connected build environment
- Download software or model update
- Verify signature and checksum
- Malware and vulnerability scanning
- Approval / change control
- Transfer into the hospital's internal store
- Production installs from the internal store only
Teams underestimate this part. It is not a one-time setup but a permanent process, with an owner, a response time and an approval step. Agree how an urgent security patch will be applied before launch. A system that cannot be patched quickly is not more secure than a connected one, just insecure in a different way.
One complete request
A doctor asks: "What is our anticoagulation policy before surgery?"
- 1The doctor opens the assistant on the hospital network
- 2The firewall confirms the request comes from an allowed part of the network
- 3A load balancer passes it to an available server
- 4The gateway checks the doctor is signed in
- 5The system looks up the doctor's permissions: Cardiology, clearance level 2
- 6The question is turned into a meaning-number list, on hospital hardware
- 7Only Cardiology documents up to clearance 2 are searched
- 8The 30 closest passages are found
- 9A reranker picks the best 5
- 10The question and those 5 passages go to the local language model
- 11The answer is written, with links to the source documents
- 12An audit record notes who asked, what was used and when
- 13The answer appears for the doctor
Now count what happened outside the hospital:
- ✕Requests to OpenAI0
- ✕Requests to Anthropic0
- ✕Requests to Google AI0
- ✕Lookups on the public internet0
- ✕Records in outside cloud logs0
Every step ran on hardware the hospital owns, behind a firewall with no way out. That is what the requirement asked for. It just cannot be achieved by calling an AI service.
Questions to settle before you build
These are the decisions that change cost and timeline the most. Get written answers early.
- Which kind of air gap? No internet access, or a fully separate network? The second needs dedicated terminals and costs far more.
- Which model? Chosen by testing on your own questions and checking its license, not by reputation.
- Who may see what? Access rules for each type of document, recorded when documents are added.
- Who owns updates? A named owner and an agreed response time for urgent security patches.
- Where do audit logs live, and who can read them? Agree this with compliance before launch.
- What is your GPU budget? Larger models answer better but need more and costlier hardware. Test whether a smaller one is good enough.
- Does anyone need calculations or complete lists? Those need more than RAG (see below).
Where to go next
This design answers questions over documents. Two things it does not do by itself:
- Calculate. Doses, totals and dates need code, because RAG does not do math.
- Give complete lists. "Every protocol that mentions warfarin" needs structured extraction, not similarity search.
Before any of it reaches a clinician, run the five questions to ask before trusting an AI system.