Skip to main content

Server Modes

The NeMo Guardrails server supports two modes:

Multi-Config Mode

In multi-config mode, the server can serve multiple guardrails configurations:
Directory structure:
Clients specify which config to use:

Single-Config Mode

In single-config mode, the server serves a single configuration:
Directory structure:
Clients don’t need to specify a config_id.

Server Options

Command-Line Options

integer
default:"8000"
The port that the server should listen on.
path
Path to a directory containing configuration sub-folders (multi-config mode) or a single configuration directory (single-config mode).
string
The default configuration to use when no config is specified in requests.
boolean
default:"false"
Enable verbose logging including prompts and LLM calls.
boolean
default:"false"
Disable the built-in chat UI.
boolean
default:"false"
Enable automatic reloading when configuration files change.
string
default:""
A prefix that should be added to all server paths (must start with ’/’).

Environment Variables

CORS Configuration

string
default:"false"
Enable Cross-Origin Resource Sharing (CORS).
string
default:"*"
Comma-separated list of allowed origins. Use ”*” to allow all origins.

Model Configuration

string
default:"openai"
The default LLM provider when model is specified in request.
string
Base URL for the LLM provider API.
string
Default configuration ID to use.

Server Configuration File

You can create a config.py file in your configs directory to customize server behavior:
config.py

API Endpoints

GET /v1/rails/configs

List available guardrails configurations.

GET /v1/models

List available LLM models from the configured provider.

POST /v1/chat/completions

See Chat Completions API for details.

Thread Management

The server supports conversation threads for maintaining state across requests.

Using Threads

Custom Datastore

By default, threads are stored in memory. You can configure a custom datastore:
config.py

Auto-Reload

Enable auto-reload to automatically reload configurations when files change:
Requires the watchdog package:
When enabled, the server monitors configuration files and reloads them automatically when changes are detected.

Chat UI

The server includes a built-in chat UI accessible at http://localhost:8000. To disable the chat UI:

Production Deployment

Using Gunicorn

Using Docker

Dockerfile

Environment Variables