Skip to main content

Command

Start a NeMo Guardrails server that provides an OpenAI-compatible API with guardrails.

Options

integer
default:"8000"
The port that the server should listen on.
path
Path to a directory containing multiple configuration sub-folders (multi-config mode) or a single configuration directory (single-config mode).If not specified, looks for a config folder in the current directory.
string
The default configuration ID to use when no config is specified in requests.
boolean
default:"false"
If the server should be verbose and output detailed logs including prompts.
boolean
default:"false"
Whether the Chat UI should be disabled. When enabled (default), the UI is accessible at http://localhost:<port>/.
boolean
default:"false"
Enable automatic reloading when configuration files change. Requires the watchdog package.
string
default:""
A prefix that should be added to all server paths. Must start with ’/’. Useful for deploying behind a reverse proxy.

Examples

Basic Usage

Start server with default settings:
This looks for a config directory in the current folder.

Specify Config Directory

Start server with a specific config directory:

Multi-Config Mode

Serve multiple guardrails configurations:
Directory structure:

Single-Config Mode

Serve a single configuration:
Directory structure:

Custom Port

Start server on a different port:

Verbose Mode

Enable detailed logging:

Auto-Reload

Automatically reload configs when files change:
Requires watchdog:

Disable Chat UI

Disable the built-in web interface:

With Path Prefix

Deploy behind a reverse proxy with a path prefix:
API endpoints will be available at:
  • http://localhost:8000/api/guardrails/v1/chat/completions
  • http://localhost:8000/api/guardrails/v1/rails/configs

Set Default Config

Set a default configuration for requests that don’t specify one:

Environment Variables

The server respects several environment variables:

CORS Configuration

Model Provider

Default Config

Testing the Server

Check Server Status

List Available Configs

List Available Models

Test Chat Completion

Using with OpenAI SDK

Production Deployment

Using Gunicorn

Using Docker

Dockerfile
Build and run:

Using Docker Compose

docker-compose.yml

Troubleshooting

Server Won’t Start

Check if port is already in use:
Try a different port:

Config Not Found

Verify config path:
Each config directory must contain a config.yml or config.yaml file.

Module Not Found

Make sure you have the server dependencies:

CORS Issues

Enable CORS if accessing from a web app: