AI

AI Guardrails: What They Are and How to Add Them

AI guardrails are checks around a model that block harmful input, unsafe output and risky actions. Types, examples, LLM guardrail tools and setup.

By OmniAI Editorial · Nov 20, 2026 · 12 min read

AI guardrails are the checks and limits you put around an AI model so it stays safe, accurate and on task. They inspect what goes in (blocking prompt injection, personal data or off-topic requests), what comes out (catching harmful content, leaked secrets, made-up facts or broken formats) and what an AI agent is allowed to do (limiting tools, spending and actions that need human approval). Models have some safety training built in, but guardrails are the layer you control, tuned to your product, users and risks.

This guide explains what AI guardrails are, how they work, the main types, AI guardrails examples for common risks, LLM guardrails tools such as NeMo Guardrails, Guardrails AI and Llama Guard, guardrails for AI agents, a worked example, and how to add guardrails without ruining speed or usefulness.

What Are AI Guardrails?

Think of a language model as a capable but unpredictable worker. Guardrails are the rules and checks around that worker:

  • Before the model: check the request. Is it allowed? Does it contain personal data that shouldn't be sent to the model? Is it trying to override instructions?
  • After the model: check the answer. Is it safe, on topic, in the right format, and supported by the sources it was given?
  • Around actions: if the model can use tools, decide which actions it can take alone and which need approval.

Guardrails complement, but don't replace, the model provider's own safety training. The provider protects against general harms; your guardrails protect against the risks specific to your app, such as a support bot promising refunds it can't give, or an internal assistant revealing salary data.

How AI Guardrails Work

Most guardrails use one or more of these techniques:

TechniqueHow it worksGood forTrade-off
Rules and patternsKeyword lists, regular expressions, allow and block listsCard numbers, banned terms, URLsFast, but easy to evade and brittle
Classifier modelsA small model labels text as safe or unsafe by categoryToxicity, self-harm, jailbreak attemptsFast, but needs tuning to avoid false alarms
LLM-as-judgeA second model checks the output against criteriaTone, policy compliance, factual supportFlexible, but slower and costs more
Schema validationCheck output matches a required structureJSON, forms, function argumentsReliable for structure, not meaning
Grounding checksCompare the answer with the retrieved sourcesHallucinations in RAG appsAdds latency; not perfect
Permissions and limitsRestrict tools, data access, rates and budgetsAgents, cost controlRequires good system design
Human reviewA person approves before something happensPayments, emails, deletionsSlow, so use only where it matters

In practice, guardrails are layered: cheap, fast checks run on everything, and slower checks run only when needed.

A light box on the left, an ink arrow into a grey funnel, an arrow into a grey square with a circle, an arrow into an orange funnel, and a final arrow to a light box on the right.
Input guardrails check the request, the model answers, and output guardrails check the answer before anyone sees it.

Types of AI Guardrails

  • Input guardrails: detect prompt injection and jailbreak attempts, filter abusive content, remove or mask personal data, enforce length limits.
  • Topic and dialog guardrails: keep the assistant to its job (a banking bot shouldn't give medical advice) and steer conversations along allowed paths.
  • Retrieval guardrails: control which documents a user's question can retrieve, based on their permissions, and filter retrieved text for hidden instructions.
  • Output guardrails: block harmful content, check facts against sources, redact secrets and personal data, enforce format and brand rules.
  • Action guardrails: for agents, limit which tools can run, with what arguments, how often, and which actions require approval.
  • Operational guardrails: rate limits, spending caps, logging and alerting.
  • Governance guardrails: company policies on which AI tools may be used and for what; see our guide to an AI policy for companies.

AI Guardrails Examples

AI guardrails examples for common risks:

RiskExampleGuardrail
Prompt injectionA web page tells the assistant to ignore its instructionsInjection classifier on retrieved text; treat it as data; limit tools
Data leakageA user asks the HR bot for a colleague's salaryRetrieval permissions; output check for personal data
Off-topic usePeople use a support bot as free general-purpose AITopic classifier; polite refusal with a redirect
Harmful contentRequests for dangerous instructions or harassmentModeration classifier on input and output
HallucinationThe bot invents a refund policyGrounding check against policy documents; "I don't know" fallback
Wrong commitmentsThe bot promises a discount it can't offerOutput rules for commitments; escalation to a person
Broken outputThe model returns invalid JSON for an APISchema validation with automatic retry
Risky actionsAn agent deletes records or sends emailsTool allowlist; human approval; dry-run mode
Runaway costA loop calls the model thousands of timesStep limits, budgets, rate limits

Prompt injection deserves special attention, because no single check stops it reliably; our guide to prompt injection explains why.

LLM Guardrails Tools

Popular LLM guardrails tools:

ToolTypeWhat it does
NeMo Guardrails (Nvidia)Open-source toolkitProgrammable "rails" for input, output, dialog, retrieval and execution, written in its Colang language plus configuration
Guardrails AIOpen-source Python libraryValidators (from a public hub) that check and fix inputs and outputs, such as PII detection or format checks
Llama Guard (Meta)Open-weight safety modelClassifies prompts and responses into safety categories; Llama Guard 4, released in April 2025, is a 12-billion-parameter multimodal version
Amazon Bedrock GuardrailsManaged cloud serviceContent filters, denied topics, PII masking and contextual grounding checks; usable with models outside Bedrock through its API
Azure AI Content SafetyManaged cloud serviceContent moderation and "Prompt Shields" to detect prompt injection
OpenAI Moderation APIHosted classifierFree moderation endpoint that flags harmful text and images
Open-source classifiersSmall modelsPrompt-injection, toxicity and PII detectors you can run yourself

NeMo Guardrails

NeMo Guardrails is Nvidia's open-source toolkit for adding programmable rails around a language model app. You define flows and rules, such as which topics the bot can discuss, how it should respond to certain requests, and which checks run on input and output, and the toolkit sits between your app and the model. It's flexible and good for conversational apps with strict dialog rules, though it takes time to learn.

Choosing a tool

  • On AWS or Azure and want minimal setup: use the managed service.
  • Need full control or on-premises: combine open-source tools such as Llama Guard, Guardrails AI validators and NeMo Guardrails.
  • Simple app: a moderation endpoint, an injection classifier, schema validation and a few rules may be enough.

Guardrails for AI Agents

Guardrails for AI agents matter most, because agents act rather than just talk. Key controls:

  • Least privilege: give each agent only the tools and data it needs; read-only by default.
  • Tool allowlists and argument checks: for example, an agent may send email only to addresses in your company's domain.
  • Human approval for high-impact actions: payments, deletions, external messages, production changes.
  • Budgets: limits on steps, tokens, tool calls and spending per task.
  • Sandboxing: run code and browsers in isolated environments with limited network access.
  • Separate untrusted content from instructions: text from web pages, emails and documents is data, never commands.
  • Logging and monitoring: record every action for review and alert on unusual behaviour.

If your agents connect to tools through the Model Context Protocol, our guide to MCP security covers the extra risks.

A grey shield shape with a thick orange check mark in the centre.
For agents, guardrails decide what the AI is allowed to do, not just what it may say.

A Worked Example: Guardrails for a Support Bot

Here's an illustrative guardrail stack for a customer-support assistant that answers from a help centre and can look up orders:

StepGuardrailTypical approachCost in latency
1Block abuse and obvious jailbreaksModeration and injection classifiersSmall
2Mask payment card numbers and IDs in the messagePattern rules and a PII detectorVery small
3Keep to support topicsTopic classifier or rules in the system promptSmall
4Only retrieve the customer's own ordersPermission check in the order-lookup toolNone (system design)
5Answer from help-centre sourcesRetrieval plus instructions to cite sourcesPart of normal generation
6Check the answer is supported by sourcesGrounding check or lightweight judge modelModerate
7Block promises outside policyRules for refund amounts and commitmentsSmall
8Escalate when unsureHand off to a person with a summaryNone
9Log everythingStore inputs, outputs and guardrail decisionsNone for the user

Notice how much protection comes from design (permissions, escalation, logging) rather than clever filters. Run fast checks on every message, and reserve slower checks, such as grounding with a judge model, for answers that contain commitments or policy details.

Guardrails in RAG Apps

Apps that answer from documents need a few guardrails of their own:

  • Permission-aware retrieval: only search documents the user is allowed to see. Filtering after retrieval is too late if the model has already read restricted text.
  • Injection filtering on retrieved text: documents and web pages can contain hidden instructions; scan them or treat them strictly as data.
  • Grounding and citations: require answers to cite sources, and check that each claim is supported. If not, answer "I couldn't find that" instead of guessing.
  • Freshness: label or exclude outdated documents so the model doesn't quote last year's policy.

Guardrails vs Moderation vs Alignment

These terms overlap but aren't the same:

TermWhat it meansWho controls it
Alignment and safety trainingHow the model itself was trained to behaveThe model provider
ModerationClassifying content as harmful or allowedProvider or app builder
GuardrailsAll the checks, limits and rules around the model in your appThe app builder
Governance and guidelinesCompany policies on how AI is usedThe organisation

Guardrails are where your product's specific rules live. Moderation is usually one component of them.

How to Measure Guardrails

Treat guardrails like any other feature and measure them:

  • Catch rate: how many bad inputs or outputs the guardrail stops, measured on a test set of known attacks and mistakes.
  • False-positive rate: how often it blocks legitimate requests. High false positives frustrate users.
  • Latency added per check and in total.
  • Cost of any extra model calls.
  • Escape rate in production: problems that got through, found through user reports and log reviews.

Keep a growing test set from red-teaming and real incidents, and run it whenever you change prompts, models or guardrail settings.

Guardrails and Regulation

Guardrails are also how organisations show they manage AI risk. Frameworks that shape them include the NIST AI Risk Management Framework in the US, the OWASP Top 10 for large language model applications, which lists risks such as prompt injection and sensitive information disclosure, and the EU AI Act, which requires risk management and human oversight for high-risk AI systems. Documenting your guardrails, tests and monitoring makes audits and customer security reviews much easier.

How to Add AI Guardrails

  1. List your risks: what could go wrong for your users, your company and third parties? Rank by likelihood and impact.
  2. Start with design: permissions, limited tools, clear escalation paths. These are the strongest guardrails.
  3. Add input and output checks for the top risks, starting with fast ones.
  4. Write clear refusal and fallback messages so blocked users know what to do next.
  5. Test with red-teaming: try to break your app with injection attempts, edge cases and misuse. Turn the failures into test cases.
  6. Measure false positives and negatives: a guardrail that blocks legitimate users is a product bug.
  7. Monitor in production: track how often guardrails fire, review samples, and update rules as you learn.
  8. Revisit when models change, since a new model may behave differently.

Common Mistakes

  • Relying on the system prompt alone. Instructions help but are easy to override.
  • One giant filter instead of layered, targeted checks.
  • Blocking too much, which frustrates users and pushes them to unofficial tools.
  • Ignoring latency: stacking several slow checks on every message makes the product feel broken.
  • No monitoring: guardrails that never get reviewed drift out of date.
  • Forgetting actions: focusing on what the model says while giving it unlimited tools.

FAQ

What are AI guardrails?

AI guardrails are checks and limits around an AI model that keep it safe and on task. They filter inputs, check outputs and restrict actions, for example blocking prompt injection, masking personal data, catching hallucinations and requiring approval before an agent takes risky actions.

What are examples of AI guardrails?

Examples include moderation filters for harmful content, prompt-injection detectors, PII masking, topic restrictions, grounding checks against source documents, JSON schema validation, tool permissions for agents, spending limits and human approval for payments or emails.

What is NeMo Guardrails?

NeMo Guardrails is an open-source toolkit from Nvidia for adding programmable guardrails to language model applications. It lets developers define rails for input, output, dialog flow, retrieval and tool execution.

Do AI guardrails slow down responses?

They can. Fast checks like rules and small classifiers add little delay, while checks that use a second language model add more. Most apps layer fast checks on every message and use slower ones only where the risk justifies it.

Are guardrails enough to make AI safe?

No single layer is enough. Guardrails work best combined with careful system design (limited permissions and tools), model provider safety features, testing, monitoring and human review for high-stakes decisions.

All articles

Read next

Language

EnglishEnglish · en TürkçeTurkish · tr DeutschGerman · de العربيةArabic · ar

Account

Enter your email. We’ll send you a sign-in link and a 6-digit code. No password needed.

Sign in

Theme

Language

Show our email address

To keep spam out of our inbox, please confirm your own email first. We will send you a 6-digit code.

We send codes only to these providers: gmail.com, googlemail.com, outlook.com, hotmail.com, live.com, msn.com, proton.me, protonmail.com, pm.me, icloud.com, me.com, mac.com, yahoo.com, aol.com, gmx.de, gmx.net, web.de, t-online.de, yandex.com, omniai.blog