PIIGhost¶
piighost is a Python library that protects your personal data (PII) in conversations with LLMs through de-identification. Sensitive values are hidden before they are sent, then restored in the response. LangChain, Pydantic AI, LlamaIndex and Claude Code integrations are provided, together with an OpenAI and Anthropic API connector.
This de-identification spots PII with pluggable detectors (regex, NER, LLM) and replaces each value with a placeholder, the token that takes its place. For example:
John Doebecomes<<PERSON:1>>john.doe@example.combecomes<<EMAIL:1>>
This placeholder stays the same from one message to the next with the conversational pipeline, which keeps the mapping between a value and its placeholder across the whole conversation. If john.doe@example.com reappears three messages later, the placeholder is still <<EMAIL:1>>, which lets the LLM follow the thread.
The LLM therefore only receives de-identified text. When it returns placeholders, for example by answering "Hello <<PERSON:1>>", piighost replaces them with the real values. The user sees John Doe and never sees the de-identification.
The same mechanism protects agents that call tools. With the LangChain middleware, a tool that needs the real email address receives it in clear, while the LLM that supplies it only writes <<EMAIL:1>>.
Full round trip of an agent request. The user and the tool see the real values, the LLM sees only placeholders.
Reversible de-identification
This retained mapping makes the de-identification a pseudonymization under the GDPR, not a definitive anonymization. With the conversational pipeline, the real values stay stored for the duration of the conversation and must be protected accordingly.
Why de-identify?¶
A cloud LLM (GPT, Claude, Gemini) receives every piece of information you send it, including your users' PII. De-identifying upstream decouples the choice of LLM from the sensitivity of the content. When PII never reach the LLM, the provider stops being a confidentiality decision and goes back to being a question of quality, cost, and latency.
To go further:
- Why de-identify?, the provider spectrum, the legal detail (CLOUD Act, FISA 702, Schrems II) and the use cases
- How PIIGhost compares, the alternatives and their trade-offs
Where to start¶
-
Get started
Install and take
piighostin hand. -
Recipes
Solve a specific task.
-
Reference
The full API documentation.
-
Concepts
Understand the design choices.