Skip to main content

PII Data Masking

Automatically detect and mask general personally identifiable information (PII) — such as names, email addresses, and credit cards — in both your prompts and model responses.

How it works

The PII guardrail uses Presidio to analyze text for sensitive entities.

Input you send:

"Check if customer Max Mustermann (max.mustermann@example.com) has open recalls"

What the model receives:
When detected, PII is replaced with a type placeholder.

"Check if customer <PERSON> (<EMAIL_ADDRESS>) has open recalls"

What the model outputs:

"Customer <PERSON> (<EMAIL_ADDRESS>) has 2 open recalls"

Output you receive:
Type placeholders are being mapped back to the original value.

"Customer Max Mustermann (max.mustermann@example.com) has 2 open recalls"

Quick start

curl -X POST 'https://llm.api.caip.bmw.cloud/v1/chat/completions' \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Email the report to Max Mustermann at max.mustermann@example.com"}],
"guardrails": ["pii-data-masking-en"]
}'

Available languages

Guardrail nameLanguageUse when
pii-data-masking-enEnglishYour input is primarily in English
pii-data-masking-deGermanYour input is primarily in German

Choose the guardrail matching your input language for best detection accuracy.

Detected entities

Entity typePlaceholderExamples
Person names<PERSON>Names detected via NLP models
Email addresses<EMAIL_ADDRESS>any@email.com
Phone numbers<PHONE_NUMBER>International phone formats
URLs<URL>Web addresses
IP addresses<IP_ADDRESS>IPv4 and IPv6
IBAN<IBAN_CODE>International bank account numbers
Credit cards<CREDIT_CARD>Visa, Mastercard, Amex, Discover, etc.
Crypto wallets<CRYPTO>Cryptocurrency wallet addresses
MAC addresses<MAC_ADDRESS>Network hardware identifiers

Behavior details

  • Action: MASK — PII is replaced with a placeholder. The request is never blocked outright.
  • Confidence threshold — Only entities exceeding a minimum confidence score are masked, reducing false positives.
  • Both directions — Masking runs on your input (pre-call) and the model's output (post-call).
  • Non-destructive — The original content is not logged or stored. Masking happens in-flight.

Limitations

  • Languages: Only English and German are supported. Other languages will pass through unscanned.
  • Confidence-based: Very short text or text lacking context may not be detected.
  • Latency: Adds a processing overhead (~0,01s-1s) depending on your input/output length.
  • Region: Currently available on RoW (llm.api.caip.bmw.cloud).

Reach out to the CAIP team for Technical Support or Consulting if you need additional language or region support.

Examples

Masking PII in English - curl

curl -X POST 'https://llm.api.caip.bmw.cloud/v1/chat/completions' \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Send the invoice to Max Mustermann at max.mustermann@example.com"}],
"guardrails": ["pii-data-masking-en"]
}'

Masking PII in German - curl

curl -X POST 'https://llm.api.caip.bmw.cloud/v1/chat/completions' \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Bitte kontaktiere Max Mustermann unter max.mustermann@example.com"}],
"guardrails": ["pii-data-masking-de"]
}'

Masking PII in English - OpenAI Python SDK

from openai import OpenAI

client = OpenAI(
base_url="https://llm.api.caip.bmw.cloud/v1",
api_key="your-api-key"
)

response = client.chat.completions.create(
model="claude-sonnet-4.6",
messages=[
{"role": "user", "content": "Summarize the service history for Max Mustermann."}
],
extra_body={"guardrails": ["pii-data-masking-en"]}
)