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

# Deploy API

> rfx.deploy() — load a policy and run the control loop.

`rfx.deploy()` is the main entry point. It handles everything: load policy,
resolve robot config, create robot, run the control loop.

## Signature

```python theme={null}
stats = rfx.deploy(
    "runs/my-policy",       # path, hf:// URL, or .py file
    robot="so101",           # robot type or YAML path
    port="/dev/ttyACM0",     # optional hardware override
    rate_hz=50,              # control frequency
    duration=30,             # seconds (None = infinite)
    mock=False,              # use MockRobot instead
    device="cpu",            # torch device
)
```

## Parameters

| Parameter  | Type            | Default  | Description                                            |
| ---------- | --------------- | -------- | ------------------------------------------------------ |
| `policy`   | `str \| Path`   | required | Path to policy dir, `hf://org/repo`, or `.py` file.    |
| `robot`    | `str \| Path`   | auto     | Robot type (`so101`, `go2`, `g1`) or YAML config path. |
| `port`     | `str`           | auto     | Serial port or IP override.                            |
| `rate_hz`  | `float`         | config   | Control loop frequency. Defaults to robot config.      |
| `duration` | `float \| None` | `None`   | Run time in seconds. `None` runs until Ctrl+C.         |
| `mock`     | `bool`          | `False`  | Use `MockRobot` instead of real hardware.              |
| `device`   | `str`           | `"cpu"`  | Torch device for inference.                            |
| `warmup`   | `float`         | `0.5`    | Seconds to sleep after reset before starting.          |

## Return value

Returns a stats object with timing information:

```python theme={null}
stats.iterations      # total control loop steps
stats.overruns        # steps that missed their deadline
stats.p50_jitter_s    # median per-step jitter
stats.p95_jitter_s    # 95th percentile per-step jitter
```

## Auto-detection

If the policy artifact stored a robot config (via `policy.save(...,
robot_config=config)`), `robot` is inferred automatically. Explicit `robot`
or `config` overrides the stored value.

## Examples

<CodeGroup>
  ```python basic theme={null}
  rfx.deploy("runs/my-policy", robot="so101")
  ```

  ```python from hub theme={null}
  rfx.deploy("hf://user/policy", robot="go2", duration=30)
  ```

  ```python python file theme={null}
  rfx.deploy("my_policy.py", robot="so101")
  ```

  ```python mock theme={null}
  rfx.deploy("runs/my-policy", robot="so101", mock=True)
  ```
</CodeGroup>
