Skip to main content
Guardrails are real-time content inspection rules that run on every request before it reaches the LLM provider. They detect sensitive content, block harmful topics, and enforce content policies — all evaluated in priority order.

Guardrail Types

Raven supports four guardrail types, each designed for a different class of content risk.
TypePurposeExample
block_topicsPrevent requests about specific subjectsBlock requests mentioning “weapons” or “illegal activities”
pii_detectionDetect personally identifiable informationFlag SSNs, emails, or credit card numbers in prompts
content_filterFilter content by categoryBlock “violence” or “adult” content categories
custom_regexMatch arbitrary patternsCatch internal project codenames or proprietary terms

Actions

Each guardrail has an action that determines what happens when content matches.
  • block — Immediately reject the request with an error. The request never reaches the provider.
  • warn — Allow the request but include a warning in the response. Logged for review.
  • log — Silently log the match for auditing. The request proceeds normally.

PII Types Supported

The pii_detection guardrail can detect the following PII types:
PII TypePatternExample Match
ssnSocial Security Numbers123-45-6789
emailEmail addresses[email protected]
phonePhone numbers555-123-4567
creditCardCredit card numbers4111 1111 1111 1111
ipAddressIP addresses192.168.1.1
You can enable all PII types or select specific ones in the guardrail configuration.

Creating a Guardrail

Via the Dashboard

1

Navigate to Guardrails

Go to Guardrails in the dashboard sidebar.
2

Click Create Guardrail

Select the guardrail type you want to create.
3

Configure the Rule

Set the name, action, and type-specific configuration (topics, PII types, regex pattern, or content categories).
4

Set Priority

Assign a priority number. Lower numbers are evaluated first.
5

Enable the Guardrail

Toggle the guardrail to enabled. It takes effect immediately on all new requests.

Configuration Examples

{
  "name": "Block harmful topics",
  "type": "block_topics",
  "action": "block",
  "config": {
    "topics": ["weapons", "illegal activities", "self-harm"]
  }
}

Priority Ordering

Guardrails are evaluated in ascending priority order. A guardrail with priority 1 runs before priority 10. If a block action triggers, evaluation stops immediately and the request is rejected.
Use low priority numbers for your most critical rules (like PII blocking) and higher numbers for informational logging rules.

How It Works

When a request arrives at the Raven proxy:
Request --> Auth --> Rate Limit --> Guardrails --> Route --> Provider
  1. All enabled guardrails for the organization are loaded, sorted by priority.
  2. Message content is extracted from the request body.
  3. Each guardrail evaluates the content against its configured rules.
  4. On a block match, a GuardrailError is thrown and the provider never receives the request.
  5. On a warn match, the warning is recorded and the request continues.
  6. On a log match, the match is silently recorded.
Because blocked requests never reach the provider, guardrails save you tokens and cost in addition to providing safety.