Guardrailz
HomeHubBlogsPricingDocs

Introduction

  • Overview
  • Architecture
  • Core Concepts

Getting Started

  • Installation
  • Quickstart
  • Playground

API

  • Validate API
  • Profiles API
  • Analytics API
  • Error Handling

SDK

  • Overview
  • Client
  • Guardrails
  • Examples

Guardrails

  • Overview
  • Input Guardrails
  • Output Guardrails
  • Tool Guardrails
  • Custom Guardrails

Profiles

  • Overview
  • Built-in Profiles
  • Custom Profiles
  • Profile Compilation

Analytics

  • Overview
  • Events
  • Queries
  • Dashboards

Deployment

  • Environment
  • Security
  • Scaling
  1. Docs
  2. /guardrails
  3. /writing custom

Writing Custom Guardrails

Custom guardrails allow you to enforce domain-specific rules unique to your application.

When to write a custom guardrail

  • Industry-specific compliance
  • Proprietary business logic
  • Internal safety rules
  • Organization-specific policies

Guardrail structure

A guardrail consists of:

  • A unique name
  • An execution phase (input, output, tool)
  • A configuration schema
  • A deterministic execute function

Example use cases

  • Prevent medical advice without disclaimers
  • Enforce region-specific data rules
  • Restrict model usage by user role
  • Enforce cost or latency limits

Design principles

Deterministic

Same input → same result.

Fast

Guardrails should be lightweight.

Observable

Emit analytics and logs.

Configurable

Avoid hardcoded values.

Testing custom guardrails

Every guardrail should have:

  • Unit tests
  • Integration tests
  • Edge-case coverage

Deployment

Once registered, custom guardrails:

  • Can be added to profiles
  • Appear in analytics
  • Are enforced consistently

Next steps

  • Explore Profiles
  • Learn about Analytics
  • Review SDK usage
 
 
 
## You’re done
 
These files are:
 
* Production-ready
* Clear and professional
* Scalable for future docs
* Free of React logic
* MDX-compatible