> This page is for NeMo Relay, version v1.0.0.
> For other versions, use one of these documentation indexes:
> - Latest (v0.11.2) (default): https://docs.nvidia.com/nemo/relay/latest/llms.txt
> - dev: https://docs.nvidia.com/nemo/relay/dev/llms.txt
> - v1.0.0: https://docs.nvidia.com/nemo/relay/v1.0.0/llms.txt
> - v0.11.2: https://docs.nvidia.com/nemo/relay/v0.11.2/llms.txt
> - v0.10.4: https://docs.nvidia.com/nemo/relay/v0.10.4/llms.txt
> - v0.9.4: https://docs.nvidia.com/nemo/relay/v0.9.4/llms.txt
> - v0.8.4: https://docs.nvidia.com/nemo/relay/v0.8.4/llms.txt

> For clean Markdown of any page, append .md to the page URL. For a task-oriented documentation index, fetch https://docs.nvidia.com/nemo/relay/llms.txt. Use the documentation version matching the installed NeMo Relay package: latest follows the latest stable release, vX.Y.Z identifies a retained release snapshot, and dev documents development changes. Preserve the selected version when following links; do not mix examples or API contracts from different versions. Fetch the relevant section's /llms.txt before individual pages instead of loading a complete version index.

# Struct Adaptive Runtime

> Hosted adaptive runtime that registers NeMo Relay plugin components.

Generated from `cargo doc --no-deps -p nemo-relay-builtins -p nemo-relay-diagnostics -p nemo-relay-logging -p nemo-relay-plugin-host -p nemo-relay-codecs -p nemo-relay -p nemo-relay-runtime -p nemo-relay-model-pricing -p nemo-relay-resource-metrics -p nemo-relay-observability -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker`.

```rust
pub struct AdaptiveRuntime { /* private fields */ }
```

Hosted adaptive runtime that registers NeMo Relay plugin components.

This type validates configuration, builds the configured storage backend, registers intercepts and subscribers, and maintains the hot cache used by adaptive features on the request path.

## Implementations

### `impl AdaptiveRuntime`

<pre />

#### `new`

<pre />

Create a new adaptive runtime from configuration.

##### Parameters

* `config`: Adaptive runtime configuration to validate and apply.

##### Returns

A [`Result`](/reference/api/rust-library-reference/nemo-relay-adaptive/error/type-result) containing a new [`AdaptiveRuntime`](/reference/api/rust-library-reference/nemo-relay-adaptive/struct-adaptiveruntime).

##### Errors

Returns [`AdaptiveError::InvalidConfig`](/reference/api/rust-library-reference/nemo-relay-adaptive/error/enum-adaptiveerror) when validation reports errors, or any backend-construction error produced while building the configured state backend.

#### `validate_config`

<pre />

Validate an adaptive runtime configuration without constructing a runtime.

##### Parameters

* `config`: Configuration to validate.

##### Returns

A [`ConfigReport`](/reference/api/rust-library-reference/nemo-relay-plugin-host/struct-configreport) containing validation diagnostics.

#### `validate_document`

<pre />

Parse and validate an adaptive config document from a binding or FFI caller.

Unlike deserializing into [`AdaptiveConfig`](/reference/api/rust-library-reference/nemo-relay-adaptive/config/struct-adaptiveconfig) directly, this reports the former `response_cache` section as the `adaptive.response_cache_moved` error instead of silently dropping it.

##### Errors

Returns the deserialization error when the document is not an adaptive config.

#### `report`

<pre />

Return the configuration report captured during construction.

##### Returns

The [`ConfigReport`](/reference/api/rust-library-reference/nemo-relay-plugin-host/struct-configreport) associated with this runtime.

#### `wait_for_idle`

<pre />

Block until the telemetry drain has processed all pending events.

##### Notes

This method performs a simple polling wait and is intended for tests, shutdown paths, or other coordination points.

#### `build_cache_request_facts`

<pre />

Build cache-diagnostics facts for an annotated request.

##### Parameters

* `agent_id`: Agent identifier associated with the request.
* `provider`: Logical provider name associated with the request.
* `annotated_request`: Annotated request to analyze.

##### Returns

`Some(CacheRequestFacts)` when enough hot-cache state is available to derive them and `None` otherwise.

#### `bind_scope`

<pre />

Bind the runtime's ACG request rewrite to an active scope.

External framework integrations can bind the runtime to a session scope and then invoke `nemo_relay.llm.request_intercepts(...)` explicitly at the provider boundary. Once any scope is bound, this runtime's hosted ACG execution intercept becomes pass-through so external frameworks do not double-translate requests.

##### Errors

Returns an error when the runtime is not yet registered, when ACG is not configured for this runtime, or when the scope-local request intercept cannot be constructed or registered.

#### `register`

<pre />

Register all configured adaptive features with the shared runtime.

##### Returns

A [`Result`](/reference/api/rust-library-reference/nemo-relay-adaptive/error/type-result) that is `Ok(())` when registration succeeds.

##### Errors

Returns any error raised while seeding state or registering features.

#### `deregister`

<pre />

Deregister all previously registered adaptive features.

##### Returns

A [`Result`](/reference/api/rust-library-reference/nemo-relay-adaptive/error/type-result) that is `Ok(())` after registrations have been rolled back.

##### Errors

Returns any rollback error surfaced by the hosted plugin system.

##### Runtime lifecycle

This method returns before the telemetry drain finishes. Callers using a Tokio `current_thread` runtime must keep that runtime alive and driven until the drain completes. Call [`Self::shutdown`](/reference/api/rust-library-reference/nemo-relay-adaptive/struct-adaptiveruntime) when completion must be observed before the runtime is dropped.

#### `shutdown`

<pre />

Deregister the runtime and consume it.

##### Returns

A [`Result`](/reference/api/rust-library-reference/nemo-relay-adaptive/error/type-result) that is `Ok(())` when shutdown completes.

##### Errors

This method currently always returns `Ok(())` after deregistering features and either draining or aborting telemetry work.

## Trait Implementations

### `impl Debug for AdaptiveRuntime`

<pre />

#### `fmt`

<pre />

### `impl Drop for AdaptiveRuntime`

<pre />

#### `drop`

<pre />