> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.
> For full documentation content, see https://docs.nvidia.com/nemo/guardrails/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# NeMo Guardrails Library Configuration Overview

> Learn to write config.yml, Colang flows, and custom actions for guardrails.

Before using the NeMo Guardrails library, you need to prepare configuration files that define your guardrails behavior. When you initialize the library's core classes or the `nemoguardrails` CLI chat or server, it will load these configuration files as shown in the next chapter [About Running Guardrailed Inference](/run-guardrailed-inference/run-rails). This section provides complete instructions on preparing your configuration files and executable scripts.

A guardrails configuration includes the following components. You can start with a basic configuration and add more components as needed. All the components should be placed in the `config` folder, and the locations in the following table are relative to the `config` folder.

| Component                    | Required/Optional | Description                                                                                                                                                                                                                            | Location                                       |
| ---------------------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
| **Core Configuration**       | Required          | A `config.yml` file that contains the core configuration options such as which LLM(s) to use, general instructions (similar to system prompts), sample conversation, which rails are active, and specific rails configuration options. | `config.yml`                                   |
| **Colang Flows**             | Optional          | A collection of Colang files (`.co` files) implementing the rails. Files are loaded recursively from anywhere in the config directory.                                                                                                 | Config root, `rails/` folder, or any subfolder |
| **Custom Prompts**           | Optional          | YAML file with custom prompts for guardrails tasks. Prompts can also be defined directly in `config.yml`.                                                                                                                              | `prompts.yml`                                  |
| **Custom Actions**           | Optional          | Python functions decorated with `@action()` that can be called from Colang flows during request processing (for example, external API calls, validation logic).                                                                        | `actions.py` or `actions/` folder              |
| **Custom Initialization**    | Optional          | Python code that runs once at startup to register custom LLM providers, embedding providers, or shared resources (for example, database connections).                                                                                  | `config.py`                                    |
| **Knowledge Base Documents** | Optional          | Documents (`.md` files) that can be used in a RAG (Retrieval-Augmented Generation) scenario (i.e. Retrieval rail) using the built-in Knowledge Base support.                                                                           | `kb` folder                                    |

***

## Example Configuration Folder Structures

The following are example configuration folder structures.

* Basic configuration

  ```text
  config/
  └── config.yml
  ```

* Configuration with Colang rails and custom actions

  ```text
  config/
  ├── config.yml
  ├── rails/
  │   ├── input.co
  │   ├── output.co
  │   └── ...
  └── actions.py          # Custom actions called from Colang flows
  ```

* Configuration with custom LLM provider registration

  ```text
  config/
  ├── config.yml
  ├── rails/
  │   └── ...
  ├── actions.py          # Custom actions
  └── config.py           # Registers custom LLM provider at startup
  ```

* Complete configuration with all components

  ```text
  config/
  ├── config.yml          # Core configuration
  ├── prompts.yml         # Custom prompts (optional, can also be in config.yml)
  ├── config.py           # Custom initialization (LLM providers, etc.)
  ├── rails/              # Colang flow files (can also be at config root)
  │   ├── input.co
  │   ├── output.co
  │   └── ...
  ├── actions/            # Custom actions (as a package)
  │   ├── __init__.py
  │   ├── validation.py
  │   ├── external_api.py
  │   └── ...
  └── kb/                 # Knowledge base documents
      ├── policies.md
      ├── faq.md
      └── ...
  ```

***

## Next Steps

For each component, refer to the following sections for more details:

* [Configuring YAML File](/configure-guardrails/yaml-schema) - A complete guide to writing your `config.yml` file.
* [Colang](/configure-guardrails/colang) - `.co` flow files in `rails` folder.
* [Custom Actions](/configure-guardrails/actions) - `actions.py` or `actions/` folder for callable actions.
* [Custom Initialization](/configure-guardrails/custom-initialization) - `config.py` for custom initialization.
* [Knowledge Base](/configure-guardrails/other-configurations/knowledge-base) - `kb/` folder for RAG.

After preparing your configuration files, you can use the NeMo Guardrails SDK to instantiate the core classes (`RailsConfig` and `LLMRails`) and run guardrails on your LLM applications.
For detailed SDK usage, including loading configurations, generating responses, streaming, and debugging, refer to [About Running Guardrailed Inference](/run-guardrailed-inference/run-rails).