phiproxy
phiproxy: your patients' stand-in on the way to any LLM, and back
Open-source, reversible PHI masking for healthcare AI. Patient identifiers are replaced before a prompt leaves your network and restored when the reply comes back.
phiproxy is a proxy in two senses. It is a proxy for the patient: names, dates of birth, phone numbers and health card numbers are swapped for stand-ins such as [NAME_1], so the AI provider never sees who the conversation is about. And it is a proxy server: one checkpoint between your applications and every LLM provider, built as a guardrail for the open-source LiteLLM gateway, or used as a plain Python library.
When the reply arrives, the stand-ins are swapped back, so staff, patients and your own tools see the right person. The model can still reason about the conversation without ever knowing who it is about.
Apache-2.0 licensed. Built and maintained by Decision Tree Technology.
One round trip, no identifiers in the middle
1. What your app sends
Hi, this is Sarah Chen, DOB 1990-03-05. Call me at 416-555-0142.
2. What the LLM provider receives
Hi, this is
[NAME_1], DOB[DATE_1]. Call me at[PHONE_1].
3. What the provider replies
Thanks
[NAME_1], we will call[PHONE_1]today.
4. What your app receives
Thanks Sarah Chen, we will call 416-555-0142 today.
The token map stays inside your network, in memory or in your own Redis. Within one conversation the same person always gets the same stand-in, so multi-turn chats stay coherent and provider prompt caching keeps working.
Built for clinic traffic, not just clinical notes
Most de-identification tools target clinical notes. Clinics send LLMs something else: patient texts, chat messages, call transcripts and referral faxes. phiproxy is designed for that traffic.
Your own records, plus a local model
Pass the identifiers you already hold for the patient and phiproxy matches them in any case and with a typo. An optional model that runs on your own server finds the names, cities and workplaces no record covers. Nothing is sent out to detect PHI.
Fails closed
If masking errors, or a request carries images, audio or files that cannot be masked as text, the request is rejected and nothing is sent. Client applications cannot switch the protection off.
Clinic-specific identifiers
HIPAA Safe Harbor identifiers plus Canadian health card numbers (OHIP, RAMQ), SIN, donor and embryo IDs, phone numbers spoken word by word in call transcripts, and dates in English, French, Spanish, Polish and Hebrew.
Date shifting
Optionally move every date in a conversation by the same hidden offset. Intervals stay true, so retrieval-to-transfer timing still makes sense to the model, and the reply is shifted back.
Streaming and tool calls
Stand-ins split across streamed chunks are restored correctly. Tool call arguments are masked on the way out and restored on the way back, so your tools act on real values.
Any provider, one gateway
As a LiteLLM guardrail, one deployment covers OpenAI, Anthropic, Azure, AWS Bedrock and Google. Apps change only their base URL.
Measured on patient communications, misses included
phiproxy ships with an open benchmark of synthetic patient messages: SMS, web chat, call transcripts, emails and referral notes. Every person and number in it is invented. The main test is a blind set of 420 messages in English, French, Spanish, Polish and Hebrew, written by a separate AI author that never saw the detection code. We scored it once with the detectors frozen, then fixed what it found:
- Pattern rules plus the patient's own record: 54% of identifiers caught on the first blind score, 68% now
- Plus the optional local model: 80% on the first blind score, 92% now
- With the local model: SMS 94%, web chat 91%, email 96%, notes 94%, call transcripts 86%
Our earlier, template-based set scored 86% without the model. The blind set showed that figure was about 30 points too kind, and we publish both. The "now" numbers include fixes informed by the blind set, so a fresh blind set will re-test them. Expect real traffic to score lower again. Messages written by people who work in clinics are the next step, and contributions are welcome.
A safety layer, not a compliance shortcut
phiproxy reduces how much protected health information reaches an AI provider. It does not make an unapproved provider compliant. No detector catches every identifier, and every miss is a disclosure. Send patient data only to providers you have a BAA or equivalent agreement with (for example a PHIPA agent agreement in Ontario), and use phiproxy as an extra layer on top. Get privacy or legal review before relying on de-identification for any workload.
Putting LLMs to work on patient data?
phiproxy comes from the team behind Fertiligent.AI, our patient communication platform for fertility clinics. We help healthcare organizations design AI workflows that keep patient data where it belongs.
