Quick Start
Policy Actions
| Action | Behavior |
|---|---|
block | Stop execution and return error |
warn | Log warning and continue |
log | Log event and continue silently |
allow | Allow without any action |
GuardrailPolicy Interface
Preset Policies
Use built-in presets for common scenarios:Preset Definitions
| Preset | Action | Description |
|---|---|---|
strict | block | Block all harmful content |
moderate | warn | Warn on sensitive content |
permissive | log | Log everything, block nothing |
no-pii | block | Block personal information |
no-code | block | Block code execution |
Resolve Policies
Convert string presets and policy objects:Common Patterns
- Content Moderation
- Data Protection
- Environment-Based
Best Practices
Use strict policies in production
Use strict policies in production
Always use
strict and no-pii policies in production environments.Log before blocking
Log before blocking
Use
warn during development to understand what would be blocked.Provide clear messages
Provide clear messages
Include descriptive messages to help users understand why content was blocked.
Layer policies
Layer policies
Combine multiple policies for comprehensive protection.

