Guardrails API Reference
Complete API reference for the guardrail framework and built-in guardrails.
Guardrail Interface
type Guardrail interface {
Validate(text string, isInput bool) error
Name() string
IsTripwire() bool
}
Built-in Guardrails
PII Detection (security)
Detects: emails, phones, SSNs, credit cards
URL Filtering (security)
Regex (content)
Moderation API (moderation - OpenAI)
Content Length (content)
func NewLength(config Config) *guardrail.Guardrail
type CountMode string
const (
CountModeCharacters CountMode = "characters"
CountModeWords CountMode = "words"
CountModeLines CountMode = "lines"
)
Rate Limiting (ratelimit)
func New(config Config) *guardrail.Guardrail
type RateLimiter interface {
Allow(ctx context.Context, key string) (bool, error)
Reset(ctx context.Context, key string) error
Close() error
}
Profanity Detection (moderation)
func NewProfanity(config ProfanityConfig) *guardrail.Guardrail
type SeverityLevel string
const (
SeverityLow SeverityLevel = "low"
SeverityMedium SeverityLevel = "medium"
SeverityHigh SeverityLevel = "high"
)