Building a HIPAA Compliant AI Chatbot That Keeps Text In

What a HIPAA Compliant AI Chatbot Requires of Your Text Pipeline
The short answer: a HIPAA compliant AI chatbot is one where patient text never crosses a boundary you cannot defend. In practice, that means running moderation and guardrails inside your own network — screening the user's message before your chatbot model sees it, screening the model's reply before the user sees it, and keeping raw patient text out of third-party services, logs and analytics. The model itself can be excellent. What decides your architecture is where the text goes.
That is a harder constraint than most chatbot teams start with. A prototype usually sends everything everywhere: the message to a hosted moderation endpoint, the message plus conversation history to a model provider, the whole exchange to a logging service, and a copy into analytics. Each of those is convenient. Each of them is also a place where health information leaves your control.
This article is about turning that prototype into something a security reviewer can sign off on. It is written so that it is useful even if you never buy anything.
What HIPAA asks for, in general terms
HIPAA's general purpose is to protect health information and set expectations for the organizations that handle it. In broad terms, it creates duties such as:
- Administrative, physical and technical safeguards for the information you create and hold.
- Limits on who may receive health information, and for what purposes.
- Written agreements in place before another organization handles that information on your behalf.
That is the shape of the obligation, not a summary of it. This article is not legal advice and deliberately avoids the specifics — no deadlines, no thresholds, no penalties. Read the official text, or ask counsel who knows your organization and your jurisdiction.
Two adjacent points. First, HIPAA is rarely the only rule in play. If minors can use the chat, child-privacy duties may apply alongside it, and the reasoning is similar — see COPPA chat data and moderation duties. Second, the engineering question is the same under every regime: where does the text go, who can read it, and what is written down.
Why an outside moderation API is a design decision, not a model decision
Two teams can pick the same classifier and end up with completely different exposure, because exposure comes from where the classifier runs, not from how accurate it is. Any service that receives raw user text is another party handling that text.
So the useful question is not "which moderation model is best?" but "which text, if any, is allowed to leave?" A hosted API is a reasonable answer for text that may leave — public content, marketing copy, aggregate signals. For patient intake, symptom questions and clinic support messages, the answer is usually no. It is worth having that comparison before you commit to a tool: on-premises vs cloud content moderation.
Map Every Place Chat Text Leaves Your Network
You cannot protect a boundary you have not drawn. Before choosing tools, inventory every point where a patient's words — or a reply about a patient — crosses out of your infrastructure. This is the single most valuable hour you will spend on the project, because most leaks are accidental rather than architectural.
The hops in a typical chatbot stack
Walk one patient message through your system. It probably touches:
- Your moderation or guardrail service, if it is hosted.
- Your LLM provider, if the model is a hosted API.
- Your logging and observability stack.
- Product analytics and error tracking.
- A human review or escalation queue.
- Support tooling: transcripts, ticket exports, notification emails.
- Backups, warehouses and test fixtures copied from production.
Two things get missed constantly. First, it is not only the user's message. The chatbot's reply, the saved transcript and the support export all carry the same class of text, and a reply can contain identifiers the patient never typed. Second, the quietest hops are usually the ones nobody chose deliberately — a debug log, an exception that includes the request body, an analytics event with the message tucked into a property.
Questions to ask about each hop
For each hop, answer these in writing:
- What exactly is sent — raw text, redacted text, an identifier, or nothing at all?
- Does the receiver store it, and for how long?
- Who can read it, on their side and on yours?
- What agreement covers that handling?
- Can the hop be removed, or moved inside your network?
- What happens to the conversation if that hop is unavailable?
Repeat until every hop is either justified or gone. Where a vendor is involved, check that vendor's current documentation and your own contract rather than assuming anything about retention, storage or terms.
How to Run Moderation and Guardrails Inside Your Own Network
The general pattern is straightforward: run a classifier container inside your own network, reachable at localhost from your application process or at an internal service address from a sidecar, so the text never crosses the boundary at all. The core mechanism — input checks and output checks against a locally hosted model — is covered in more detail in local LLM guardrails.
Check input before the model sees the message
This is the first checkpoint, and it sits in front of the expensive call. The user's message is classified locally, and the chatbot model is only called when the pipeline allows it.
Why check here rather than later:
- Identifiers the patient volunteers can be caught before they are embedded in a prompt or repeated in a reply.
- Abusive, spammy or manipulative messages never reach the model, so prompt-injection attempts are stopped early.
- You save the latency and cost of a model call on messages you would not answer anyway.
A practical sequence for the input path:
- Receive the message from your web or mobile client.
- Call the local moderation service.
- If it is flagged, stop: show a safe fallback response, record the decision, and optionally queue the message for human review.
- If it is clean, send it to the chatbot model with a system prompt that scopes the assistant to its role.
Check output before the user sees the reply
The second checkpoint uses the same local service, applied to the model's reply. The output check exists because a reply can introduce problems the input did not: a hallucinated instruction, an identifier the model echoed back, self-harm content in an unhelpful form, or a phrase that reads as medical advice the product is not permitted to give.
On a flagged reply, the usual move is to replace the text with a short, fixed fallback, record the decision, and route the exchange to review. Keep the fallback boring and consistent — a single sentence that never varies — so that nobody tries to infer what went wrong from the wording.
Inline or sidecar
There is a genuine trade-off between blocking inline and running checks alongside the request.
- Inline blocking completes the check before the next step: input check, then model; model reply, then output check, then send. It is the easiest design to explain to a reviewer and the easiest to reason about under pressure. It adds latency, though a local call over the loopback interface is small compared to a model call.
- Sidecar or asynchronous checks run alongside the request and reduce the delay the user feels, but they mean you may already have shown a reply you would rather have withheld. They work best as a second layer behind an inline input check, not as a replacement for it.
For regulated chat, a common split is: block inline on the input, act inline on the output for the categories you care about most, and let everything else inform review rather than the live conversation. The trade-offs are covered in more depth in LLM guardrails best practices.
One design note that pays off later: boolean flags make the branch deterministic. A flag becomes a decision — block, replace, review — with no numeric cutoff for someone to choose, defend and re-validate every time the model changes.
Redact before you store
Assume that anything you log will one day be read by someone who should not see it. Store the decision, not the conversation:
- A request identifier and a timestamp.
- Which categories were flagged, and whether the text was allowed through.
- The action taken, and who or what took it.
- A reference to the conversation if it must remain retrievable, rather than the text itself.
Raw text should live only as long as the conversation needs it, under restricted access, with a defined retention period. Where you genuinely need text in logs, strip identifiers first — the patterns for that are in redact PII in Python.
Finally, keep a restricted human review path. Reviews are where the most sensitive text is read by the most people, so treat that queue as a system in its own right: named reviewers, audited access, time-limited holds, and a rule that held text is visible to as few people as possible. And test all of it with synthetic messages rather than real patient text, in staging and in CI fixtures alike.
What to Check in a Self-Hostable Moderation Model
Once you have decided moderation belongs inside the network, the selection criteria change. These are the questions that separate a model you can defend from one you cannot:
- Offline behaviour. Does the container make outbound requests, and does it emit telemetry? Ask for a documented statement and verify it by running the image with network access restricted to what it actually needs.
- License terms. What does the license say about redistributing the software and its keys, and does the software contact anything to validate a license?
- Packaging and distribution. Is it delivered as a container image, how is the registry authenticated, and can you move an image into a disconnected environment yourself?
- Air-gapped path. Is an offline install documented, or only implied? If you operate in a restricted environment, an undocumented path is not a path.
- Hardware. CPU or GPU, memory footprint, whether an accelerator must stay resident, and how that fits the capacity you already run.
- Output shape. Boolean flags map directly to branches: flag, act, log. Scores push threshold selection, calibration and re-validation onto your team, and those thresholds drift when the model or the prompt changes.
- Category coverage and definitions. Read the vendor's own descriptions of each category and check they match the harms you actually care about. Do not assume what a label means from its name.
- Upgrade path. How new versions arrive, whether you can pin a version, and what changes in the output when you upgrade.
- Operability. Health checks, restart behaviour, and what the container writes to its own logs about the text it sees.
Packaging, licensing and hardware requirements change between releases, so check each vendor's current documentation rather than relying on a blog post or a benchmark thread.
How CautionLabs Runs on Your Own Servers
CautionLabs is built for exactly this pattern. The model runs on the customer's own infrastructure, so patient text stays where your network boundary puts it. The first model is Argus 1, with the model id argus_1.
On-premises is a one-time payment of $299 USD per model, with unlimited installs and requests, and upgrades to that model included. The model files and keys are covered by the on-premises software license; the software and its API keys may not be distributed.
From purchase to a local endpoint
There are four steps:
- Buy a model — the first is Argus 1.
- Create a private key in the dashboard.
- Log in to the CautionLabs registry with that key as the password (
docker login registery.cautionlabs.com), then run the image. The registry checks the license on every download. - Call
POST /moderatewith{"text": "..."}on your own network — by default athttp://localhost:8000.
The exact install commands, registry details and error handling live in deploy the on-premises model with Docker and in the On-Premises Guide — start there rather than improvising. The same guide documents air-gapped installs, and deployment on RunPod-style GPU clouds using the private key as the registry password.
The model container makes no outbound requests and has no telemetry, which is what makes an air-gapped install more than a marketing claim. A private on-premises key does not work with the hosted cloud API.
What the response looks like
Calling the local endpoint is a single POST with the text:
import requests
result = requests.post(
"http://localhost:8000/moderate",
json={"text": "patient message goes here"},
).json()The response contains twelve boolean categories plus an overall flagged boolean that is true when any category is flagged. An illustrative shape:
{
"categories": {
"toxic": false,
"profanity": false,
"hate": false,
"harassment": false,
"self_harm": false,
"adult": false,
"violence": false,
"drugs": false,
"weapons": false,
"pii": true,
"spam": false,
"minor": false
},
"flagged": true
}There are no scores, probabilities or confidence values, and no thresholds to tune — the branch is the same every time. Each started 3,000-character piece of a text counts as one request, so a long intake note is processed in pieces. If some text in your product is allowed to leave your infrastructure, the hosted API is documented at cautionlabs.com/docs with its own request and response schema.
Questions Teams Ask About HIPAA Chatbot Moderation
Does moderation have to run on premises to be HIPAA compliant? HIPAA does not name moderation vendors. The question your reviewers will ask is whether you can defend every place the text goes, and keeping moderation inside your network removes one entire class of question. Whether that is required for your product is a decision for counsel, not a blog post.
Can we still use a hosted service anywhere? Yes, if the text is allowed to leave. Public FAQ content, aggregate signals and non-identifying material are different from patient intake. For everything else, apply the same inventory method and check that vendor's current documentation and your own agreements.
Do we need scores or confidence values? Not necessarily. Boolean flags are simpler to act on and leave no cutoff for your team to pick, calibrate and re-validate. Scores push that work onto you, and the right cutoff changes when the model or the prompt changes.
What should we log? Decisions: a request identifier, a timestamp, which categories were flagged, and the action taken. Not raw patient text, and not the model's replies.
What about the assistant's replies? They carry the same class of text. A reply can contain identifiers the patient never typed, so screen the output path as carefully as the input path.
How do we test without real patient data? Synthetic messages that exercise every category and every edge case you can think of, run in staging and in CI. Keep production text out of test fixtures entirely.
A Rollout Checklist for Regulated Chat Features
Before launch, make sure you can answer all of these:
- Which checkpoints exist — input, output or both — and in what order do they run?
- What happens on each flag, decided in advance and deterministic?
- Who can read held text, for how long, and under what audit trail?
- Is the data flow written down, hop by hop, including logs, analytics and review queues?
- Is there a re-test plan for changes to the model, the prompt, the redaction rules or the logging layer?
- Has counsel reviewed the flow and the agreements?
The architecture will not survive on its own. It survives because someone wrote it down and someone keeps the log line from reappearing.
Run Argus 1 inside your own network: follow the On-Premises Guide to buy a model, create a private key, pull the image and call POST /moderate on localhost — then keep the hosted API for any text that is allowed to leave your infrastructure.