NeMo Guardrailsnemoguardrails 0.24.0 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
35 small wins to finish your pathNext lesson

Installation and setup

Installing NeMo Guardrails does not choose a model. The model is a few lines of config.yml, and a free Groq or Gemini key fits there.

pip install nemoguardrails 0.24.0

The package brings a runtime, a parser for the Colang configuration language and an embedding index, but no model client.

pip install "nemoguardrails==0.24.0"
Example
from importlib.metadata import version

print(version("nemoguardrails"))

A model entry in config.ymlOptional

This course registers a stand-in chat model in lessons 5 and 6 and a stand-in embedding model in lesson 10, so it runs without a key. For a hosted model, the docs point any OpenAI-compatible provider, Groq and OpenRouter among them, at the openai engine with a base_url. Engines whose API is not OpenAI-compatible, such as anthropic and vertexai, need a LangChain package and NEMOGUARDRAILS_LLM_FRAMEWORK=langchain.

yaml
models:
  - type: main
    engine: openai
    model: openai/gpt-oss-120b
    api_key_env_var: GROQ_API_KEY
    parameters:
      base_url: https://api.groq.com/openai/v1
ProviderKeyVariablebase_url and model
GroqFree, console.groq.com/keysGROQ_API_KEYhttps://api.groq.com/openai/v1, openai/gpt-oss-120b
GeminiFree, aistudio.google.com/apikeyGEMINI_API_KEYhttps://generativelanguage.googleapis.com/v1beta/openai/, gemini-2.5-flash
OpenRouterFree models end in :free, openrouter.ai/keysOPENROUTER_API_KEYhttps://openrouter.ai/api/v1, google/gemma-4-31b-it:free
OpenAIPaid, platform.openai.com/api-keysOPENAI_API_KEYLeave out base_url and api_key_env_var
export GROQ_API_KEY=gsk_...

The first time a message is matched to an intent with the real embedding model, it downloads, about ninety megabytes.

Try it yourself
  • Change model in the snippet to gemini-2.5-flash and work out the other two lines that must change with it.

Little by little, you're building something great.