# Guardrail (AI)

> A check around an AI model. It blocks bad requests and bad answers.

**Field:** Artificial Intelligence  
**Category:** Safety & Security  
**Also known as:** AI Guardrails, LLM Guardrails, Safety Filter

## Think of it like

It is like the rail on a mountain road. You can drive freely, but it stops you going over the edge.

## Definition

A guardrail is a check placed around an AI model to stop bad input and output. An input guardrail looks at a request before the model sees it. It can block attacks or requests that are off topic. An output guardrail looks at the answer before the user sees it. It can block harm, hide private data, or check the format. Guardrails can be simple rules, or a second, smaller model that sorts the text.

## Example

Emma's bank chatbot has an output guardrail. If an answer contains a full card number, the guardrail masks it before it reaches the user.

## Why it matters

Models make mistakes and can be tricked. A guardrail catches some of that before it reaches a person.

## Common mistake

Relying on guardrails alone. They catch a lot, but clever attacks get past them, so keep the model's power limited too.

## Three principles

- **Check the input.** Before the model.
- **Check the output.** Before the user.
- **An extra layer.** Not the only one.

## Related terms

- [Prompt Injection](https://learn.benibix.com/term/ai/prompt-injection)
- [AI Content Moderation](https://learn.benibix.com/term/ai/ai-content-moderation)
- [AI Safety](https://learn.benibix.com/term/ai/ai-safety)
- [System Prompt](https://learn.benibix.com/term/ai/system-prompt)
- [Refusal (AI)](https://learn.benibix.com/term/ai/refusal)

## Told apart from

- [Refusal (AI) vs Guardrail (AI)](https://learn.benibix.com/compare/refusal-vs-guardrail): People think a model's refusal is a guardrail blocking the request. Most of the time it is not. A refusal comes from the model's own training: it decides to say no. A guardrail is a separate check placed around the model, on the way in or the way out. A good app uses both, because each one misses things the other catches.

![A check sits before the model and another after it. The first blocks bad requests. The second blocks or fixes bad answers before the user sees them.](https://learn.benibix.com/diagrams/sf-guardrail.svg)

---

Source: https://learn.benibix.com/term/ai/guardrail
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
