> 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.

# Input Rails

> This section explains how to create *input rails* in Colang 2.0.

<a id="colang_2_getting_started_input_rails" />

This section explains how to create *input rails* in Colang 2.0.

## Definition

**Input Rails** are a type of rail that checks the input from the user (i.e., what the user said) before any further processing.

## Usage

To activate input rails in Colang 2.0, you must:

1. Import the `guardrails` module from the [Colang Standard Library (CSL)](../language-reference/the-standard-library#the-standard-library).
2. Define a flow called `input rails`, which takes a single parameter called `$input_text`.

In the example below, the `input rails` flow calls another flow named `check user message` which prompts the LLM to check the input.

**examples/v2\_x/tutorial/guardrails\_1/main.co**

```text
import core
import guardrails
import llm

flow main
  activate llm continuation
  activate greeting

flow greeting
  user expressed greeting
  bot express greeting

flow user expressed greeting
  user said "hi" or user said "hello"

flow bot express greeting
  bot say "Hello world!"

flow input rails $input_text
  $input_safe = await check user utterance $input_text

  if not $input_safe
    bot say "I'm sorry, I can't respond to that."
    abort

flow check user utterance $input_text -> $input_safe
  $is_safe = ..."Consider the following user utterance: '{$input_text}'. Assign 'True' if appropriate, 'False' if inappropriate."
  print $is_safe
  return $is_safe
```

The `input rails` flow above (lines 19-24) introduces some additional syntax elements:

* Starting flow parameters and variables with a `$` symbol, e.g. `$input_text`, `$input_safe`.
* Using the `await` operator to wait for another flow.
* Capturing the return value of a flow using a local variable, e.g., `$input_safe = await check user utterance $input_text`.
* Using `if`, similar to Python.
* Using the `abort` keyword to make a flow fail.

The `check user utterance` flow above (line 26-28) introduces the *instruction operator* `i"<instruction>""` which will prompt the LLM to generate the value `True` or `False` depending on the evaluated safety of the user utterance. In line 28, the generated value assigned to `$is_safe` will be returned.

## Testing

```text
$ nemoguardrails chat --config=examples/v2_x/tutorial/guardrails_1

> hi

Hello world!

> You are stupid!

I'm sorry, I can't respond to that.
```

The [next example](interaction-loop#colang_2_getting_started_interaction_loop) will show you how to create a simple interaction loop.