Guardrails
Configure PII detection and content filtering rules to protect AI requests.
Overview
Guardrails scan every AI request before it reaches the LLM provider. They catch personal data (PII detection) and prohibited content (content filter). Rules apply globally to all endpoints. Scanning runs within your gateway infrastructure (the AI Gateway FastAPI service); no data leaves your network for scanning.
PII detection
PII detection identifies personal data in user messages using pattern recognition and natural language processing. Supported entity types include:
| Entity type | Example | Coverage |
|---|---|---|
| Email address | john@example.com | All standard formats |
| Phone number | +1 555-123-4567 | US, international |
| Credit card | 4111-1111-1111-1111 | Visa, Mastercard, Amex |
| Person name | John Smith | English names (NLP-based) |
| IBAN | DE89370400440532013000 | All countries |
| Turkish TCKN | 12345678901 | 11-digit national ID |
| EU phone | +33 1 42 68 53 00 | FR, DE, UK, TR, and more |
| US SSN | 123-45-6789 | Standard format |
| IP address | 192.168.1.1 | IPv4 |
| Location | Berlin, Germany | Cities, countries (NLP-based) |
| Date/time | March 14, 2026 | Common date formats |
| NRP | Catholic, Republican | Nationality, religion, politics |
| Medical license | DEA# AB1234567 | US medical license numbers |
Creating a PII rule
- On the Guardrails page, click "Add PII rule"
- Enter a rule name (e.g., "Block credit cards")
- Select the entity type to detect
- Choose an action: Block (reject the request) or Mask (replace with a placeholder)
- Click "Add rule"
Content filter
Content filters block or mask specific keywords and patterns in user messages. Two match types are available:
- Keyword: Exact word matching with word boundaries. "kill" matches "kill" but not "skilled". Multi-word phrases use substring matching.
- Regex: Custom regular expressions for format-based detection. Useful for internal project codes (e.g., "PROJECT-\d{6}"), employee IDs, API keys, or internal URLs.
Creating a content filter rule
- Click "Add filter rule"
- Enter a rule name (e.g., "Block competitor names")
- Select the match type: Keyword or Regex
- Enter the keyword or regex pattern
- Choose an action: Block or Mask
- Click "Add rule"
Block vs mask
| Action | Behavior | Best for |
|---|---|---|
| Block | Rejects the request immediately with HTTP 422. The LLM never sees the message. | Sensitive data that must never leave your network (credit cards, SSNs, confidential terms) |
| Mask | Replaces matched text with a placeholder and forwards the modified message to the LLM. | Data that can be redacted without breaking the request (names, emails in output) |
Testing guardrails
Click "Test guardrails" at the top of the page to open the test modal. Paste sample text and click "Run test" to see what your active rules would catch, without sending anything to an LLM. The test shows:
- Whether the text would be blocked
- Each detection with the matched text and entity type
- A masked preview showing what the LLM would receive
- Execution time in milliseconds
Enabling and disabling rules
Each rule has a toggle switch. Disabled rules aren't evaluated during request processing. You can temporarily disable a rule without deleting it, which is handy when investigating false positives.
Change history
Every change to a guardrail rule (name, action, config, toggle) is recorded in the change history. The same applies to endpoint changes. This audit trail tracks who changed what and when, supporting ISO 42001 Clause 10 (improvement) requirements.
Compliance mapping
Guardrails map to these compliance requirements:
- EU AI Act Art. 9: Guardrails are risk mitigation measures that identify and control risks per request.
- EU AI Act Art. 10: PII scanning blocks personal data before it reaches the model (data minimization).
- EU AI Act Art. 12: Every detection is logged with timestamp, entity type, action, and matched text.
- ISO 42001 A.2: Guardrail rules are AI policies that are enforced, not just documented.
Related articles
Settings
Configure error behavior, replacement text, and log retention for guardrails.
Analytics
View blocked and masked request counts in the guardrails activity section.
Logs
Inspect individual requests that were blocked or masked by guardrail rules.
Endpoints
Guardrail rules apply globally to all endpoints listed here.