Navigate to Guardrails
Fill in the Custom Guardrail Form
main.py
: FastAPI application with route definitionsguardrail/
: Directory containing all guardrail implementationsentities.py
: Pydantic models for request/response validationrequirements.txt
: Dependencies and librariesRequestContext
is a Pydantic model that provides structured contextual information for each request processed by your custom guardrail server. It includes details about the user (as a Subject
object) and optional metadata relevant to the request lifecycle. This context is automatically populated by the TrueFoundry AI Gateway and can be leveraged for access control, auditing, or custom logic within your guardrail implementations.
1. PII Redaction (Presidio)
Info
POST /pii-redaction
Code Snippet
Response Behavior
null
- No PII detected, no transformation neededChatCompletionCreateParams
- PII detected and redacted, returns modified requestHTTP 400/500
- Error occurred during processing2. NSFW Filtering (Local Model)
Info
POST /nsfw-filtering
Code Snippet
Response Behavior
null
- Content is safe, no issues detectedHTTP 400
- NSFW content detected, request blocked3. Drug Mention Detection (Guardrails AI)
Info
POST /drug-mention
Code Snippet
Response Behavior
null
- No drug mentions detectedHTTP 400
- Drug mentions detected, request blocked4. Web Sanitization (Guardrails AI)
Info
POST /web-sanitization
Code Snippet
Response Behavior
null
- No malicious content detectedHTTP 400
- Malicious content detected, request blocked5. PII Detection (Guardrails AI)
Info
POST /pii-detection
Code Snippet
Response Behavior
null
- No PII detectedHTTP 400
- PII detected, request blockedInput Guardrail Request
Output Guardrail Request