NeMo Engine
gllm-guardrail | Tutorial: Guardrail | Engine: NeMo | API Reference
What it does
NemoGuardrailEngine integrates with NVIDIA NeMo Guardrails to run LLM-based moderation.
In this library, NeMo Guardrails is wired to gllm-inference via a custom provider, so the engine can use the same model ecosystem you already use elsewhere in the SDK.
What it can handle (in this library)
Out of the box, the default NeMo configuration includes:
Allowed & denied topic guardrails (allowlist / denylist / hybrid / disabled)
Prompt injection / jailbreak detection (via predefined flows)
Core safety restrictions (categories such as violence, hate, privacy, system manipulation, etc.)
Use default config
from gllm_guardrail import NemoGuardrailEngine
engine = NemoGuardrailEngine()Default model and credentials (important)
The default config_dict uses:
Model:
openai/gpt-5-nanoCredentials:
"OPENAI_API_KEY"(resolved from environment variables)
Use custom config
Configuration is done by passing a NemoGuardrailEngineConfig into the engine:
1) Topic safety settings
2) Enable/disable core restriction categories
How to change the LLM model and its configuration
The NeMo engine reads model configuration from config_dict["models"]. The provider is already set up to use gllm-inference:
engine:"gllm_invoker"model: any model id supported bygllm-inference(e.g.,"openai/gpt-4o-mini","azure-openai/gpt-4o-mini", etc.)parameters.credentials: can be either:a string that is resolved from environment variables (recommended), or
a direct credential string/dict
parameters.model_kwargs: passed to the invoker builder (provider-specific fields +default_hyperparameters)
Example (switch model + tune hyperparameters):
Blocking behavior: configure denial phrases
This engine decides “unsafe” by checking whether the NeMo output contains any configured denial_phrases substrings.
Recommended defaults for the built-in Colang flows:
Custom guardrails with Colang
If you already have your own NeMo Guardrails configuration, you can provide:
colang_config(string), and/orconfig_dict(models + rails config)
Last updated