> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/NVIDIA-NeMo/Guardrails/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration Overview

> Learn how to configure NeMo Guardrails for your LLM applications

NeMo Guardrails uses a structured configuration approach to define guardrails for your LLM applications. A guardrails configuration defines the LLM(s) to be used, the rails that should be active, and custom settings.

## Configuration Structure

The standard structure for a guardrails configuration folder looks like this:

```
.
├── config
│   ├── actions.py
│   ├── config.py
│   ├── config.yml
│   ├── rails.co
│   ├── ...
```

### Main Configuration Files

A complete guardrails configuration typically consists of three main components:

<CardGroup cols={3}>
  <Card title="config.yml" icon="gear" href="/configuration/config-yaml">
    General configuration options including LLM models, active rails, and custom settings
  </Card>

  <Card title=".co files" icon="file-code" href="/configuration/rails-definition">
    Colang definitions that define various types of rails and conversation flows
  </Card>

  <Card title="actions.py" icon="code" href="/configuration/custom-actions">
    Custom Python actions that can be called from your guardrails
  </Card>
</CardGroup>

## Configuration Loading

To use a guardrails configuration in your application:

```python theme={null}
from nemoguardrails import LLMRails, RailsConfig

# Load a guardrails configuration from the specified path
config = RailsConfig.from_path("PATH/TO/CONFIG")
rails = LLMRails(config)

completion = rails.generate(
    messages=[{"role": "user", "content": "Hello world!"}]
)
```

**Sample output:**

```json theme={null}
{"role": "assistant", "content": "Hi! How can I help you?"}
```

## Types of Guardrails

NeMo Guardrails supports five main types of guardrails that can be configured:

<Steps>
  <Step title="Input Rails">
    Applied to user input; can reject or alter input (e.g., mask sensitive data, rephrase)

    ```yaml theme={null}
    rails:
      input:
        flows:
          - check jailbreak
          - mask sensitive data on input
    ```
  </Step>

  <Step title="Dialog Rails">
    Influence how the LLM is prompted; operate on canonical form messages and determine conversation flow

    ```yaml theme={null}
    rails:
      dialog:
        single_call:
          enabled: False
    ```
  </Step>

  <Step title="Retrieval Rails">
    Applied to retrieved chunks in RAG scenarios; can reject or alter chunks

    ```yaml theme={null}
    rails:
      retrieval:
        flows:
          - check relevance
    ```
  </Step>

  <Step title="Execution Rails">
    Applied to input/output of custom actions (tools) called by the LLM
  </Step>

  <Step title="Output Rails">
    Applied to LLM output; can reject or alter output before returning to user

    ```yaml theme={null}
    rails:
      output:
        flows:
          - self check facts
          - self check hallucination
    ```
  </Step>
</Steps>

## Basic Configuration Example

Here's a minimal example from `examples/configs/sample/config.yml`:

```yaml theme={null}
instructions:
  - type: general
    content: |
      Below is a conversation between a bot and a user. The bot is talkative and
      quirky. If the bot does not know the answer to a question, it truthfully says it does not know.

sample_conversation: |
  user "Hello there!"
    express greeting
  bot express greeting
    "Hello! How can I assist you today?"
  user "What can you do for me?"
    ask about capabilities
  bot respond about capabilities
    "I am an AI assistant built to help you."

models:
  - type: main
    engine: openai
    model: gpt-3.5-turbo-instruct

rails:
  input:
    flows:
      - dummy input rail

  output:
    flows:
      - dummy output rail
```

## Next Steps

<CardGroup cols={2}>
  <Card title="config.yml Schema" icon="file-lines" href="/configuration/config-yaml">
    Learn about all available configuration options
  </Card>

  <Card title="Rails Definition" icon="shield" href="/configuration/rails-definition">
    Define custom rails using Colang
  </Card>

  <Card title="Custom Actions" icon="bolt" href="/configuration/custom-actions">
    Create Python actions for your guardrails
  </Card>

  <Card title="LLM Configuration" icon="brain" href="/configuration/llm-configuration">
    Configure different LLM providers
  </Card>
</CardGroup>
