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

# nemoguardrails.cli.chat

## Module Contents

### Classes

| Name                                              | Description |
| ------------------------------------------------- | ----------- |
| [`ChatState`](#nemoguardrails-cli-chat-ChatState) | -           |

### Functions

| Name                                                                                | Description                                              |
| ----------------------------------------------------------------------------------- | -------------------------------------------------------- |
| [`_run_chat_v1_0`](#nemoguardrails-cli-chat-_run_chat_v1_0)                         | Asynchronously run a chat session in the terminal.       |
| [`_run_chat_v2_x`](#nemoguardrails-cli-chat-_run_chat_v2_x)                         | Simple chat loop for v2.x using the stateful events API. |
| [`extract_scene_text_content`](#nemoguardrails-cli-chat-extract_scene_text_content) | Extract the text content of a scene event as a string.   |
| [`parse_events_inputs`](#nemoguardrails-cli-chat-parse_events_inputs)               | Parses a event string and creates an event dictionary.   |
| [`run_chat`](#nemoguardrails-cli-chat-run_chat)                                     | Run a chat session in the terminal.                      |

### Data

[`enable_input`](#nemoguardrails-cli-chat-enable_input)

### API

```python
class nemoguardrails.cli.chat.ChatState(
    state: typing.Optional[nemoguardrails.colang.v2_x.runtime.flows.State] = None,
    waiting_user_input: bool = False,
    paused: bool = False,
    running_timer_tasks: typing.Dict[str, asyncio.Task] = dict(),
    input_events: typing.List[dict] = list(),
    output_events: typing.List[dict] = list(),
    output_state: typing.Optional[nemoguardrails.colang.v2_x.runtime.flows.State] = None,
    session: prompt_toolkit.PromptSession = PromptSession(),
    first_time: bool = False
)
```

Dataclass

```python
nemoguardrails.cli.chat._run_chat_v1_0(
    config_path: typing.Optional[str] = None,
    verbose: bool = False,
    streaming: bool = False,
    server_url: typing.Optional[str] = None,
    config_id: typing.Optional[str] = None
)
```

async

Asynchronously run a chat session in the terminal.

**Parameters:**

The path to the configuration file. Defaults to None.

Whether to run in verbose mode. Defaults to False.

Whether to enable streaming mode. Defaults to False.

The URL of the chat server. Defaults to None.

The configuration ID. Defaults to None.

```python
nemoguardrails.cli.chat._run_chat_v2_x(
    rails_app: nemoguardrails.LLMRails
)
```

async

Simple chat loop for v2.x using the stateful events API.

```python
nemoguardrails.cli.chat.extract_scene_text_content(
    content_list: typing.List[dict]
) -> str
```

Extract the text content of a scene event as a string.

```python
nemoguardrails.cli.chat.parse_events_inputs(
    input_str: str
) -> typing.Optional[dict]
```

Parses a event string and creates an event dictionary.

```python
nemoguardrails.cli.chat.run_chat(
    config_path: typing.Optional[str] = None,
    verbose: bool = False,
    verbose_llm_calls: bool = False,
    streaming: bool = False,
    server_url: typing.Optional[str] = None,
    config_id: typing.Optional[str] = None
)
```

Run a chat session in the terminal.

**Parameters:**

The path to the configuration file. Defaults to None.

Whether to run in verbose mode. Defaults to False.

Whether to print the prompts and the completions. Defaults to False.

Whether to enable streaming mode. Defaults to False.

The URL of the chat server. Defaults to None.

The configuration ID. Defaults to None.

```python
nemoguardrails.cli.chat.enable_input = asyncio.Event()
```