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

# Python SDK

> One Python API for the full AI robotics loop.

## Design goals

* One simple Python API for AI robotics workloads.
* Three methods per robot: `observe()`, `act()`, `reset()`.
* Simulation and collection are first-class SDK surfaces.
* Every saved model is self-describing — load and deploy with zero context.
* HuggingFace Hub native — push and pull policies like datasets.

## Install

```bash theme={null}
uv pip install rfx-sdk
```

Or add to a project:

```bash theme={null}
uv add rfx-sdk
```

## Quick start

```python theme={null}
import rfx

robot = rfx.MockRobot(state_dim=12, action_dim=6)
obs = robot.observe()

rfx.deploy("runs/my-policy", robot="so101")
```

## Robot interface

Every robot implements three methods:

```python theme={null}
obs = robot.observe()   # {"state": Tensor(1, N), "images": ...}
robot.act(action)       # Tensor(1, N)
robot.reset()
```

Built-in robots:

```python theme={null}
robot = rfx.SimRobot.from_config("so101.yaml", backend="genesis", viewer=True)
robot = rfx.MockRobot(state_dim=12, action_dim=6)
robot = rfx.RealRobot(rfx.SO101_CONFIG)
```

See the [robot interface page](/concepts/robot-interface) for the full
contract.

## Collection

```python theme={null}
dataset = rfx.collection.collect(
    "so101",
    "my-org/demos",
    episodes=2,
    duration_s=10,
)
```

## Package layout

```text theme={null}
rfx/python/rfx/
├── robot/          # Robot protocol, config, URDF
├── collection/     # Collection and dataset contracts
├── real/           # Real hardware backends (SO-101, Go2, G1)
├── sim/            # Simulation backends (MuJoCo, Genesis, mock)
├── runtime/        # Lifecycle, CLI, health, runtime helpers
├── hub.py          # Model save/load/push (HuggingFace Hub)
├── session.py      # Rate-controlled control loop
├── deploy.py       # rfx.deploy() implementation
├── decorators.py   # @policy, MotorCommands
├── node.py         # Zenoh transport factory & discovery
└── observation.py  # Observation spec & padding
```

## Reference

<CardGroup cols={2}>
  <Card title="Deploy API" icon="rocket" href="/sdk/deploy">
    `rfx.deploy()` signature and return value.
  </Card>

  <Card title="Policies" icon="code" href="/sdk/policies">
    `@rfx.policy` and the policy callable contract.
  </Card>

  <Card title="MotorCommands" icon="sliders" href="/sdk/motor-commands">
    Named joint control without hardcoded indices.
  </Card>

  <Card title="Model management" icon="box" href="/sdk/model-management">
    Save, load, inspect, and push policies.
  </Card>

  <Card title="Hardware configs" icon="microchip" href="/sdk/hardware-configs">
    Built-in robot configs: SO-101, Go2, G1.
  </Card>
</CardGroup>
