Learn how to implement PII redaction in ChatGPT, OpenAI, and other LLM APIs. Protect customer data, ensure GDPR/HIPAA compliance, and prevent data breaches in your AI workflows.
If you're building applications with ChatGPT, OpenAI APIs, or any Large Language Model, there's a security problem you need to solve before going to production. Every time your app sends a prompt to an AI provider, you might be exposing your customers' most sensitive data (names, emails, credit cards, social security numbers) to third-party servers. This guide walks you through exactly how PII redactionworks and why it's become essential for any serious AI implementation in 2025.
Personally Identifiable Information (PII) is any data that can be used to identify a specific individual. When you send prompts to AI models like GPT-4, Claude, or Gemini, this information gets transmitted to third-party servers. This creates real security and compliance risks that can cost your company millions.
When your application sends prompts containing customer data to AI providers, you're creating serious legal and security exposure. Here's what you need to understand:
OpenAI and other providers may store your prompts for up to 30 days. That means your customer's personal data sits on third-party servers, outside your control.
Without enterprise agreements, your data could be used to train future models. This could potentially leak sensitive information to other users down the line.
Transferring EU citizen data to US-based AI providers without proper safeguards violates GDPR Article 44. Fines can reach 4% of your global revenue.
Sending protected health information (PHI) to AI models without a Business Associate Agreement is a HIPAA violation with penalties up to $1.5M per incident.
PII redactionintercepts API calls to LLMs, automatically detects sensitive information using AI-powered entity recognition, and replaces it with safe placeholder tokens. Here's the exact process:
Your native OpenAI, Anthropic, or Google API call reaches the SHIM gateway before the selected provider.
Configured detectors scan the request for supported sensitive values such as emails, phone numbers, credentials, card numbers, SSNs, and Turkish identity numbers.
Detected values are replaced with randomized, request-local typed placeholders such as <EMAIL_ADDRESS_1964f6d844cd293bdcadc8ee81071dcc> so they can be restored in the client-facing response.
When the AI responds, tokens are automatically replaced with original values. Your application sees the complete response.
See exactly how SHIM transforms your API calls to protect sensitive data:
// Your original API call
const response = await openai.chat.completions.create({
model: "gpt-4.1",
messages: [{
role: "user",
content: "Summarize the support ticket for
sarah.johnson@acme.com (card: 4111 1111 1111 1111)
regarding her order #ORD-2025-1234"
}]
});Problem: Customer email and card number sent directly to OpenAI servers
// What actually gets sent to OpenAI
{
"messages": [{
"role": "user",
"content": "Summarize the support ticket for
<EMAIL_ADDRESS_1964f6d844cd293bdcadc8ee81071dcc>
(card: <CREDIT_CARD_6a7e0e79b018d08c9d1bb20be79999a7>)
regarding her order #ORD-2025-1234"
}]
}
// Request-local placeholder mapping used for response restoration:
// <EMAIL_ADDRESS_1964f6d844cd293bdcadc8ee81071dcc> → sarah.johnson@acme.com
// <CREDIT_CARD_6a7e0e79b018d08c9d1bb20be79999a7> → 4111 1111 1111 1111Result: the detected values are not forwarded to the provider. This is one technical privacy control, not a compliance determination.
Use this checklist to ensure your AI implementation meets regulatory requirements:
SHIM replaces recognized sensitive values with randomized, request-local typed placeholders before forwarding a request to the selected provider, then restores them in the client-facing response. It preserves each provider's native API rather than translating requests or selecting a fallback provider.
const openai = new OpenAI({
baseURL: "https://api.getshim.tech/v1",
apiKey: process.env.SHIM_API_KEY
})As AI adoption accelerates, PII redactionis no longer optional. It's a fundamental requirement for any organization using ChatGPT, OpenAI, or other LLMs in production. The risks are clear: data breaches, regulatory fines up to €20M, and permanent reputation damage.
The solution is equally clear: implement automatic PII detection and redaction at the infrastructure level. A gateway can reduce exposure, but each deployment still needs its own legal, security, provider, and retention review.
Ready to secure your AI infrastructure? Start by mapping your data flows, choosing the provider-native API you need, and testing redaction against representative inputs.
SHIM detects the sensitive-value types documented for its PII processing, including emails, phone numbers, credentials, card numbers, SSNs, and supported Turkish identifiers. It does not currently detect personal names. Confirm current coverage and test representative languages and regional formats before relying on it.
It depends on the input, detection rules, provider, and deployment. Measure end-to-end latency with representative traffic before setting a production budget.
No. It is one technical control. Assess your provider terms, data flows, retention, access controls, and regulatory obligations with the appropriate legal and security reviewers.
Use the documented configuration for supported detector types, and test the resulting policy against representative inputs. Treat custom detection and application-specific authorization as separate controls unless they are explicitly documented.