Install
Install with PiG
pig install npm:phi-routerInstall with Pi
pi install npm:phi-routerPackages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.
Pi manifest JSON
The pi field of package.json.
{
"extensions": [
"./plugins/pi/extension.mjs"
]
}README
Written by the package's publisher, shown as published in version 0.6.2 (README.md). PiG does not review it.
phi-router
Run Claude Code, Codex or pi on your flat-rate subscription when your work touches patient data. Only your BAA account reads PHI. HIPAA-aligned.
![Claude Code reads a synthetic patients.csv. The open account gets [sealed h1], the phi-sealed subagent does the work on the BAA account, and Claude Code answers that 2 of 4 patients are overdue.](https://raw.githubusercontent.com/drsh4dow/phi-router/HEAD/docs/demo.gif)
The real Claude Code and router against mock accounts. Model replies are scripted, and the patients are synthetic. The bottom pane shows what each account received.
How it works

- Your agent runs on your subscription. phi-router reads each new message before it goes out.
- Rules catch identifiers such as SSNs. A judge on your BAA account decides the rest.
- A message with PHI reaches your subscription as a handle, such as
[sealed h3]. - When the task needs that PHI, your agent hands a scoped task to the
phi-sealedsubagent on your BAA account. phi-router checks the subagent's answer and sends it back to rewrite, up to five times, until it holds no PHI. Identifiers you need go to a private file on your machine. - If the router is down, requests fail.
Get started
You need:
- Claude Code, Codex or pi, logged in to your subscription.
- An OpenAI API key under your BAA, for the judge.
- For Claude Code or pi, an Anthropic API key or a Claude Enterprise login under your BAA.
Paste this into your coding agent:
Install phi-router for your harness by following its SETUP.md in https://github.com/drsh4dow/phi-router/blob/main/SETUP.md
Or run it yourself, with codex or pi in place of claude:
npx phi-router setup claude
Setup finds the keys you already have and asks only for the rest. Claude Code and Codex take updates by themselves, and pi tells you when one is out. More in SETUP.md and Accounts.
Proof
bun run eval:recorded replays a synthetic corpus through the router with the judge's recorded answers. It calls no API.
| Check | Result |
|---|---|
| PHI cases leaked to an open account | 0 of 282 |
| Clean cases sealed anyway | 41 of 352 |
| Judge cost for 3,031 calls | $0.6132 |
The corpus covers 12 identifier kinds, such as names, SSNs and MRNs, in 12 formats, such as FHIR, HL7v2, SQL dumps and screenshots. Zero leaks in a sample is not a zero leak rate. For the 74 plain-text cases, the 95% upper bound is 0.0397. bun run check replays it on every pull request and fails on any leak.
What it saves
bun run cost . drives the real Claude Code through a scripted claims session against mock accounts. Your subscription took 8 of 9 requests. The BAA account took 1.
| Estimate, input tokens at list price | Everything on the BAA account | With phi-router |
|---|---|---|
| Per session | $0.44 | $0.04 |
| Per 1,000 sessions | $444 | $41 |
Prices were read on 2026-11-26: Claude Opus 5.5 at $4 and the Decisions judge at $0.10 per million input tokens. The estimate leaves out output tokens, caching and your subscription fee.
Compared to the alternatives
| (blank) | Everything on a BAA API key | Claude Enterprise with HIPAA | A redaction tool such as Presidio | phi-router |
|---|---|---|---|---|
| Everyday requests run on | The BAA account, per token | The Enterprise account | Your current account | Your subscription |
| The agent can work with PHI | Yes | Yes | No, only redacted text | Yes, through the subagent |
| When the check can't run | No check | No check | Up to your code | The part stays sealed |
What HIPAA-aligned means
phi-router keeps PHI on the accounts your BAA covers. It is not a certification.
phi-router does this:
- PHI that the rules or the judge find reaches only your BAA accounts.
- A part it cannot check stays sealed.
- Sealed content stays in a 0600 file on your machine.
You keep this:
- The BAA with each vendor whose account reads PHI.
- The policy. phi-router's definition of PHI is a routing rule, so check it against yours.
- Your compliance program and the machine phi-router runs on.
FAQ
What counts as PHI? A complete direct identifier of a real patient or member, of 12 kinds: name, SSN, full date of birth, home address, personal phone, personal email, member number, Medicare or Medicaid number, MRN, driver license, passport, and face photo. Internal ids, staff contacts, fragments and counts are not.
What does the judge see? Each new part no rule sealed, alone, without the conversation (ADR 0013). It runs on OpenAI's Decisions API under your BAA. If it fails to answer, the part stays sealed.
What does the router not cover? Before each prompt, your harness checks that the router on its port is yours. A request sent before the first prompt, or after a crash in the middle of a turn, skips that check, so another user on the same machine could read it (ADR 0002).
Does it work with Codex and pi? Claude Code and pi-harness run the whole flow. Codex runs the subagent without the answer check. Stock pi has no subagents, so use phi/sealed for PHI work. See SETUP.md.
What if my subscription hits a rate limit? List several subscriptions and phi-router moves to the next one. When all are limited, the request runs on the BAA account, with handles still in place of PHI. In Claude Code and pi, the status line under the prompt marks the overflow, with the time the router tries your subscription again when it has one, and /phi shows the session's accounts and counts. phi-router adds no notice to their conversation. Codex has no status line, so it says so once at the end of the turn.
Security
Report a vulnerability or a suspected leak privately, as SECURITY.md says. Never put real PHI in an issue. To contribute, see CONTRIBUTING.md.
This software comes with no warranty. The author takes no responsibility for how you use it, including with policies other than the one it ships.