Join our Newsletter — 33% off our NHI Course
Home› Guides› Open-Source LLM Guardrails Guide: Deploying Llama Guard, NeMo…
Guide LLM & GenAI Security

Open-Source LLM Guardrails Guide: Deploying Llama Guard, NeMo Guardrails, Guardrails AI and LLM Guard

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 18 November 2026 13 min read
On this page

Open-source LLM guardrails let teams that self-host their AI applications screen prompts, responses and tool calls without sending traffic to a third-party safety service, but only if they are deployed, configured and monitored with the same care as any other security control. This guide is for engineers and security teams who want to run open-source guardrails themselves. It covers four widely used projects, how each one is installed and configured, where it sits in the request path, and the operational work that makes it dependable: identity of the guardrail service, logging, testing, updates and failure handling.

For the concepts behind guardrails and AI firewalls, including where to enforce, detection techniques and their limits, read the AI Guardrails and AI Firewalls Guide first. This page does not repeat that material. The four projects are described in alphabetical order (Guardrails AI, Llama Guard, LLM Guard, NeMo Guardrails), each in its own neutral section, using facts from each project's own documentation as of November 2026. No ranking or comparison is intended; choose based on your own requirements and testing.

Key takeaways

  • Open-source guardrails come in different forms: a framework of validators, a safety classifier model, a library of scanners and a dialogue rail toolkit. They can be layered, and each needs its own deployment plan.
  • A guardrail is a security dependency. Pin versions and model weights, record them in your software bill of materials, and check maintenance status regularly. One project in this guide is now archived by its maintainer.
  • Guardrail models are themselves LLMs and can be targeted by prompt injection. Do not treat a "safe" verdict as proof that content is harmless.
  • Decide in advance what happens when a guardrail fails, times out or is unavailable. For high-risk actions, fail closed.
  • Check telemetry and remote calls. Some projects send usage data or call hosted services unless configured otherwise.
  • Measure false positives and false negatives on your own traffic before enforcing, and keep the test set under version control.

Where self-hosted guardrails sit

A self-hosted guardrail usually runs in one of three places:

  • In process. A Python library is called directly by the application before and after each model call. This is the simplest option and keeps latency low, but every application must integrate it correctly.
  • As a sidecar or internal service. The guardrail runs as an HTTP service next to the application or model server. Several projects in this guide ship a server mode for this.
  • As a classifier model. A dedicated safety model is served by the same inference stack as your main model and called as a separate step.

In every case there are four checkpoints worth covering: the user's input, retrieved content in retrieval-augmented generation (RAG), tool or function calls and their results, and the model's final output. Tool calls deserve the most attention in agent systems, because a manipulated tool call can change data or spend money. The Prompt Guardrails vs Policy Engines for AI Agent Actions guide explains why authorisation for actions should also sit outside the model.

Project settings at a glance

This table lists each project's own install command and main configuration concept, with a link to its documentation. It is a reference list, in alphabetical order, not a comparison.

ProjectLicence (per project docs)InstallMain configuration conceptDocumentation
Guardrails AIApache 2.0pip install guardrails-aiGuards built from validatorsguardrails-ai/guardrails
Llama Guard 3See model card and weights pageModel weights served by your inference stackHazard categories S1 to S14Llama Guard 3 8B model card
LLM GuardMITpip install llm-guardInput and output scannersprotectai/llm-guard
NeMo GuardrailsApache 2.0pip install nemoguardrailsconfig.yml plus Colang flowsNVIDIA/NeMo-Guardrails

Guardrails AI

The Guardrails AI README describes a Python framework that runs input and output guards to detect and mitigate risks, and helps generate structured data from LLMs. A validator is a pre-built check for a specific type of risk, and validators are combined into Guards that intercept model inputs and outputs. Validators are listed in the Guardrails Hub.

Deployment

  • Install with pip install guardrails-ai, then run guardrails configure to set up the Hub command-line tooling. Individual validators install as separate packages.
  • For a service deployment, guardrails start --config=./config.py runs Guardrails as a REST service, and Guards can be created with guardrails create. The server exposes an OpenAI-compatible endpoint, so an application using the OpenAI SDK can point its base URL at a guard.
  • The README notes the development server is Flask based and recommends Docker with Gunicorn for production.
  • For structured output, a Pydantic model defines the expected shape and Guard.for_pydantic creates the Guard.

Operational notes

  • The README shows OnFailAction.EXCEPTION, which raises an error when a validator fails. Decide per validator whether failure should block, and make sure the application handles the exception rather than retrying without the guard.
  • A notice in the README, dated 6 July 2026, says validators are moving to standard PyPI packages and that hosted remote inferencing is being discontinued, with a planned cut-off of 25 August 2026. Teams that relied on hosted inferencing should confirm their validators now run locally.
  • Because validators are separate packages, review each one as a third-party dependency and pin its version.

Llama Guard

The Llama Guard 3 8B model card describes a content safety classifier fine-tuned from Llama 3.1 8B that can screen both prompts and responses. Its output text indicates whether the content is safe or unsafe and, if unsafe, lists the categories violated. Scores can be taken from the probability of the first output token and thresholded for binary decisions.

Hazard categories

The model card lists 14 categories: S1 Violent Crimes, S2 Non-Violent Crimes, S3 Sex-Related Crimes, S4 Child Sexual Exploitation, S5 Defamation, S6 Specialized Advice, S7 Privacy, S8 Intellectual Property, S9 Indiscriminate Weapons, S10 Hate, S11 Suicide and Self-Harm, S12 Sexual Content, S13 Elections and S14 Code Interpreter Abuse. S14 covers attempts to abuse code interpreters, such as denial of service, container escapes or privilege escalation, which makes it relevant to agent systems that run code.

Deployment

  • Serve the weights with your existing inference stack and call the model as a separate classification step on input, output or both.
  • Choose which categories to enforce for each application, and set the threshold using your own labelled examples.
  • The model card lists supported languages as English, French, German, Hindi, Italian, Portuguese, Spanish and Thai. Plan separate handling for traffic in other languages.

Operational notes

  • The model card states that, as an LLM, the classifier may be vulnerable to adversarial or prompt injection attacks, and that deployment may increase refusals of benign prompts.
  • It also notes that categories such as Defamation, Intellectual Property and Elections may need factual, up-to-date knowledge, and suggests more complex systems for highly sensitive uses.
  • Confirm the licence and acceptable use terms on the weights download page before production use, and record the exact weights version you serve.

LLM Guard

The LLM Guard README describes a security toolkit from Protect AI for LLM interactions, covering sanitisation, harmful language detection, data leakage prevention and prompt injection resistance. It is organised as scanners that run on prompts and on outputs.

Status

The README carries a warning that the project is archived and no longer under active development or maintained, and that the same applies to its Hugging Face models. Teams already running LLM Guard should treat it as an unmaintained dependency: freeze and record the version, assess whether security fixes can be applied in house, and plan a review of its place in the stack.

Scanners

  • Input scanners (15): Anonymize, BanCode, BanCompetitors, BanSubstrings, BanTopics, Code, Gibberish, InvisibleText, Language, PromptInjection, Regex, Secrets, Sentiment, TokenLimit and Toxicity.
  • Output scanners (21): BanCode, BanCompetitors, BanSubstrings, BanTopics, Bias, Code, Deanonymize, JSON, Language, LanguageSame, MaliciousURLs, NoRefusal, ReadingTime, FactualConsistency, Gibberish, Regex, Relevance, Sensitive, Sentiment, Toxicity and URLReachability.

Deployment

  • Install with pip install llm-guard on Python 3.9 or later. The README says it can also be deployed as an API.
  • Pairing Anonymize on input with Deanonymize on output lets an application mask personal data before it reaches the model and restore it afterwards. Keep the mapping store protected, since it holds the original values.
  • The Secrets input scanner is relevant to NHI risk: it can catch API keys and tokens pasted into prompts before they reach a model or a log.

NeMo Guardrails

The NeMo Guardrails README describes an open-source NVIDIA toolkit that adds programmable rails to LLM-based conversational applications, sitting between application code and the model.

Rail types

  • Input rails screen user messages, which can be rejected, masked or rephrased.
  • Dialog rails govern how the model is prompted, including whether to run an action or use a predefined response.
  • Retrieval rails filter or alter retrieved chunks in RAG.
  • Execution rails check the inputs and outputs of custom actions (tools) the model calls.
  • Output rails reject or modify responses before they reach the user.

Deployment

  • Install with pip install nemoguardrails on Python 3.10 to 3.13.
  • A configuration folder holds config.yml (models, active rails and settings), Colang .co files for flows, and optional config.py and actions.py for custom code. Colang 1.0 is the default and 2.0 is supported.
  • nemoguardrails server loads configurations from a folder and exposes an HTTP API with a /v1/chat/completions endpoint that takes a config_id. A Dockerfile is provided.
  • Built-in guardrails include self-checking for moderation, fact-checking and hallucination, NVIDIA safety models for content and topic safety, and jailbreak and injection detection.

Operational notes

  • The README says telemetry is on by default and sends anonymous usage pings. Opt out by setting NEMO_GUARDRAILS_NO_USAGE_STATS=1 or DO_NOT_TRACK=1, or by creating a do_not_track file, before the library starts.
  • It states that NVIDIA Build endpoints are for evaluation and testing only, not production, and that confidential or personal data should not be sent to them. Make sure production configurations point only at your own model endpoints.
  • Treat actions.py and config.py as code: review, test and sign them like any other application change.

Running guardrails as a service securely

When a guardrail runs as an HTTP service, it becomes part of your attack surface and a non-human identity in its own right. Recommended controls (NHI Mgmt Group guidance):

  • Bind the service to an internal network and require authentication from calling applications, using workload identity or mutual TLS rather than a shared static key.
  • Give the guardrail service only the model endpoints and secrets it needs. If it calls a classifier model, use a dedicated credential for that call.
  • Do not log full prompts and responses by default. Log verdicts, categories, scanner names and request identifiers, and store any content samples under your data retention rules.
  • Rate limit the service and set timeouts, so a slow classifier cannot stall the application or be used for denial of service.
  • Run the service as a non-root user in a minimal container, with egress restricted to the endpoints it needs, which also stops unexpected telemetry or remote calls.

Testing, tuning and failure handling

Guardrails work only as well as their configuration fits your traffic. A practical tuning cycle:

  1. Build a labelled test set from real, anonymised traffic, plus known attacks from your AI red teaming work and from public jailbreak collections.
  2. Run the guardrail in monitor mode first, logging verdicts without blocking.
  3. Measure false positives (benign requests flagged) and false negatives (attacks passed), per category or scanner.
  4. Adjust thresholds, categories and validators, then rerun the full set.
  5. Switch to enforcement for the categories that meet your targets, and keep monitoring the rest.
  6. Repeat after every guardrail, model or prompt change.

Define failure behaviour explicitly. If the guardrail raises an error, times out or is unreachable, high-risk paths such as tool execution, code interpreters and data export should fail closed. Low-risk paths such as general chat may fail open with an alert, if the business accepts that. Never let a retry path silently bypass the guardrail. Jailbreak techniques that target classifiers are covered in the LLM Jailbreaks Guide.

Supply chain and maintenance

Each guardrail adds Python packages and, often, model weights to your stack. Treat them as security-relevant dependencies:

  • Pin package versions and model weight hashes, and scan them with your usual software composition tools.
  • Download weights from the official source only, and check them against published hashes where available. The Hugging Face Security Guide covers safe model retrieval.
  • Check maintenance status at least quarterly. Archived or unmaintained projects need a documented decision about continued use.
  • Track announced changes, such as the move away from hosted inferencing noted in the Guardrails AI README, so that a dependency does not change behaviour on a fixed date without warning.

MITRE ATLAS catalogues AI Supply Chain Compromise (AML.T0010), which applies to guardrail models as much as to the main model.

Common failure patterns

  • Output-only checks. Only the final response is screened, so injected instructions in retrieved documents or tool results drive tool calls unchecked.
  • Silent fail open. A guardrail exception is caught and the request proceeds, so an attacker who can trigger errors bypasses it.
  • Default thresholds in production. Thresholds are never tuned on real traffic, so users meet heavy false positives and teams disable the control.
  • Prompt logging by accident. Debug logging in the guardrail service stores full prompts containing personal data or secrets.
  • Unreviewed custom code. Custom actions and validators run with the application's privileges without code review.
  • Unmaintained dependencies. A project is archived upstream and no one notices.
  • Telemetry left on. Default usage reporting runs in a regulated environment where outbound calls are not permitted.

Practitioner checklist

  • Record each guardrail project, version and model weights hash in the SBOM and AI inventory.
  • Cover input, retrieved content, tool calls and output, not just the final response.
  • Run guardrail services on internal networks with authenticated callers and restricted egress.
  • Disable or confirm telemetry settings before first start in each environment.
  • Tune thresholds and categories in monitor mode against a version-controlled test set.
  • Define fail-closed behaviour for tool execution, code interpreters and data export.
  • Log verdicts and identifiers, not full content, unless retention rules allow it.
  • Review maintenance status of every guardrail dependency each quarter.
  • Retest after every guardrail, model or system prompt change.

Standards and references

Related NHI Mgmt Group resources: AI Guardrails and AI Firewalls Guide · Prompt Guardrails vs Policy Engines for AI Agent Actions · AI red teaming · LLM Jailbreaks Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.