Overview
Custom guardrails allow you to:- Define custom validation logic for user inputs
- Implement specialized output checking
- Control conversation flow based on safety checks
- Build reusable guardrail components
Basic Custom Input Guardrail
1
Configure the bot
2
Create custom input checking flow
- Checks every input using an LLM prompt
- Returns a boolean indicating safety
- Blocks unsafe inputs with a polite refusal
Advanced Content Safety Guardrail
Implement sophisticated content safety using NemoGuard models:1
Configure multiple models
2
Define comprehensive input/output rails
3
Configure topical rules
Custom Action-Based Guardrail
Implement guardrails using Python actions for maximum control:1
Create a custom action
2
Use the action in flows
LLama Guard Integration
Use Meta’s LLama Guard for safety checking:Jailbreak Detection
Protect against prompt injection and jailbreak attempts:Testing Custom Guardrails
Best Practices
- Layer Multiple Guardrails - Combine content safety, topic control, and jailbreak detection
- Use Appropriate Models - Choose specialized models for specific safety tasks
- Test Thoroughly - Cover edge cases and adversarial inputs
- Provide Clear Feedback - Tell users why their input was blocked
- Monitor Performance - Track guardrail activation rates and false positives
- Update Regularly - Refresh patterns and rules as new threats emerge
Related Examples
- Chatbot Assistant - Full chatbot with guardrails
- Multi-Rail Configuration - Combining multiple rails
- Agentic Applications - Guardrails for agents