Run the Guardrails Server
The NeMo Guardrails server loads configurations from a local directory at startup and exposes an HTTP API to use them. The server uses FastAPI and includes a built-in Chat UI for testing.
Start the Server
Launch the server using the nemoguardrails CLI:
For more information about the available options, see CLI: Server.
Link Guardrail Configurations to the Server
The server supports two modes depending on your folder structure: multi-config mode and single-config mode.
Multi-Config Mode
When the --config path points to a folder containing multiple sub-folders, each sub-folder with a config.yml file becomes an available configuration.
The sub-folder name becomes the config_id.
-
Start the server in multi-config mode:
-
List available configurations.
The endpoint returns the list of available configurations.
Single-Config Mode
When the --config path points directly to a folder containing a config.yml file, the server runs in single-config mode.
The folder name becomes the only available config_id.
-
Start the server in single-config mode:
-
List available configurations.
The endpoint returns the single configuration named
content_safety.
Examples
The following examples show how to start the server with different options.
Start with Default Settings
The following command starts the server with default settings.
The server starts on port 8000 and looks for a ./config folder in the current directory. If not found, it uses the built-in example configurations.
Start with Custom Port
You can use the --port flag to start the server on a custom port.
Start with a Default Configuration
Use the following command to start the server with a default configuration within a multi-config folder. For example, when you use the provided example configurations (examples/configs), you can set the default configuration to content_safety as follows.
Chat completions requests without a config_id use the content_safety configuration by default.
Start in Development Mode
You can add the --auto-reload flag to the server to automatically reload when configuration files change.
Use --auto-reload only in development environments. It is not recommended for production.
Model Provider Configuration
When the model field is specified in a chat completion request, the server uses environment variables to determine which LLM provider and endpoint to use.
Set the appropriate API key for your provider:
CORS Configuration
To enable your guardrails server to receive requests from browser-based applications, configure CORS using environment variables:
Example:
Chat UI
The server includes a built-in Chat UI for testing guardrails configurations.
Access it at http://localhost:8000/ after starting the server.
The Chat UI is for internal testing only.
For production deployments, disable it using the --disable-chat-ui flag.