Abdul MoizFractional CTO · Senior EngineerBook a free call

AI systems

Designing an Air-Gapped RAG Architecture for Healthcare

A hospital wants a GPT-4-class assistant, but clinical data can never leave infrastructure it controls. That single constraint disqualifies every hosted API and forces a specific architecture. Here is that architecture, box by box, and the decisions it puts in front of you.

Updated · 10 min read

Fractional CTO · Senior Engineer

Key takeaways

  • An air-gapped RAG system runs the embedding model, the LLM and the vector database on hardware the hospital controls, so no request leaves the network.
  • Access rules belong inside the search itself. Once a passage reaches the model, filtering is too late.
  • Most hospitals that ask for “air-gapped” mean a network with no internet route, not a physically separate one.

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.

Two meanings of air-gapped
Network isolatedPhysically air-gapped
Internet accessNoneNone
Link to hospital networkYes, through a firewallNone
How doctors use itTheir normal laptopsDedicated terminals
UpdatesControlled internal transferCarried 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:

  1. Hospital data
  2. 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.

  1. Doctors
  2. Hospital LAN
  3. AI datacenter
  4. no route outInternet

Definition 2: a true physical air gap. No connection to the general hospital network at all.

  1. Normal hospital network
  2. 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
                  • Generation
                    • Local LLM
                      • Answer + citations

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.

  1. “When should warfarin be stopped before surgery?”
  2. Embedding modelBGE, E5 or similar
  3. 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.

  1. Question + the passages that were found
  2. Local LLMQwen 72B, or whichever wins your testing
  3. 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:

  1. Top 30 results from the first search
  2. Reranker
  3. 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.

  1. Hospital documentPDF, scan, policy doc
  2. Text extraction / OCR
  3. Split into passages
  4. Embedding model
  5. Vector database

This runs in the background. A few minutes per document is fine.

Retrieval: every time someone asks a question.

  1. Doctor's question
  2. Embedding model
  3. Search for similar passages
  4. Best passages
  5. Local LLM
  6. 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:

  1. Authenticationwho is this?
  2. Authorizationwhat may they see?
  3. Retrievalsearch only within that

Never:

  1. Retrieval
  2. “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

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:

  1. Upload
  2. Queue
  3. Worker
  4. OCR
  5. Split
  6. Embed
  7. 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.

  1. GPU servers
  2. Inference serversuch as vLLM
  3. Model loaded from internal storage
  4. 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:

  1. Connected build environment
  2. Download software or model update
  3. Verify signature and checksum
  4. Malware and vulnerability scanning
  5. Approval / change control
  6. Transfer into the hospital's internal store
  7. 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?"

  1. 1The doctor opens the assistant on the hospital network
  2. 2The firewall confirms the request comes from an allowed part of the network
  3. 3A load balancer passes it to an available server
  4. 4The gateway checks the doctor is signed in
  5. 5The system looks up the doctor's permissions: Cardiology, clearance level 2
  6. 6The question is turned into a meaning-number list, on hospital hardware
  7. 7Only Cardiology documents up to clearance 2 are searched
  8. 8The 30 closest passages are found
  9. 9A reranker picks the best 5
  10. 10The question and those 5 passages go to the local language model
  11. 11The answer is written, with links to the source documents
  12. 12An audit record notes who asked, what was used and when
  13. 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:

Before any of it reaches a clinician, run the five questions to ask before trusting an AI system.

Common questions

Can you run an LLM without the internet?

Yes. Open-weight models such as Llama, Qwen and Mistral can run on your own GPU servers with an inference server such as vLLM. The embedding model has to run locally too, or every question still leaves the building.

Is an air-gapped LLM automatically HIPAA compliant?

No. Keeping data inside removes one risk. HIPAA also covers things such as access control, audit logs, integrity and policies. Treat the architecture as one part of compliance, and involve your compliance team.

Why must access control happen before retrieval?

Once a passage is in the model context, its content can appear in the answer. Filtering afterwards is too late. The search itself must only return passages the user may read.

How do you update models in an air-gapped environment?

Download them on a connected machine, verify signatures and checksums, scan them, get approval, then transfer them to an internal registry that production reads from.

Sources and further reading

Abdul MoizFractional CTOSenior Engineer

About the author

I build production-grade AI applications, AI agents and data systems, fix AI-built apps, and help teams as a fractional CTO. I've spent seven years building software people rely on, including a media platform that grew to 2M+ users.

ShareXLinkedIn

Keep reading

Working on something like this?

Tell me about it on a free 30-minute call.