PII Anonymization
Opt-in identifier pseudonymization for outbound prompts - what it protects, what it does not
PII Anonymization
VoidLLM can replace personal identifiers in outbound prompts with deterministic pseudonyms before the request reaches an external provider, and restore the original values in the response. The provider never sees the real identifier; your client sees its own data unchanged.
This is opt-in and off by default (settings.pii.enabled).
Status: early / beta. The feature is new and still evolving. Detection today is regular expressions plus curated word lists - there is no NER model, so coverage is finite and names are only found if they are in a list. The zero-knowledge and fail-closed properties described here are implemented and tested, including against live provider endpoints, but the feature has limited production mileage. Treat it as a strong reduction of re-identification risk, not as a completed privacy guarantee, and validate it against your own data before relying on it.
Read the limits section before enabling this. Identifier pseudonymization is frequently misunderstood, and the wrong mental model creates false confidence.
How it works
client VoidLLM provider
| | |
|-- "Call Tina about --->| |
| the invoice" |-- "Call PII_NM_4f2c9a... ->|
| | about the invoice" |
| | |
| |<-- "I called PII_NM_4f2c9a..."
|<-- "I called Tina" <----| |
- The request body is scanned in memory for known identifier patterns.
- Each match is replaced with a pseudonym:
PII_<2-char type>_<24 hex>(31 characters). - The anonymized body goes upstream. The mapping exists only in RAM, for the lifetime of the request.
- Pseudonyms in the response - including streamed content and tool-call arguments - are replaced with the original values before the response reaches the client.
Pseudonyms are derived as HMAC-SHA256(secret, orgID || type || normalized value). They are stable: the same value always yields the same pseudonym within an organization, so multi-turn conversations stay coherent without storing any mapping.
Nothing is persisted. No prompt content, no PII, and no pseudonyms are ever written to the database, logs, or traces.
What it does not protect
This is an identifier firewall, not a confidentiality firewall. It removes the link between a statement and a named person. It does not make the statement itself private.
Consider:
“Tina has been diagnosed with hepatitis.”
The provider receives:
“PII_NM_4f2c9a1be07d35ac8b61e02d has been diagnosed with hepatitis.”
The provider still learns that someone has that diagnosis - health data, a special category under GDPR Article 9. It only fails to learn who. In most sensitive sentences the name is the least sensitive part.
Three further limits worth internalizing:
- You are not anonymous. The API key, account, organization, and billing identity are known to the provider. Only identifiers of third parties mentioned in the text are masked.
- Stable pseudonyms allow pseudonymous profiling. Determinism is required for multi-turn coherence, but it also means a provider can accumulate everything ever said about
PII_NM_cb0aaf...across requests - a dossier without a name attached. - Coverage is finite. Only what the detectors recognize is masked. Everything else passes through in clear text.
If you need the statement withheld, pseudonymization is the wrong tool. Do not send the prompt to an external provider at all - route it to a self-hosted model instead.
What is detected
Structured identifiers (regex, always on when PII is enabled):
| Type | Code | Notes |
|---|---|---|
EM | ||
| IBAN | IB | German format (DE + 20 digits) |
| Phone | PH | German formats |
| Credit card | CC | 13-19 digits |
| Tax ID | TX | German 11-digit |
Unstructured terms (gazetteer, separately opt-in): names, places, company forms, and any term list you supply. Matching is whole-token and case-insensitive.
Names are only detected if they appear in a loaded list. A name that is not in any list - an uncommon given name, a surname, a nickname - is sent in clear text. There is no NER model; transformer-based detection is planned.
Not detected, by design: free-form facts, diagnoses, addresses, dates of birth, non-German identifier formats, and anything else without a pattern or list entry.
Field coverage
Detection runs at the JSON field level, not on the raw request body. Chat, completion, embedding, rerank, and score requests are all supported: messages[].content, messages[].name, tool-call and function-call arguments, tools[].function.description and its parameters schema, and the top-level user, stop, prompt, input, logit_bias, and tool_choice fields each get shape-validated scanning. The legacy pre-tools fields functions and function_call get the same treatment as their tools/tool_choice equivalents.
Function and tool names are validated identifiers, not free text - they are never pseudonymized. tools[].function.name, tool_choice.function.name, messages[].tool_calls[].function.name, messages[].function_call.name, and the legacy functions[].name / top-level function_call.name must all match the same charset the provider adapters already enforce on tool/function identifiers (letters, digits, underscore, period, plus, hyphen; 1-128 characters) and are additionally run through the PII detectors. A name that fails the charset check, or one that matches it but still looks like PII (an email address, a card number, a phone number), is rejected fail-closed rather than rewritten - a declared name and the name a later tool_choice or tool call selects it by must stay byte-identical. This means a name containing a digit sequence that looks like a phone number, a German tax ID, or a card number - e.g. tool_0301234567 - is rejected by design, even though it reads as an innocuous identifier to a human. Callers that hit this should pick a name without an embedded long digit run. A JSON null name is left as-is rather than validated or rejected: it carries no text for the charset check or the detectors to act on, and was never scanned before this policy existed.
Every other top-level field in the request body is scanned by default. Every string value in it - whether the field is a plain string, an array, or a nested object - is checked for PII and pseudonymized independently; array elements and object fields are never concatenated before scanning. This is what covers rerank and score requests (query, documents, texts, text_1, text_2, queries, items, instruction, in any of the shapes different providers use - plain strings, arrays of strings, {"text": ...} objects, Cohere-style documents, vLLM content parts), sampling and shape knobs that carry no routing semantics (reasoning_effort, service_tier, modalities, stream_options, and the like), and any provider-specific field such as vLLM’s chat_template_kwargs, without needing a field added to an allowlist first. A field is only exempt from this default scan if it is purely structural - see below.
Exempt from scanning (the value is a routing parameter, not text, and must reach the upstream byte-identical): model.
Shape-validated instead of scanned (the value is a routing or sampling parameter, but only in specific shapes - anything else is rejected fail-closed rather than silently forwarded):
logit_bias- left untouched only when it is a JSON object whose keys are all 1-to-7-digit ASCII-digit strings (token IDs - tokenizer vocabularies stay below 10 million entries) and whose values are all JSON numbers, or is JSONnull. Rewriting a numeric-string key would corrupt the token bias map, so the field is never scanned even when its shape is valid. A longer digit string is rejected fail-closed rather than treated as a token ID, since it could be a card or phone number smuggled through this field.tool_choice- a JSON string is scanned like any other string field; JSONnullis a no-op; a JSON object’sfunction.nameis validated as a function name (see above) and left untouched, while every other string value in the object (includingtype) is scanned normally.tools- each element’sfunction.nameis validated as a function name,function.descriptionandfunction.parametersare scanned as described above; every other key onfunction(a sibling ofname/description/parameters) and every other key on the element itself (a sibling oftype/function-metadata,custom, or whatever a non-function tool type carries) is scanned with the same string-leaf scan used forparameters.functions(legacy) - each element is{"name", "description", "parameters", ...};nameis validated as a function name,descriptionandparametersare scanned exactly liketools[].function.descriptionandtools[].function.parameters, and every other key on the element is scanned the same way astools[].function’s sibling keys.function_call(legacy) - a JSON string is scanned liketool_choice’s string form; JSONnullis a no-op; a JSON object selects a function bynamedirectly (no nestedfunctionkey) -nameis validated as a function name, every other string value in the object is scanned normally.
If a field’s value is an object and one of its keys itself looks like PII (rather than a value), the request is rejected (fail-closed) instead of silently forwarding an unscanned or corrupted key.
A single request can hold at most 10,000 unique PII-to-pseudonym mappings. A request that exceeds this - a very large rerank batch, for example - is rejected (HTTP 422) rather than partially anonymized.
Configuration
settings:
pii:
enabled: true
action: pseudonymize
# optional: extra structured patterns on top of the built-ins
patterns:
- type: PASSPORT_NO
regexp: '\b[A-Z]{1,3}[0-9]{6,9}\b'
gazetteer:
enabled: true
# bundled, curated packs (opt-in by name)
packs:
- company-forms # legal forms: GmbH, AG, Ltd, Inc, ...
- de-firstnames # common German given names
- de-cities # major German cities
# your own term lists, any language
dirs:
- /etc/voidllm/gazetteers
# inline terms, handy for a short blocklist
terms:
- type: NAME
values: ["Ayşe", "Kwame"]
- type: PROJECT
values: ["Projekt Nordstern"]
- type: CUSTOMER
values: ["Nordwind Logistik", "Familie Özdemir"]
Extending the lists
Bundled packs are deliberately small and conservative. The lists you add yourself are usually the highest-value ones, because you know your own sensitive terms: employee names, customer names, project code names, internal system names.
A gazetteer file in a dirs directory is plain text:
# locale: de
# type: CUSTOMER
Nordwind Logistik
Familie Özdemir
- One term per line;
#starts a comment. Multi-word terms are supported. # type:is required. Any label works; unknown labels get a stable two-character code in the pseudonym (PROJECTbecomesPR,CUSTOMERbecomesCU).# locale:is metadata only. The matcher is language-neutral, so lists of any language can be loaded together.- Files are read at startup. Restart to pick up changes.
Per-model behavior
By default, anonymization applies to public destinations only. Private and loopback upstreams (a self-hosted vLLM, Ollama on the same network) receive the original text, because the data never leaves your trust boundary.
Override per model or deployment:
models:
- name: internal-llama
provider: vllm
base_url: http://vllm:8000/v1
pii_filter: true # anonymize even though the destination is private
- name: trusted-partner
provider: openai
base_url: https://api.partner.example/v1
pii_filter: false # WARNING: sends PII in clear text to this upstream
The native endpoints (/v1/messages, /v1/messages/count_tokens, /v1/responses) are never anonymized, because the PII walkers only understand the chat completions format. When PII anonymization is enabled, a native request is only sent to deployments for which anonymization does not apply under the rules above. If there is none, it is rejected with 400 and nothing is forwarded. See Native endpoints.
Operational notes
- Models may notice pseudonyms. A pseudonym is an odd-looking token. Models sometimes comment on it, refuse to repeat it, or handle it awkwardly. Expect some quality impact on text that is heavily pseudonymized.
- False positives mask real text. A gazetteer term that is also an everyday word will be replaced wherever it appears. The bundled lists exclude known collisions; apply the same care to your own lists.
- Ambiguity fails closed. If a request or response cannot be processed safely, it is rejected (HTTP 422) or the stream is aborted, rather than forwarding unprotected content. Enabling PII therefore trades some availability for safety.
- Restoration covers response bodies and streams, but not response headers. A provider that echoed a pseudonym into a header would pass it through. No realistic vector is known.
Related
- Privacy Architecture - the zero-knowledge design this builds on
- Configuration Reference