phiproxy

Open Source

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.

How it works

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.

Open benchmark

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.

Read this first

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.