---
title: "Guardrails"
type: "glossary term"
url: "https://aifordevs.org/glossary#guardrails"
markdown: "https://aifordevs.org/glossary/guardrails.md"
publisher: "AI for Devs"
license: "https://aifordevs.org/reuse"
attribution: "Credit AI for Devs and link to https://aifordevs.org/glossary#guardrails"
---

# Guardrails

Guardrails are checks that run on a model's input or output to block, rewrite, or flag content such as personal data, prompt injection, policy violations, or malformed responses. They run outside the model, so they still apply when the model's output is wrong.

Each check adds latency, and running input checks in parallel with the model call limits that cost. OWASP lists prompt injection as LLM01 and says it is unclear whether fool-proof prevention exists. Treat guardrails as one layer alongside least-privilege tools and human approval for risky actions.

## Example

An output guardrail can scan a reply for a regex matching card numbers and replace any match before the text reaches the user.

## Source

[OWASP, LLM01:2025 Prompt Injection](https://genai.owasp.org/llmrisk/llm01-prompt-injection/)

## Related terms

- [Eval](https://aifordevs.org/glossary#eval)
- [Hallucination](https://aifordevs.org/glossary#hallucination)
- [AI gateway](https://aifordevs.org/glossary#ai-gateway)

## Cite this term

AI for Devs. "Guardrails." https://aifordevs.org/glossary#guardrails

- Page: https://aifordevs.org/glossary#guardrails
- Markdown: https://aifordevs.org/glossary/guardrails.md
- Reuse: Quote or summarize with a link to this page. Terms: https://aifordevs.org/reuse
- Publisher: AI for Devs
