> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# connect

> Connect to a remote robot via the signaling server

```python theme={null}
from grid_nexus_client import connect
```

```python Signature theme={null}
connect(
    robot_id: str,
    program=None,
    debug: bool | None = None,
    *,
    zenoh_config: str | os.PathLike[str] | Mapping[str, object] | None = None,
    enable_monitor_ws: bool | None = None,
    timeout: float | None = DEFAULT_CONNECT_TIMEOUT_SECS,
) -> RemoteRobot | RemoteDeployment
```

Connect to a remote robot via the signaling server.

Returns a `RemoteRobot` for direct command dispatch, or a
`RemoteDeployment` if a `program` is provided (staged execution mode).

The signaling URL resolves from the selected `GRID_TARGET_ENV` profile.
In dev, client-side signaling uses the local desktop ports.

Streaming is inferred from the mode: off for direct/dev mode, on for
staged/deploy mode. Disconnects and re-raises on any connection failure.

`enable_monitor_ws` controls the in-process Rust websocket snapshot
broadcaster that serves the monitor on `127.0.0.1:8765`.

`zenoh_config` connects directly to an existing TUI-owned dev session
without opening a signaling websocket. It is supported only for direct/dev
mode, not when `program` is provided. Pass either a path to the TUI
session config file or a mapping with the same fields. When omitted, an
active dev session for `robot_id` (the config the GRID CLI writes on
`robot connect` / `session start robot`) is discovered automatically;
with no active dev session the signaling path is used.

When `debug` is omitted, it is enabled for staged/deploy connections
where `program` is provided and disabled for direct/dev connections.
It controls only cloud model debug-image streaming; pass `debug=False`
to disable those streams for a deployment. Native Rust/zenoh log verbosity
is controlled separately through `RUST_LOG` and defaults to warnings.

For `enable_monitor_ws`:

* `None` (default): best-effort. Start if possible, log and continue on
  failure (e.g. port already taken by another `connect()`).
* `True`: required. Propagate any failure so the caller knows.
* `False`: skip entirely.

Setting `GRID_NEXUS_CLIENT_DISABLE_MONITOR_WS=1` in the environment
behaves like `enable_monitor_ws=False` when the kwarg is left as
`None`.


## Related topics

- [CortexHubClient](/python-api/grid-cortex-client/cortexhubclient.md)
- [Get started](/get-started/installation.md)
- [Your first skill](/get-started/first-skill.md)
- [Your first session](/get-started/first-session.md)
- [The Intelligence Grid for Physical AI](/introduction.md)
