Documentation Index
Fetch the complete documentation index at: https://enrolla-nk-hub-guardrails.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
Hub guardrails provide real-time safety and quality checks for LLM requests and responses at the gateway level. Hub guardrails can run centrally before requests reach your LLM providers (pre-call) and after responses are received from LLMs but before they return to users (post-call). Key Benefits:- No Code Changes Required - Add safety checks without modifying application code
- Centralized Control - Manage security policies for all LLM traffic in one place
- Provider-Agnostic - Works with any LLM provider (OpenAI, Anthropic, Azure, etc.)
- Real-Time Protection - Blocks malicious requests and filters harmful responses
- Flexible Policies - Different guardrail configurations per pipeline
How Guardrails Work
Guardrails execute at two critical points in the request lifecycle:Execution Flow
- User sends a request to Hub
- Pre-call guards execute concurrently on the user’s prompt
- If any blocking guard fails → return HTTP 403
- If warning guards fail → add warning headers, continue
- Request forwarded to LLM (if not blocked)
- Post-call guards execute concurrently on the LLM’s response
- If any blocking guard fails → return HTTP 403
- If warning guards fail → add warning headers, continue
- Response returned to user (if not blocked)
Pre-call vs Post-call Guards
Pre-call guards run on the prompt messages before it reaches the LLM. Use these for security checks, input validation, and preventing malicious prompts. Post-call guards run on the LLM’s completion after the response is generated. Use these for output safety, content moderation, and preventing data leaks.Supported Request Types
Guardrails work across all three LLM endpoint types with appropriate logic for each:| Request Type | Pre-call Guards | Post-call Guards | Streaming Support |
|---|---|---|---|
/chat/completions | ✅ | ✅ | ✅ Skipped |
/completions (legacy) | ✅ | ✅ | ✅ Skipped |
/embeddings | ✅ | ❌ N/A | ❌ N/A |
- Chat and legacy completions support both pre-call and post-call guards. When streaming is enabled, post-call guards are skipped since the response is delivered incrementally.
- Embeddings only support pre-call guards, as there is no text completion to evaluate in the response.
Core Concepts
Guards
A guard is a configured instance of an evaluator. Each guard defines:- What to evaluate (evaluator type)
- When to evaluate (pre_call or post_call)
- How to respond to failures (block or warn)
- Configuration parameters (evaluator-specific settings)
Evaluators
Evaluators are the detection algorithms that analyze text. Traceloop Hub includes 12 built-in evaluators across three categories: Safety Evaluators (6):pii-detector- Detects personally identifiable informationsecrets-detector- Identifies exposed secrets and API keysprompt-injection- Detects prompt injection attacksprofanity-detector- Detects profane languagesexism-detector- Identifies sexist contenttoxicity-detector- Detects toxic/harmful content
regex-validator- Custom pattern matchingjson-validator- JSON structure validationsql-validator- SQL syntax validation
tone-detection- Analyzes communication toneprompt-perplexity- Measures prompt qualityuncertainty-detector- Detects uncertain language
Execution Modes
Guards can run in two modes:pre_call Mode:
- Executes on user input before the LLM call
- Best for: security checks, input validation, attack prevention
- Examples: prompt injection detection, input PII filtering
post_call Mode:
- Executes on LLM output after the LLM responds
- Best for: output safety, content moderation, quality checks
- Examples: response PII filtering, secrets detection, tone validation
Failure Handling
When a guard evaluation fails, the system responds based on theon_failure setting:
block Mode:
- Returns HTTP 403 Forbidden to the user
- Includes details about which guard failed
- Prevents the request/response from proceeding
warn Mode:
- Adds an
x-traceloop-guardrail-warningheader to the response - Allows the request/response to continue
Required Flag (Fail-Closed vs Fail-Open)
Therequired flag determines behavior when the evaluator service is unavailable, times out, or errors.
Default: false
required: true (Fail-Closed):
- If evaluator is unavailable → treat as failure
- Use for security-critical guards
- Ensures zero gaps in protection
- Example: PII detection in healthcare apps
required: false (Fail-Open):
- If evaluator is unavailable → continue anyway
- Use for quality checks and non-critical guards
- Prioritizes availability over enforcement
- Example: Tone detection in internal tools
Providers
Providers are the services that execute evaluations. Currently, Hub supports the Traceloop provider, which offers all 12 evaluators through the Traceloop API. Provider configuration example:Quick Start Example
Here’s a minimal configuration that adds PII detection and prompt injection protection:- Checks all user prompts for PII (blocks if detected)
- Checks all user prompts for injection attacks (blocks if detected)
- Runs both guards concurrently for minimal latency
- Fails closed (blocks if evaluator unavailable)
Observability
Every guard evaluation creates an OpenTelemetry span with attributes:gen_ai.guardrail.name- Guard namegen_ai.guardrail.status- PASSED, FAILED, or ERRORgen_ai.guardrail.duration- Execution time in millisecondsgen_ai.guardrail.error.type- Error category (if failed)gen_ai.guardrail.input- Guard input text
Next Steps
Configuration Guide
Learn how to configure guardrails with complete YAML reference
Evaluators Reference
Detailed reference for all 12 evaluators with examples

