Configuration Structure
A guardrail configuration contains several properties that customize how the service interacts with models and applies safety checks. This page describes the core components (models, prompts, and rails) as well as advanced options for tracing, passthrough, and other behaviors.
Models
A model configuration defines the LLM to use for a specific task. It consists of the following fields:
type: The task the model is used for (for example,content_safetyorself_check_input).engine: The model provider. For most cases, usenim.model: The name of the model to use for the task, inworkspace/nameformat (for example,default/nvidia-llama-3-1-nemotron-safety-guard-8b-v3).mode: The completion mode. Allowed values are"chat"(default) or"text".cache: Cache configuration for this model. Primarily used for content safety models to cache repeated checks. Containsenabled(default:false),maxsize(default:50000), andstatssub-fields.parameters: Additional properties to configure interacting with the model. The following fields are supported for all model types:base_url: The URL to use for inference with this model. When using models deployed through the Inference Gateway, NeMo Guardrails automatically resolves the URL through IGW’s route table. You do not need to explicitly set a Base URL for your model.default_headers: Custom HTTP headers to include in requests to this model. Each key-value pair represents a header name (key) and its default value (value).
Under the IGW plugin architecture, the main model is owned by IGW and specified through the VirtualModel’s default_model_entity. Guardrail configurations should omit the type: "main" model entry — the plugin injects the per-request main model at runtime, and self-check rails reuse that per-request main model for evaluation.
Include a type: "main" entry only when you need to pin the engine or parameters used to talk to the main model — for example, a non-NIM engine, a custom parameters.base_url, or static parameters.default_headers. The model field on a main entry is treated as a template; the actual model name always comes from the inference request body.
You can configure task-specific models for any task that occurs during the guardrail process. type is a free-form label — rails reference it via $model=<type> — so you can declare custom task types in addition to the common ones below (for example, a vision_rails model used in Adding Safety Checks to Multimodal Data):
content_safety: Content Safety check for detecting harmful content.topic_control: Topic Control check for keeping conversations on-topic.jailbreak: Jailbreak detection check.self_check_input: Safety check that automatically checks the user input using themainmodel for inference.self_check_output: Safety check that automatically checks the final LLM output using themainmodel for inference.
Model Entities are automatically created when you:
- Create a Model Provider pointing to an external API (refer to Add External Providers)
Use client.models.list() to retrieve available Model Entities in your workspace.
Using Direct URLs
Using Inference Gateway is the recommended approach for interacting with models. If you require a direct connection to specific endpoints, you can explicitly set parameters.base_url:
Prompts
A prompt is used by the model during a task to evaluate a message. It consists of the following fields:
task: The task to apply the prompt to.content: The content of the prompt. Mutually exclusive withmessages.- Prompts that require a dynamic input variable(s) use Jinja2 templating. For example, the
{{ user_input }}variable is replaced with the end user’s input at runtime.
- Prompts that require a dynamic input variable(s) use Jinja2 templating. For example, the
messages: A list of messages for chat-model prompts. Mutually exclusive withcontent. Each message hastype(such as"system"or"user") andcontentfields.output_parser: Name of output parser to process the model’s response.max_tokens: Maximum number of tokens the model can generate.max_length: Maximum prompt length in characters. When the maximum length is exceeded, the prompt is truncated by removing older turns from the conversation history until the length of the prompt is less than or equal to the maximum length. The default is 16,000 characters.models: Restricts this prompt to specific LLM engines or models. Format: a list of strings such as"<engine>"or"<engine>/<model>".mode: The prompting mode for this prompt. Defaults to the top-levelprompting_modevalue (typically"standard").stop: A list of stop tokens for models that support this feature.
Self-check prompts with reasoning models
Self-check rails use the main model and expect it to answer Yes to block or No to allow. Reasoning models may use part of the completion budget for reasoning before they emit the final verdict. By default, self-check requests set max_tokens: 3, which can stop a reasoning model before it reaches Yes or No. A truncated or unparseable self-check answer will block the message. For production safety checks, prefer content-safety rails with a dedicated safety model. If you use self-check rails, prefer a non-reasoning main model when available.
If you must use a reasoning model for self_check_input or self_check_output, set max_tokens high enough for both the model’s reasoning and the final Yes or No verdict:
For Content Safety and Topic Control checks, prompts must include the model reference in the task name:
Prompt Template Variables
The following dynamic variables can be used in the prompt content:
Rails
Rails specify which flows to apply to the user input and LLM output. The rails object accepts the following top-level keys, each triggered at a different point in the request lifecycle:
Each rail key supports a flows list and, optionally, a parallel flag to execute those flows concurrently.
The following example defines the flow to run as an input and output rail.
Output Rails Streaming
Output rails support a streaming configuration for processing LLM tokens in chunks:
enabled: Enables streaming mode (default:false).chunk_size: Number of tokens per processing chunk (default:200).context_size: Number of tokens carried from the previous chunk for continuity (default:50).stream_first: Iftrue, token chunks are streamed before output rails are applied (default:true).
Rails-Specific Configuration
Specific rails can require additional configuration that you specify in the config key. The following integrations are supported:
jailbreak_detection— Threshold-based jailbreak detection.injection_detection— Prompt injection detection.
General Instructions
Instructions provide context to the model about expected behavior. They are appended to the beginning of every prompt (similar to a system prompt).
Sample Conversation
The sample conversation sets the tone for conversations between the user and the bot. It helps the LLM learn the format, tone, and verbosity of responses. Include a minimum of two turns. The sample conversation is appended to every prompt; keep it short and relevant.
Advanced Options
The guardrail configuration supports additional top-level fields for fine-tuning behavior. All fields below are optional and have sensible defaults.
Enabling tracing.enable_content_capture causes prompts and responses (including user, assistant, and tool message content) to be included in telemetry events. This can expose PII and sensitive data in your telemetry backend.
Next Steps
- Refer to Manage Configurations to create, update, and manage your guardrail configurations.