Skip to main content

Prerequisites

Before installing NeMo Guardrails, ensure your system meets the following requirements:

Python Version

NeMo Guardrails supports the following Python versions:
  • Python 3.10
  • Python 3.11
  • Python 3.12
  • Python 3.13
Python 3.9 and earlier versions are not supported.

C++ Compiler and Dev Tools

NeMo Guardrails uses annoy, a C++ library with Python bindings for efficient similarity search. You’ll need a C++ compiler and development tools installed on your system.
Install Xcode Command Line Tools:
This provides the necessary C++ compiler (clang) and build tools.

Installation

1

Install via pip

The simplest way to install NeMo Guardrails is using pip:
This installs the core package with all essential dependencies.
2

Verify Installation

Verify that NeMo Guardrails is installed correctly:
You should see the help menu with available commands:
3

Test Python Import

Test that you can import the package in Python:
If this runs without errors, you’re ready to go!

Optional Dependencies

NeMo Guardrails supports optional features through extras. Install them based on your needs:

Optional Dependencies Details

Includes:
  • openai - Official OpenAI Python client
  • langchain-openai - LangChain integrations for OpenAI models
Required for using OpenAI models (GPT-3.5, GPT-4, etc.).
Includes:
  • tqdm - Progress bars for evaluation
  • numpy - Numerical computing
  • streamlit - Web UI for evaluation results
  • tornado - Web server framework
Required for running nemoguardrails evaluate command.
Includes:
  • presidio-analyzer - PII detection and analysis
  • presidio-anonymizer - PII anonymization
Required for detecting and masking sensitive data like emails, phone numbers, SSNs, etc.
Not available for Python 3.13
Includes:
  • google-cloud-language - Google Cloud Natural Language API
Required for using Google Cloud services.
Includes:
  • langchain-nvidia-ai-endpoints - LangChain integration for NVIDIA NIM
Required for using NVIDIA NIM (NVIDIA Inference Microservices).
Includes:
  • opentelemetry-api - OpenTelemetry API
  • aiofiles - Async file operations
Required for distributed tracing and observability.
Includes:
  • yara-python - Pattern matching for jailbreak detection
Required for advanced jailbreak attempt detection.
Includes:
  • fast-langdetect - Fast language detection
Required for multilingual content safety.
Includes:
  • aiofiles - Async file operations
  • openai - OpenAI client for server endpoints
Required for running nemoguardrails server with full features.

Development Installation

For contributing to NeMo Guardrails or running tests, install from source:
1

Clone the Repository

2

Install with Poetry

NeMo Guardrails uses Poetry for dependency management:
3

Activate the Environment

4

Run Tests

Docker Installation

You can also run NeMo Guardrails in a Docker container:
For detailed Docker usage, see the Using Docker guide in the official documentation.

Environment Variables

For using LLM providers, you’ll typically need API keys set as environment variables:
OpenAI
Anthropic
Cohere

Troubleshooting

Windows users: Install Microsoft C++ Build Tools as described in the prerequisites section.
Linux/macOS users: Install build tools and Python development headers:
Ubuntu/Debian
macOS
The annoy library didn’t install correctly. This usually means the C++ compiler isn’t available. Install the required build tools for your platform.
Consider using a virtual environment to isolate dependencies:

Next Steps

Quickstart Guide

Now that you have NeMo Guardrails installed, follow the quickstart guide to create your first guardrails configuration.