piighost

piighost

The core library. Build PII anonymization pipelines for AI agents.

What it does

piighost is the core library. It sits between your agent and the model. It detects PII, replaces it with stable placeholders the model can reason about, and restores the real values for your tools and your end users. The same value keeps the same placeholder across a whole conversation, even across multiple messages and tool calls.

It is detector-agnostic: you wire in regex, a NER model, an LLM, or several at once. piighost handles detection arbitration, a tolerant linker for typos and case variants, and output guardrails for when the model generates fresh PII in its reply.

Install

uv add 'piighost[cache]'

Use it as LangChain middleware

from langchain.agents import create_agent

from piighost import Anonymizer, ExactMatchDetector
from piighost.pipeline import ThreadAnonymizationPipeline
from piighost.middleware import PIIAnonymizationMiddleware

# Wire any detector you like: regex, a NER model, or an LLM.
detector = ExactMatchDetector([("Patrick", "PERSON")])
pipeline = ThreadAnonymizationPipeline(detector=detector, anonymizer=Anonymizer())
middleware = PIIAnonymizationMiddleware(pipeline=pipeline)

agent = create_agent(
    model="openai:gpt-5.5",
    tools=[send_email],
    middleware=[middleware],
)

Where it fits

The library embeds in your Python process. When you need one shared inference endpoint across several processes, reach for piighost-api. To see it end to end, look at the chat demo and the proofreader.