Run the NeMo 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:

nemoguardrails server --config examples/configs

For more information about the available options, see server.

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.

nemoguardrails server

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.

nemoguardrails server --config examples/configs --port 8080

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.

nemoguardrails server --config examples/configs --default-config-id content_safety

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.

nemoguardrails server --config ./configs --auto-reload

Important

Use --auto-reload only in development environments. It is not recommended for production.

CORS Configuration#

To enable your guardrails server to receive requests from browser-based applications, configure CORS using environment variables:

Environment Variable

Description

NEMO_GUARDRAILS_SERVER_ENABLE_CORS

Set to true to enable CORS. Default: false.

NEMO_GUARDRAILS_SERVER_ALLOWED_ORIGINS

Comma-separated list of allowed origins. Default: *.

Example:

export NEMO_GUARDRAILS_SERVER_ENABLE_CORS=true
export NEMO_GUARDRAILS_SERVER_ALLOWED_ORIGINS=http://localhost:3000,https://myapp.com
nemoguardrails server --config ./configs

Chat UI#

The server includes a built-in Chat UI for testing guardrails configurations. Access it at http://localhost:8000/ after starting the server.

Important

The Chat UI is for internal testing only. For production deployments, disable it using the --disable-chat-ui flag.