> 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 Plugin Context

> Borrowed safe wrapper around a host plugin registration context.

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

```rust
pub struct PluginContext<'a> { /* private fields */ }
```

Borrowed safe wrapper around a host plugin registration context.

## Implementations

### `impl<'a> PluginContext<'a>`

<pre />

#### `from_raw`

<pre />

Creates a plugin context wrapper from raw ABI parts.

##### Safety

`host` and `raw` must remain valid for the lifetime of this wrapper.

#### `host_api`

<pre />

Returns the host ABI table backing this registration context.

#### `runtime`

<pre />

Returns a cloneable high-level runtime handle.

#### `register_subscriber`

<pre />

Registers a typed event subscriber callback.

#### `register_tool_sanitize_request_guardrail`

<pre />

Registers a typed tool sanitize-request guardrail.

#### `register_tool_sanitize_response_guardrail`

<pre />

Registers a typed tool sanitize-response guardrail.

#### `register_tool_conditional_execution_guardrail`

<pre />

Registers a typed tool conditional-execution guardrail.

#### `register_tool_request_intercept`

<pre />

Registers a typed tool request intercept.

#### `register_tool_execution_intercept`

<pre />

Registers a typed tool execution intercept.

The callback returns a [`ToolExecutionInterceptOutcome`](/reference/api/rust-library-reference/nemo-relay-plugin/struct-toolexecutioninterceptoutcome). Calling [`ToolNext::call`](/reference/api/rust-library-reference/nemo-relay-plugin/struct-toolnext) continues the chain and returns only the raw downstream result JSON; Relay retains downstream pending marks.

#### `register_llm_sanitize_request_guardrail`

<pre />

Registers a typed LLM sanitize-request guardrail.

#### `register_llm_sanitize_response_guardrail`

<pre />

Registers a typed LLM sanitize-response guardrail.

#### `register_llm_conditional_execution_guardrail`

<pre />

Registers a typed LLM conditional-execution guardrail.

#### `register_llm_request_intercept`

<pre />

Registers a typed LLM request intercept.

#### `register_llm_execution_intercept`

<pre />

Registers a typed LLM execution intercept.

#### `register_llm_stream_execution_intercept`

<pre />

Registers a typed LLM stream execution intercept.

Native ABI v1 represents stream execution as one JSON result. The host wraps that result as a one-chunk stream.

#### `register_subscriber_raw`

<pre />

Registers a raw event subscriber callback.

##### Safety

`cb`, `user_data`, and `free_fn` must remain valid for every host callback invocation until the host deregisters the callback or calls `free_fn`. `free_fn` must match the allocation behind `user_data`.

#### `register_tool_sanitize_request_guardrail_raw`

<pre />

Registers a raw tool sanitize-request guardrail callback.

##### Safety

`cb`, `user_data`, and `free_fn` must remain valid for every host callback invocation until the host deregisters the callback or calls `free_fn`. `free_fn` must match the allocation behind `user_data`.

#### `register_tool_sanitize_response_guardrail_raw`

<pre />

Registers a raw tool sanitize-response guardrail callback.

##### Safety

`cb`, `user_data`, and `free_fn` must remain valid for every host callback invocation until the host deregisters the callback or calls `free_fn`. `free_fn` must match the allocation behind `user_data`.

#### `register_tool_conditional_execution_guardrail_raw`

<pre />

Registers a raw tool conditional-execution guardrail callback.

##### Safety

`cb`, `user_data`, and `free_fn` must remain valid for every host callback invocation until the host deregisters the callback or calls `free_fn`. `free_fn` must match the allocation behind `user_data`.

#### `register_tool_request_intercept_raw`

<pre />

Registers a raw tool request intercept callback.

##### Safety

`cb`, `user_data`, and `free_fn` must remain valid for every host callback invocation until the host deregisters the callback or calls `free_fn`. `free_fn` must match the allocation behind `user_data`.

#### `register_tool_execution_intercept_raw`

<pre />

Registers a raw tool execution intercept callback.

##### Safety

`cb`, `user_data`, and `free_fn` must remain valid for every host callback invocation until the host deregisters the callback or calls `free_fn`. `free_fn` must match the allocation behind `user_data`.

#### `register_llm_sanitize_request_guardrail_raw`

<pre />

Registers a raw LLM sanitize-request guardrail callback.

##### Safety

`cb`, `user_data`, and `free_fn` must remain valid for every host callback invocation until the host deregisters the callback or calls `free_fn`. `free_fn` must match the allocation behind `user_data`.

#### `register_llm_sanitize_response_guardrail_raw`

<pre />

Registers a raw LLM sanitize-response guardrail callback.

##### Safety

`cb`, `user_data`, and `free_fn` must remain valid for every host callback invocation until the host deregisters the callback or calls `free_fn`. `free_fn` must match the allocation behind `user_data`.

#### `register_llm_conditional_execution_guardrail_raw`

<pre />

Registers a raw LLM conditional-execution guardrail callback.

##### Safety

`cb`, `user_data`, and `free_fn` must remain valid for every host callback invocation until the host deregisters the callback or calls `free_fn`. `free_fn` must match the allocation behind `user_data`.

#### `register_llm_request_intercept_raw`

<pre />

Registers a raw LLM request intercept callback.

##### Safety

`cb`, `user_data`, and `free_fn` must remain valid for every host callback invocation until the host deregisters the callback or calls `free_fn`. `free_fn` must match the allocation behind `user_data`.

#### `register_llm_execution_intercept_raw`

<pre />

Registers a raw LLM execution intercept callback.

##### Safety

`cb`, `user_data`, and `free_fn` must remain valid for every host callback invocation until the host deregisters the callback or calls `free_fn`. `free_fn` must match the allocation behind `user_data`.

#### `register_llm_stream_execution_intercept_raw`

<pre />

Registers a raw LLM stream execution intercept callback.

##### Safety

`cb`, `user_data`, and `free_fn` must remain valid for every host callback invocation until the host deregisters the callback or calls `free_fn`. `free_fn` must match the allocation behind `user_data`.