
Programmable guardrails for LLM chat apps: enforce input/output rails, block jailbreaks and prompt injections, detect hallucination, and mask sensitive data.
Documentation · Quickstart · Use cases · Integrations · Guardrail catalog · Examples · Community · Security · Releases · Changelog
NeMo Guardrails is an open-source library for applying programmable safety and security controls to LLM and agentic applications. Agents run commands, call APIs, query your data, and read the web. Conversational applications apply input and output checks; retrieval-augmented generation (RAG) systems filter retrieved content and check answers against evidence.
You use the NeMo Guardrails library to declare what each agent may do in a policy, combining low-latency local rules with model-backed checks for jailbreaks, injected instructions, and unsafe tool calls. Your application or agent harness runs these checks and uses their results to decide whether to continue.
pip install nemoguardrails
Requires Python 3.11–3.13. Refer to the installation guide for optional packages and setup.
[!NOTE] Version 0.25.0 deprecates
LLMRails, with removal planned no earlier than 0.27.0. UseGuardrailsfor new integrations and follow the migration guide.

Tool-call checks run before execution, while tool-result checks run after the tool has executed. Latency depends on the configured rules, models, and services.
Integrations support different checks. Rail support varies by engine; refer to rail engine support and configuration.
Check a support agent's proposed refund against a $500 limit, without a model or API key. Install the optional CEL extra for this example:
pip install "nemoguardrails[cel]"
The example validates the tool's argument schema and blocks calls over the limit. Expand it and save it as check_refund.py:
import asyncio
import json
from nemoguardrails import Guardrails, RailsConfig
from nemoguardrails.rails.llm.options import RailStatus, RailType
config = RailsConfig.from_content(yaml_content="""
models: []
rails:
tool_call:
flows: [tool call validation]
per_tool:
issue_refund: [cel check tool call]
config:
cel:
tool_call:
issue_refund:
expressions: ["args.amount > 500"]
""")
TOOLS = [{
"type": "function",
"function": {
"name": "issue_refund",
"parameters": {
"type": "object",
"properties": {"amount": {"type": "number", "minimum": 0}},
"required": ["amount"],
"additionalProperties": False,
},
},
}]
Descubra as ferramentas mais usadas pela nossa comunidade.
Sem dados de popularidade ainda.