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

# Struct Nemo Relay Native Host ApiV4

> ABI-v4 host extension for typed asynchronous middleware, mark options, diagnostics, and activation-owned dynamic gate control.

Generated from `cargo doc --no-deps -p nemo-relay -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`.

<pre />

ABI-v4 host extension for typed asynchronous middleware, mark options, diagnostics, and activation-owned dynamic gate control.

The complete ABI-v3 table is the prefix, preserving layout compatibility.

## Fields

### `v3: NemoRelayNativeHostApiV3`

Frozen ABI-v3 compatibility prefix.

### `async_completion_llm_request_codec_decode: unsafe extern "C" fn(completion: *const NemoRelayNativeAsyncCompletion, request_json: *const NemoRelayNativeString, out: *mut *mut NemoRelayNativeString) -> NemoRelayStatus`

Decodes an LLM request using the request codec attached to `completion`.

### `async_completion_llm_request_codec_encode: unsafe extern "C" fn(completion: *const NemoRelayNativeAsyncCompletion, annotated_json: *const NemoRelayNativeString, original_json: *const NemoRelayNativeString, out: *mut *mut NemoRelayNativeString) -> NemoRelayStatus`

Encodes an annotated LLM request using the request codec attached to `completion`.

### `async_completion_llm_response_codec_decode: unsafe extern "C" fn(completion: *const NemoRelayNativeAsyncCompletion, response_json: *const NemoRelayNativeString, out: *mut *mut NemoRelayNativeString) -> NemoRelayStatus`

Decodes an LLM response using the response codec attached to `completion`.

### `async_next_open_llm_stream: unsafe extern "C" fn(next: *const NemoRelayNativeAsyncNext, request_json: *const NemoRelayNativeString, cb: NemoRelayNativeAsyncLlmStreamOpenCb, user_data: *mut c_void) -> NemoRelayStatus`

Opens an independent pull-based downstream LLM stream.

### `async_llm_stream_pull: unsafe extern "C" fn(stream: *const NemoRelayNativeLlmAsyncStream, cb: NemoRelayNativeAsyncLlmStreamPullCb, user_data: *mut c_void) -> NemoRelayStatus`

Requests one item from a pull-based downstream LLM stream.

### `async_llm_stream_cancel: unsafe extern "C" fn(stream: *const NemoRelayNativeLlmAsyncStream) -> NemoRelayStatus`

Cancels a pull-based downstream LLM stream.

### `async_llm_stream_release: unsafe extern "C" fn(stream: *const NemoRelayNativeLlmAsyncStream)`

Releases the plugin-owned stream reference exactly once.

### `async_completion_retain: unsafe extern "C" fn(completion: *const NemoRelayNativeAsyncCompletion) -> NemoRelayStatus`

Retains a completion capability for a codec facade that outlives the callback's original completion reference.

### `async_stream_is_backpressured: unsafe extern "C" fn(stream: *const NemoRelayNativeAsyncStream) -> bool`

Returns whether the output queue is currently full.

Use [`NemoRelayStatus::Backpressured`](/reference/api/rust-library-reference/nemo-relay-plugin/enum-nemorelaystatus) from the individual push or rejection operation to decide whether that operation must be retried.

### `emit_mark_v2: NemoRelayNativeEmitMarkV2Fn`

Emits a mark with optional data-schema and telemetry-severity fields.

### `get_runtime_diagnostics: NemoRelayNativeGetRuntimeDiagnosticsFn`

Returns a bounded snapshot of active host runtime diagnostics.

### `plugin_context_runtime: unsafe extern "C" fn(ctx: *mut NemoRelayNativePluginContext, out: *mut *const NemoRelayNativePluginRuntime) -> NemoRelayStatus`

Creates an activation-owned runtime capability from a registration context.

On success, `out` receives one owned reference. Every owned reference must be released exactly once with `plugin_runtime_release`.

### `plugin_runtime_retain: unsafe extern "C" fn(runtime: *const NemoRelayNativePluginRuntime) -> NemoRelayStatus`

Retains a runtime capability for a cloned SDK handle.

A successful call creates one additional owned reference.

### `plugin_runtime_release: unsafe extern "C" fn(runtime: *const NemoRelayNativePluginRuntime)`

Releases one owned runtime capability reference.

### `plugin_runtime_list_registrations: unsafe extern "C" fn(runtime: *const NemoRelayNativePluginRuntime, kinds_json: *const NemoRelayNativeString, out_json: *mut *mut NemoRelayNativeString) -> NemoRelayStatus`

Lists global runtime registrations as JSON.

### `plugin_runtime_register_conditional_middleware_guardrail: unsafe extern "C" fn(runtime: *const NemoRelayNativePluginRuntime, name: *const NemoRelayNativeString, kinds_json: *const NemoRelayNativeString, registration_name: *const NemoRelayNativeString, reason: *const NemoRelayNativeString, out_handle: *mut *mut NemoRelayNativeString) -> NemoRelayStatus`

Registers an activation-owned host-resident gate and returns its handle.

### `plugin_runtime_deregister_conditional_middleware_guardrail: unsafe extern "C" fn(runtime: *const NemoRelayNativePluginRuntime, handle: *const NemoRelayNativeString, out_removed: *mut bool) -> NemoRelayStatus`

Deregisters an activation-owned gate by opaque handle.

### `plugin_context_register_conditional_middleware_guardrail: unsafe extern "C" fn(ctx: *mut NemoRelayNativePluginContext, name: *const NemoRelayNativeString, kinds_json: *const NemoRelayNativeString, registration_name: *const NemoRelayNativeString, reason: *const NemoRelayNativeString) -> NemoRelayStatus`

Declares a host-resident gate during component registration.

## Trait Implementations

### `impl Clone for NemoRelayNativeHostApiV4`

<pre />

#### `clone`

<pre />

#### `clone_from`

<pre />

### `impl Copy for NemoRelayNativeHostApiV4`

<pre />

### `impl Send for NemoRelayNativeHostApiV4`

<pre />

### `impl Sync for NemoRelayNativeHostApiV4`

<pre />