Back to research
$cd /research/piihush|2026

piihush

Fast PII and secret masking for AI applications. A Rust extension for Python that removes sensitive data from your text before it reaches an external model provider.

26 µs
per 1 KiB chunk
10×
faster than Python re
15
built-in entity types
0
runtime dependencies

The problem

─

AI applications pass a lot of data to external providers: documents, user messages, tool results and logs. That data often holds email addresses, card numbers and API keys. piihush masks them first, and it's fast enough to run on every chunk, without adding noticeable latency to a pipeline.

Quick start

─
pip install "piihush[llm]"

from piihush.llm import PrivateChat

chat = PrivateChat("openai", model="gpt-4.1-mini")
reply = chat.send("Write a reminder to email jane@example.com")

# The provider receives: Write a reminder to email [EMAIL_1]
# You receive: a reply containing jane@example.com

What it does

─

Masking

Detects emails, phones, cards, IBANs, API keys, JWTs, private keys, passwords and more. Linear-time matching means crafted input can't trigger catastrophic backtracking.

PrivacyGuard

Swaps values for tokens such as [EMAIL_1], so a model works without seeing them, then restores the real values in its reply.

PrivateChat

Wraps a chat with OpenAI, Claude, Gemini, DeepSeek, Grok, Ollama, llama.cpp or any OpenAI-compatible service. The provider only sees tokens.

Name detection

An optional BERT model finds names and places in free text, and runs on your own machine after one model download.

LLM detection

An optional LLM can flag extra values, with the rules always running alongside it. It can only add masking, never remove it.

Built for pipelines

Releases the GIL, runs batches across all CPU cores, and works with threads, fork() and pickling.

Where to use it

─
#RAG pipelines#AI agents#Chatbots and support assistants#LLM observability#Application logs#Training data#Data pipelines and analytics#Document processing

Accuracy

─

Measured on 3,000 English records of the independent ai4privacy pii-masking-400k dataset, kept apart from the data used to build the rules.

ToolPII maskedOrdinary words keptTime per record
piihush NerMasker69.7%96.6%About 160 ms
Presidio64.8%94.8%15 ms
piihush Masker48.6%98.2%About 20 µs
scrubadub13.8%98.3%1.2 ms
pyveil13.1%100%0.3 ms
pii-veil10.7%100%0.2 ms

No PII tool catches everything, so piihush works best as one layer of a privacy strategy, alongside access controls and review for highly sensitive data.

$ pip install piihush
Read the full guide

Clients & Partners

─18+ companies
Agro Farm
Alpha Chemical
Bloom Corp
Bloom Loan
Carson Mountains
Eternal Eye
Glass Factory
Risings Education
Safirify
Nexook
Nutribest
XP3 Data
Agro Farm
Alpha Chemical
Bloom Corp
Bloom Loan
Carson Mountains
Eternal Eye
Glass Factory
Risings Education
Safirify
Nexook
Nutribest
XP3 Data
● trusted by industry leaders