> This page is for version 0.7.0.
> For other versions, use one of these documentation indexes:
> - Main (default): https://docs.nvidia.com/nemo/gym/main/llms.txt
> - 0.7.0: https://docs.nvidia.com/nemo/gym/v0.7.0/llms.txt
> - 0.6.0: https://docs.nvidia.com/nemo/gym/v0.6.0/llms.txt
> - 0.5.1: https://docs.nvidia.com/nemo/gym/v0.5.1/llms.txt
> - 0.5.0: https://docs.nvidia.com/nemo/gym/v0.5.0/llms.txt
> - 0.4.0: https://docs.nvidia.com/nemo/gym/v0.4.0/llms.txt
> - 0.3.0: https://docs.nvidia.com/nemo/gym/v0.3.0/llms.txt
> - 0.2.1: https://docs.nvidia.com/nemo/gym/v0.2.1/llms.txt

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

# nemo_gym.token_id_capture.control_routes

Expose rollout capture manifests and ledger removal over HTTP.

The training framework reads one manifest for each rollout.
The endpoint returns call metadata and does not read staged token data.
The framework builds receipts and removes staged data after use.
It then retires the rollout's ledger, which Gym cannot otherwise know is no longer needed.

## Module Contents

### Classes

| Name                                                                                     | Description                                                        |
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| [`LedgerBatchRequest`](#nemo_gym-token_id_capture-control_routes-LedgerBatchRequest)     | Body of the retire and delete routes.                              |
| [`RolloutControlClient`](#nemo_gym-token_id_capture-control_routes-RolloutControlClient) | Framework-side client for the manifest, retire, and delete routes. |

### Functions

| Name                                                                                                         | Description                                                       |
| ------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------- |
| [`install_rollout_control_routes`](#nemo_gym-token_id_capture-control_routes-install_rollout_control_routes) | Install the bearer-protected manifest, retire, and delete routes. |

### Data

[`CONTROL_ROUTE_PREFIX`](#nemo_gym-token_id_capture-control_routes-CONTROL_ROUTE_PREFIX)

[`MAX_LEDGER_BATCH`](#nemo_gym-token_id_capture-control_routes-MAX_LEDGER_BATCH)

### API

```python
class nemo_gym.token_id_capture.control_routes.LedgerBatchRequest()
```

**Bases:** `BaseModel`

Body of the retire and delete routes.

**`model_config`** `= ConfigDict(extra='forbid')`

---

**`rollout_ids`** `list[str] = Field(min_length=1, max_length=MAX_LEDGER_BATCH)`

---

```python
class nemo_gym.token_id_capture.control_routes.RolloutControlClient(
    base_url: str,
    auth_token: str,
    request_timeout_s: float
)
```

Framework-side client for the manifest, retire, and delete routes.

**`_base_url`** `= base_url.rstrip('/')`

---

**`_headers`** `= {'Authorization': f'Bearer {auth_token}'}`

---

```python
nemo_gym.token_id_capture.control_routes.RolloutControlClient._remove(
    action: str,
    rollout_ids: collections.abc.Sequence[str]
) -> nemo_gym.token_id_capture.staging.records.RolloutRemoval
```

async

```python
nemo_gym.token_id_capture.control_routes.RolloutControlClient._request(
    method: str,
    path: str,
    kwargs: typing.Any = {}
)
```

async

```python
nemo_gym.token_id_capture.control_routes.RolloutControlClient.delete(
    rollout_ids: collections.abc.Sequence[str]
) -> nemo_gym.token_id_capture.staging.records.RolloutRemoval
```

async

Delete ledgers and their fences; see `CaptureLedger.delete`. Retrying after a failure is safe.

```python
nemo_gym.token_id_capture.control_routes.RolloutControlClient.manifest(
    rollout_id: str
) -> nemo_gym.token_id_capture.staging.records.RolloutManifest
```

async

Fetch a rollout's manifest. A retired rollout raises `RolloutRetiredError`.

```python
nemo_gym.token_id_capture.control_routes.RolloutControlClient.retire(
    rollout_ids: collections.abc.Sequence[str]
) -> nemo_gym.token_id_capture.staging.records.RolloutRemoval
```

async

Retire ledgers; see `CaptureLedger.retire`. Retrying after a failure is safe.

```python
nemo_gym.token_id_capture.control_routes.install_rollout_control_routes(
    app: typing.Any,
    lineage_store: nemo_gym.token_id_capture.protocols.CaptureLedger,
    auth_token: str,
    refuse_removal: collections.abc.Callable[[], str | None] | None = None
) -> None
```

Install the bearer-protected manifest, retire, and delete routes.

`refuse_removal` returns a reason to refuse retire and delete for now, with 409; the caller retries later.

```python
nemo_gym.token_id_capture.control_routes.CONTROL_ROUTE_PREFIX = '/training-token-capture/control'
```

```python
nemo_gym.token_id_capture.control_routes.MAX_LEDGER_BATCH = 4096
```