PII Filtering and Compliance at the AI Gateway Layer
How to filter PII at the AI gateway layer, covering detection options, the three redaction modes and the audit trail for compliance.
TL;DR
- PII filtering at the AI gateway layer inspects every prompt and response before it leaves the network, so one control covers every application, provider, and model.
- Bifrost Enterprise detects PII with an in-process regex template, Microsoft Presidio, Azure AI Language PII, AWS Bedrock Guardrails, or Lakera Guard, and catches leaked credentials with Gitleaks-backed Secrets Detection.
- Each guardrail rule can block, redact, or log a match, and PII redaction can apply to the live request, to stored logs only, or to both with reversible placeholders.
- Request logs record every call with its virtual key, provider, model, and redacted content, while signed audit logs record administrative changes; both export to S3, GCS, or SIEM pipelines.
- Virtual keys carry a guardrail profile per consumer group, so a healthcare app, a coding assistant, and a customer chatbot each get the AI compliance controls their regulation requires.
AI applications that process user input send prompts containing potentially sensitive data, including personally identifiable information (PII), credentials, and proprietary business content, to external LLM providers. Without a gateway-level content inspection layer, organizations have no mechanism to intercept or redact sensitive data before it leaves their network. Bifrost, the open-source AI gateway built in Go by Maxim AI, applies PII filtering, secrets detection, and AI compliance guardrails at the infrastructure layer without requiring changes to application code. This guide explains how to implement those controls in practice, and how PII redaction, audit logging, and per-consumer policy map onto HIPAA, SOC 2, ISO 27001, and GDPR.
Why PII Filtering Belongs at the Gateway Layer
PII filtering belongs at the gateway layer because the gateway is the one point every AI request already passes through, which makes it the only place a single rule can cover all applications, providers, and models at once. Implementing PII filtering at the gateway layer rather than inside individual applications provides three structural advantages for security and compliance teams, and the explainer on what AI guardrails are and how they work covers the enforcement model these advantages rest on.
A single enforcement point. A gateway-level filter covers all AI traffic from all applications in the organization, without requiring each application team to implement its own filtering logic. The control is already in the path for any new AI feature.
Immediate policy updates. When a new sensitive data pattern is identified or a compliance requirement changes, updating the filter at the gateway applies it immediately across every consumer, with no application redeployments or code changes needed.
Centralized audit coverage. Compliance audit logs that capture every filtered and unfiltered AI request in one place are far easier to produce from a gateway than by aggregating per-application logs. Every request identity, every guardrail action, every provider call appears in the same immutable record.
These properties make the gateway the most effective place to enforce PII filtering at scale. The guide to stopping AI from leaking PII or unsafe output covers the output side of the same problem.
Types of Sensitive Data That Reach LLM Providers
Five categories of sensitive data reach LLM providers through prompts: personally identifiable information, credentials and secrets, protected health information, financial data, and proprietary code or business logic. Each is regulated differently and each is best caught by a different detection method, which is why a gateway needs both pattern-based checks such as the Custom Regex PII template and semantic providers. Without a content inspection layer, the following categories routinely appear in prompts sent to external LLM providers:
- PII: Names, postal addresses, phone numbers, email addresses, Social Security Numbers, dates of birth, and other information regulated under GDPR, CCPA, and similar data protection frameworks.
- Credentials and secrets: API keys, authentication tokens, passwords, and private keys embedded in prompts or code snippets submitted to coding assistants.
- Protected health information (PHI) under HIPAA: Patient names, medical record numbers, diagnostic information, insurance identifiers, and other information covered by the HIPAA Privacy Rule.
- Financial data: Payment card numbers, bank account numbers, routing numbers, and transaction details regulated under PCI DSS.
- Proprietary code and business logic: Source code, internal system architectures, business strategies, and trade secrets submitted to coding agents and general-purpose AI assistants.
Each category carries a different regulatory and business risk profile, and a gateway-layer approach lets organizations match a filtering profile to each one.
| Data category | Governing regulation | Best detection method in Bifrost | Typical action |
|---|---|---|---|
| PII (email, phone, SSN, card-like numbers) | GDPR, CCPA | Custom Regex PII template, or Presidio / Azure AI Language PII for semantic entities | Redact |
| Credentials and secrets | SOC 2, internal security policy | Secrets Detection (Gitleaks rules) | Block or redact |
| PHI | HIPAA Privacy Rule | Custom Regex for identifiers plus a semantic PII provider | Redact or block |
| Financial data | PCI DSS | Custom Regex card and account patterns | Redact |
| Proprietary code and business logic | Trade secret and contract obligations | Prompt Guardrails policy, virtual key model restrictions | Block or route to in-VPC models |
PII Filtering and Guardrail Controls in Bifrost
The guardrail system in Bifrost provides layered content inspection through a combination of native controls and third-party provider integrations. Every guardrail rule can apply to inputs (prompts), outputs (responses), or both, and rules with the mcp target apply the same checks to MCP tool arguments and results. The companion post on enterprise AI guardrails for PII, injection, and toxicity covers the rule and profile model in depth; this section focuses on the PII and compliance controls.
Native Secrets Detection
Secrets detection in Bifrost is backed by Gitleaks, the open-source secret scanning engine, using the 222 default rules embedded from Gitleaks v8.30.1. Secrets Detection identifies API keys, authentication tokens, private keys, and common credential patterns across all major providers and services. Secrets appearing in prompts are caught before the request is forwarded to any LLM provider. Detection runs in-process with minimal latency overhead, and the action defaults to block, with redact available.
Custom Regex Guardrails with Built-In PII Templates
Custom regex guardrails allow organizations to define their own content patterns for detection and action. Bifrost includes a built-in PII Detection template covering email addresses, US phone numbers, US Social Security numbers, credit-card-like numbers, and IPv4 addresses, evaluated with Go's RE2-compatible engine. Teams extend this template with organization-specific patterns: internal identifier formats, national IDs outside the US, proprietary naming conventions, domain-specific sensitive terms. Because the template is pattern-based rather than semantic, names and unformatted values need a semantic provider such as Presidio.
Custom regex rules are configured once as reusable profiles and attached to virtual keys or applied globally. They run in-process, adding negligible latency.
Third-Party Guardrail Provider Integrations
For organizations with existing content safety infrastructure or more advanced inspection needs, Bifrost integrates with the following external guardrail providers:
- Microsoft Presidio: Analyzer-based PII entity recognition with blocking and redaction, self-hostable inside the network boundary.
- Azure AI Language PII: Entity recognition with configurable PII categories and redaction.
- AWS Bedrock Guardrails: Enterprise content filtering combined with managed PII detection, covering multiple entity types by default.
- Azure Content Safety: Multi-category content moderation with severity-based thresholds for harmful content.
- Google Model Armor: Google Cloud policy enforcement covering prompt injection, content safety, and sensitive data protection.
- CrowdStrike AIDR: Inline AI threat detection with audit visibility and policy-based redaction.
- GraySwan Cygnal: AI safety monitoring using natural language rule definitions.
- Patronus AI: LLM security evaluation including hallucination detection and safety assessment.
- Lakera Guard: Prompt attack and PII screening with span-level findings that Bifrost maps back to the original text for redaction.
- Repello Argus: Asset-defined policies covering prompt injection, PII, secrets, toxicity, and organization policy violations.
The AWS Bedrock Guardrails setup guide walks through configuring one of these external profiles end to end.
Guardrail Actions on Match
When a guardrail rule matches content in a prompt or response, Bifrost supports three actions, configured per rule as block, redact, or detect_only:
- Block: Reject the request before it is forwarded to the provider. The requesting application receives an error indicating the content policy violation.
- Redact: Replace the matched content with a placeholder and forward the modified request to the provider. The original content never reaches the model or the provider's infrastructure.
- Log and allow (
detect_only): Record the match in the request log but allow the request to proceed. This mode is useful for establishing detection baselines before enforcing blocking.
Each action is configurable per guardrail rule, allowing teams to apply blocking to high-risk categories while logging others for review. Redaction itself runs in one of three modes: runtime rewrites the live payload and stores the redacted form, logs_only sends the original text to the model but stores reversible placeholders in logs and exports, and runtime_reversible redacts both with placeholders that permitted users can reveal in Bifrost logs. The logs_only mode is often the actual compliance requirement, because it keeps raw PII out of retained data without changing what the model sees; the guide to PII redaction at the gateway before data reaches providers compares the modes.
Building a Compliance Audit Trail for AI Requests
A compliance audit trail for AI requests has two layers in Bifrost: request logs, which record what every AI call contained and what the gateway did to it, and audit logs, which record who changed the configuration that governed those calls. Auditors ask both questions, and the two logs answer them separately.
Built-in request logging captures every AI request passing through the gateway asynchronously, with no added request latency. Each log entry includes:
- Timestamp and request identifier
- Requesting identity (virtual key, and the team or customer it belongs to)
- Target provider and model, plus the key selected and any retries
- Prompt and response content, stored in redacted form when a guardrail detected sensitive values, or omitted entirely when
disable_content_loggingis enabled - Token usage, cost, and latency
Audit logs in Bifrost Enterprise record administrative activity: who changed which rule, profile, virtual key, or provider, and when. Entries can be signed with an HMAC key for verification, retained for a configurable number of days, filtered in the dashboard, and exported as JSON, JSON Lines, or Syslog (RFC 5424) for SIEM ingestion, with periodic archival to S3 or GCS for long-term retention.
Log exports offload request and response payloads to Amazon S3 or Google Cloud Storage while the logs database keeps searchable metadata, which enables long-term retention policies and cross-system correlation for incident investigation from your own data lake.
The Bifrost governance resource hub provides additional detail on how audit logging fits into a complete governance architecture.
Per-Consumer Compliance Controls via Virtual Keys
Virtual keys are the primary mechanism for applying differentiated compliance controls across consumer groups. Each virtual key carries its own guardrail profile, budget, rate limits, and model access controls.
This differentiation enables compliance teams to configure appropriate controls for each use case without changing application code:
- A customer-facing chatbot handling user-submitted text might have strict PII filtering and content moderation, blocking any prompt containing detected personal information.
- An internal developer tool used by engineers for code generation might have secrets detection enabled but a more permissive content policy suited to technical work.
- A healthcare application might carry a HIPAA-specific guardrail profile with PHI pattern detection from the built-in PII template supplemented by condition-specific identifiers.
- A financial services application might have PCI DSS-relevant patterns for card and account number detection configured as redact-on-match rules.
Because these profiles are attached to virtual keys rather than configured inside applications, compliance teams can update the guardrail profile for a consumer group without involving the application engineering team. The next request after an update is evaluated against the new profile. Engineering-specific rollouts, including SSO, audit logs, and PII guardrails for coding agents, are covered in the guide to securing Claude Code in production.
Compliance for Regulated Industries
AI compliance for regulated industries comes down to four controls the gateway can enforce: sensitive data never leaves the boundary unredacted, every request and configuration change is logged, access is scoped per consumer, and the infrastructure runs where the regulation requires.
| Framework | Requirement | Bifrost control |
|---|---|---|
| HIPAA | PHI must not reach unauthorized processors; access must be auditable | PHI redaction rules, request logs, in-VPC deployment |
| SOC 2 Type II | Evidence of access control, data integrity, and monitoring | Virtual keys with RBAC, HMAC-signed audit logs, log retention to S3/GCS |
| ISO 27001 | A.9 access control, A.12.4 logging and monitoring | Virtual key and role permissions, audit and request logs |
| GDPR | Data minimization, Article 30 records of processing, transfer limits | PII redaction before transmission, request logs, in-VPC and regional deployment |
HIPAA: PHI detection via custom regex, Presidio, or AWS Bedrock Guardrails catches protected health information before it reaches an external model. Request logs and audit logs together provide the records required for HIPAA audit trails. In-VPC deployment keeps all AI traffic within the organization's own network boundary, addressing data residency requirements for covered entities and business associates. Healthcare teams can review the Bifrost healthcare AI infrastructure page for deployment guidance specific to healthcare compliance.
SOC 2 Type II: Audit logs provide the evidence base for access control (virtual keys with role-based assignment), data integrity (HMAC-signed log records), and security monitoring controls. Log exports and audit archival to S3 or GCS enable the retention policies required by SOC 2 auditors.
GDPR: PII redaction at the gateway implements data minimization principles by preventing unnecessary transmission of personal data to external processors. Request logs provide the records required for Article 30 processing activity documentation. In-VPC deployment supports data transfer and localization requirements. Teams selecting broader tooling for these obligations can compare the AI governance tools for regulatory compliance alongside the gateway.
Deploying PII Filtering Without Application Code Changes
Deploying PII filtering at the gateway layer requires changing only the base URL in the existing application configuration, because Bifrost is a drop-in replacement for existing OpenAI, Anthropic, Google GenAI, and LangChain SDKs. The application code itself does not change.
The change in practice:
# Before: direct provider access
client = OpenAI(api_key="sk-...")
# After: all traffic through Bifrost with PII filtering applied
client = OpenAI(
base_url="https://your-bifrost-instance/openai",
api_key="your-bifrost-virtual-key"
)
After this change, every request from the application passes through the Bifrost guardrail stack, and PII filtering, secrets detection, and content safety controls apply automatically. Content inspection moves to the gateway layer, where it can be managed, updated, and audited centrally.
Bifrost supports 25+ providers and 10,000+ models behind this unified API, so organizations running multiple AI providers apply the same guardrail configuration to all of them from a single deployment. The same rollout pattern covers prompt injection and audit requirements, as the guide to LLM gateway security for prompt injection, PII, and audit compliance describes.
Frequently Asked Questions About PII Filtering and AI Compliance
What does AI compliance mean?
AI compliance means operating AI systems in a way that satisfies the regulations and standards that apply to the data they process and the decisions they make, such as GDPR, HIPAA, SOC 2, ISO 27001, and the EU AI Act. In practice it requires enforceable controls on what data reaches a model, who can access which models, and a record of both.
What does PII redacted mean?
PII redacted means that personally identifiable information detected in a text has been replaced with a placeholder, such as [EMAIL] or [SSN], so the surrounding content can still be processed without exposing the original value. In Bifrost, redaction modes let it apply to the live request, to stored logs only, or to both with reversible placeholders.
How do you do PII redaction for LLM prompts?
Route all LLM traffic through a gateway, attach a PII guardrail profile to each virtual key, and set the rule action to redact. Bifrost then matches PII with the regex template or a semantic provider such as Presidio, replaces each match using a replace, mask, or hash strategy, and forwards the redacted prompt to the provider, with no application code change.
Is PII masking the same as PII redaction?
PII masking preserves the approximate shape of a value while hiding it, for example [EMAIL:****************], whereas redaction replaces the value with its entity type alone. Bifrost treats masking as one of three redaction strategies (replace, mask, hash), selectable per rule, so teams can keep length information for downstream parsing where they need it.
Does gateway-level PII filtering satisfy HIPAA on its own?
No single control satisfies HIPAA, but gateway-level PHI redaction addresses the transmission risk, request logs address the audit trail, and in-VPC deployment addresses data residency. Covered entities still need a business associate agreement with any external model provider that receives PHI, and Bifrost's per-consumer profiles let a healthcare application block PHI from providers that lack one.
Get Started with AI Gateway Compliance
Implementing PII filtering and compliance controls at the AI gateway layer begins with deploying Bifrost and configuring guardrail profiles for each consumer group. The governance resource page has detailed guidance on virtual key configuration, guardrail profile structure, and how to apply different compliance profiles to different teams or applications.
For organizations with specific compliance requirements in regulated industries, HIPAA-specific PHI detection profiles, SOC 2-aligned audit log retention, and in-VPC deployment configurations are covered on the Bifrost Enterprise feature page, and the broader rule and profile system behind them is explained in the AI guardrails explainer.
To see how Bifrost handles PII filtering and compliance at the gateway layer for your organization's specific requirements, book a demo with the Bifrost team.