
Guardrails v0.24.1
Salvaguardas programables para aplicaciones de chat con LLM: aplica reglas de entrada/salida, bloquea jailbreaks e inyecciones de prompt, detecta alucinaciones y enmascara datos sensibles.
NVIDIA NeMo Guardrails Library
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.
What You Can Build
- AI agents and coding assistants: Check proposed tool calls and returned results with tool rails, or connect an agent through the hooks server.
- Conversational applications: Apply input and output checks.
- Retrieval-augmented generation (RAG): Detect or mask sensitive data in retrieved content and check whether answers are grounded in evidence.
How It Works
- Define your policy. Configure rails, models, and prompts in YAML. Use Python actions for custom logic.
- Run the checks. Invoke rails at the points where your application needs a policy decision.
- Read the result. Handle blocked or modified content before executing a tool or returning a response. You can also route generation through Guardrails.

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.
Why NeMo Guardrails
- Govern what agents do. Validate tool names and argument schemas before execution. Check tool results and apply per-tool policies before returning them to the model.
- Keep your model and agent loop. Use checks without main-model generation to add guardrails to an existing application. Model-backed checks still call their configured model or service.
- Compose the policy you need. Combine local regex and CEL rules with safety models and third-party checks.
- Connect your runtime. Choose an integration for your application, shared service, or coding agent.
- Open and yours to run. The library is Apache 2.0 licensed. Choose supported model providers and run checks with local detectors or hosted inference endpoints.
Quickstart
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:
Complete Python example
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,
},
},
}]