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

# nemo_voice_agent.pipecat.bot_server

Shared bot-server runner.

Bots build their own services, RTVI processor, pipeline, and `PipelineWorker`;
this module handles the boilerplate that sits around the task — transport event
handlers, the RTVI `on_client_ready` kick-off, audio-logger finalization,
shutdown, and optional FastAPI `/connect` endpoint.

The runner makes no assumptions about pipeline contents: it only needs the
`task`, `ws_transport`, and `rtvi` the bot already constructed. Per-bot
customization (what to reset on disconnect, which initial frame to queue on
client-ready) is passed via keyword arguments.

## Module Contents

### Functions

| Name                                                                                        | Description                                                          |
| ------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| [`_reset_services`](#nemo_voice_agent-pipecat-bot_server-_reset_services)                   | -                                                                    |
| [`create_fastapi_app`](#nemo_voice_agent-pipecat-bot_server-create_fastapi_app)             | FastAPI app with CORS + `/connect` + a stub `/ws` endpoint.          |
| [`run_bot_websocket_server`](#nemo_voice_agent-pipecat-bot_server-run_bot_websocket_server) | Wire event handlers onto `ws_transport`/`rtvi` and run the pipeline. |
| [`run_bot_with_fastapi`](#nemo_voice_agent-pipecat-bot_server-run_bot_with_fastapi)         | Run the websocket server coroutine and uvicorn concurrently.         |

### Data

[`__all__`](#nemo_voice_agent-pipecat-bot_server-__all__)

### API

```python
nemo_voice_agent.pipecat.bot_server._reset_services(
    services: typing.Optional[typing.List[typing.Any]]
) -> None
```

```python
nemo_voice_agent.pipecat.bot_server.create_fastapi_app(
    websocket_port: int,
    public_host: str = '127.0.0.1',
    ws_scheme: str = 'ws'
) -> fastapi.FastAPI
```

FastAPI app with CORS + `/connect` + a stub `/ws` endpoint.

`/connect` returns the ws URL the pipecat client should dial. `/ws` is
kept as a placeholder mirroring the original bot scripts' unimplemented
FastAPI websocket path.

```python
nemo_voice_agent.pipecat.bot_server.run_bot_websocket_server(
    task: pipecat.pipeline.worker.PipelineWorker,
    ws_transport: pipecat.transports.websocket.server.SingleClientWebsocketServerTransport,
    rtvi: pipecat.processors.frameworks.rtvi.RTVIProcessor,
    task_ref: typing.Optional[nemo_voice_agent.pipecat.processors.frameworks.rtvi_actions.TaskRef] = None,
    audio_logger: typing.Optional[nemo_voice_agent.pipecat.services.nemo.audio_logger.AudioLogger] = None,
    talk_first: bool = True,
    initial_frame_factory: typing.Optional[typing.Callable[[], pipecat.frames.frames.Frame]] = None,
    on_disconnect_reset_services: typing.Optional[typing.List[typing.Any]] = None,
    on_disconnect_hook: typing.Optional[typing.Callable[[], typing.Awaitable[None]]] = None
) -> None
```

async

Wire event handlers onto `ws_transport`/`rtvi` and run the pipeline.

**Parameters:**

**`task`**

Fully constructed `PipelineWorker` with observers already attached.

---

**`ws_transport`**

Transport the task's pipeline uses for I/O.

---

**`rtvi`**

RTVI processor embedded in the pipeline. Must already have any
actions the bot wants registered.

---

**`task_ref`**

Optional `TaskRef` passed to the RTVI handler factories.
Populated here so handlers can reach the live pipeline worker.

---

**`audio_logger`**

Audio logger to finalize on disconnect / shutdown.

---

**`talk_first`**

If True, queue `initial_frame_factory()` on client-ready.

---

**`initial_frame_factory`**

Callable returning the Frame to kick off with
(e.g. `lambda: LLMRunFrame()`). Invoked once per client-ready.

---

**`on_disconnect_reset_services`**

Services whose `.reset()` is called on
client disconnect. `None` entries are skipped.

---

**`on_disconnect_hook`**

Optional extra async cleanup called on disconnect
after the default reset logic.

---

```python
nemo_voice_agent.pipecat.bot_server.run_bot_with_fastapi(
    ws_coro: typing.Awaitable[None],
    app: fastapi.FastAPI,
    host: str,
    fastapi_port: int
) -> None
```

async

Run the websocket server coroutine and uvicorn concurrently.

```python
nemo_voice_agent.pipecat.bot_server.__all__ = ['run_bot_websocket_server', 'create_fastapi_app', 'run_bot_with_fastapi']
```