Back to Documentation

PII Masking

Automatically detect and mask personally identifiable information in requests and responses.

Enable PII Masking

const response = await client.gateway.chat({
  model: "gpt-4",
  messages: [{ role: "user", content: "My SSN is 123-45-6789" }],
  security: {
    piiMasking: {
      enabled: true,
      types: ["ssn", "email", "phone", "credit_card"],
      action: "mask"
    }
  }
});
// Input becomes: "My SSN is [SSN]"

Supported PII Types

Social Security Numbers
Email Addresses
Phone Numbers
Credit Card Numbers
Physical Addresses
IP Addresses
Date of Birth
Names

Masking Actions

Mask

Replace with type label: [EMAIL], [PHONE], etc.

Redact

Replace with asterisks: ****

Hash

Replace with consistent hash for de-identification.