Skip to main content
Guard checks every call at the gateway, both ways. It can scan the user’s input before the model sees it, and the model’s response before it reaches your code. A typical use: redact credit card numbers from incoming messages, or block responses that look like a leaked API key.

Two kinds of rule

Open Controls → Guard in platform.opper.ai and add a rule.

LLM Guard

A custom prompt that asks a model to classify content. Use it for fuzzy things like tone, intent, or categories. Templates: PII, Toxicity, Secrets.

Regex Guard

Pattern matching. Use it for known formats like credit cards, emails, SSNs, and API keys. Templates: Email, Phone, Credit Card, SSN, API Key.

Actions

Where it applies

You can layer rules. For example, run an org-wide secrets check alongside a stricter toxicity check on a customer-facing project. Each rule fires independently.

Where you see the result

A Guardrail event appears on the trace span with a Shield icon and status:
  • Passed: the content was fine.
  • Flagged: matched but the action was Flag, so the call proceeded.
  • Blocked: the rule rejected the call.
Each event carries the rule name, a family label (LLM guard or Regex guard), and a scope badge. Redacted content appears already replaced in the span’s input or output. In the playground, Guard runs when Project controls is on. Open the trace ↗ link to see the event.
Start with Flag while validating a new rule. Once you trust it, switch to Block or Redact. Combine an LLM Guard (fuzzy: toxicity, intent) with a Regex Guard (exact: card numbers, API keys).