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

# nemo-relay-plugin

> Shared in-process plugin contracts, stable native ABI, and Rust authoring helpers.

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

Shared in-process plugin contracts, stable native ABI, and Rust authoring helpers.

This crate intentionally does not depend on the `nemo-relay` runtime crate. Native plugins built with it communicate with a host through versioned checked ABI-safe values and foreign futures.

## Re-exports

* `pub use nemo_relay_plugin_abi as abi;`

## Modules

* [abi_value](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/abi_value): Lossless SDK JSON conversions. Typed JSON conversion without encoding or parsing JSON text.
* [component](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/component): Shared built-in component contracts. In-process plugin contracts shared by built-in components and runtime hosts.
* [diagnostics](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/diagnostics): Diagnostic submission and authorized reads. Native diagnostic authoring and explicitly authorized canonical reads. Recording is synchronous, state-only, and independent of operational logs. Disabled/unsupported facades skip factories. Diagnostic errors must not be propagated as plugin execution failures unless the application chooses so.

## Macros

* [nemo_relay_checked_plugin](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/macro-nemo-relay-checked-plugin): Export a native plugin with SDK-derived checked contract metadata.
* [nemo_relay_plugin](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/macro-nemo-relay-plugin): Export a checked native plugin with its SDK-required contract version.
* [relay_debug](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/macro-relay-debug): Emit a formatted debug-level native-plugin record through the Relay host.
* [relay_error](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/macro-relay-error): Emit a formatted error-level native-plugin record through the Relay host.
* [relay_info](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/macro-relay-info): Emit a formatted info-level native-plugin record through the Relay host.
* [relay_trace](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/macro-relay-trace): Emit a formatted trace-level native-plugin record through the Relay host.
* [relay_warn](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/macro-relay-warn): Emit a formatted warn-level native-plugin record through the Relay host.

## Structs

* [AnnotatedLlmRequest](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-annotatedllmrequest): Structured view of an LLM request, produced by a Codec from opaque [`LlmRequest`](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmrequest) content.
* [AnnotatedLlmResponse](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-annotatedllmresponse): Structured view of an LLM response, produced by a response codec from raw JSON API output.
* [ApplicationExecutionContext](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-applicationexecutioncontext): Concrete invocation-local context owned by Relay.
* [CategoryProfile](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-categoryprofile): Category-specific profile data.
* [ConditionalMiddlewareGuardrailHandle](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-conditionalmiddlewareguardrailhandle)
* [ConfigDiagnostic](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-configdiagnostic): Structured diagnostic reported while validating or activating plugin configuration.
* [ContentSnapshot](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-contentsnapshot): Owned snapshot; materialization copies selected content for transport or independent retention.
* [CostEstimate](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-costestimate): Normalized LLM response cost.
* [DataSchema](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-dataschema): Identifier for the schema that describes an event's opaque `data` payload.
* [EmitMarkOptions](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-emitmarkoptions): Optional event parent, time, schema, and severity for a native mark.
* [EventCategory](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-eventcategory): Semantic category carried by ATOF `category`.
* [EventSanitizeFields](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-eventsanitizefields): Observability fields that event sanitizers may rewrite.
* [LlmApplicationExecutionContext](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmapplicationexecutioncontext): Application data passed to execution intercepts for one LLM call. Application context for one LLM call.
* [LlmAttributes](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmattributes): Bitflags that modify LLM-call behavior and observability.
* [LlmExecutionContext](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmexecutioncontext)
* [LlmInputStream](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llminputstream): Downstream LLM stream that reports whether its cleanup succeeded.
* [LlmNext](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmnext)
* [LlmOptimizationContribution](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmoptimizationcontribution): One optimizer's evidence for a change to an LLM call.
* [LlmOptimizationKind](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmoptimizationkind): Open, forward-compatible optimization classification.
* [LlmOptimizationModel](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmoptimizationmodel): Model identity used for counterfactual and effective pricing.
* [LlmOptimizationModelTransition](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmoptimizationmodeltransition): A model change proposed or applied by an optimizer.
* [LlmOptimizationSummary](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmoptimizationsummary): Close-time accounting attached to the normalized LLM response.
* [LlmOptimizationTokenImpact](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmoptimizationtokenimpact): Shared token evidence that Relay can aggregate without understanding a plugin payload.
* [LlmOptimizationTokens](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmoptimizationtokens): Token quantities retained independently from pricing arithmetic.
* [LlmRequest](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmrequest): JSON-shaped LLM request payload passed through the runtime.
* [LlmRequestContext](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmrequestcontext)
* [LlmRequestInterceptOutcome](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmrequestinterceptoutcome): Result of an LLM request intercept that can schedule lifecycle marks.
* [LlmResponseContext](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmresponsecontext)
* [LlmSanitizeRequestContext](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmsanitizerequestcontext)
* [LlmSanitizeResponseContext](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmsanitizeresponsecontext)
* [LlmStreamNext](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-llmstreamnext)
* [Map](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-map): Represents a JSON key/value type.
* [MetricEnvelope](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-metricenvelope): Payload stored in a mark using [`METRIC_DATA_SCHEMA_NAME`](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/constant-metric-data-schema-name).
* [MetricMeasurement](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-metricmeasurement): One recording operation in a Relay metric mark.
* [NativeExecutorConfig](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-nativeexecutorconfig): Configuration used when a native plugin opts into a shared Tokio runtime.
* [PendingMarkSpec](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-pendingmarkspec): Mark requested by middleware for materialization by a lifecycle owner.
* [PluginContext](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-plugincontext)
* [PluginRuntime](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-pluginruntime)
* [PluginTaskSpawner](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-plugintaskspawner): Cloneable admission handle for background tasks owned by one native component.
* [RuntimeDiagnostic](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-runtimediagnostic): One bounded runtime diagnostic reported by the Relay host.
* [RuntimeDiagnostics](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-runtimediagnostics): Bounded snapshot of active host runtime diagnostics.
* [RuntimeRegistrationIdentity](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-runtimeregistrationidentity): Structured identity for a global gateable runtime registration.
* [RuntimeRegistrationOwner](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-runtimeregistrationowner): Discovery metadata describing the owner of a runtime registration.
* [ScopeAttributes](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-scopeattributes): Bitflags that modify scope behavior and observability.
* [ScopeGuard](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-scopeguard)
* [ScopeHandle](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-scopehandle)
* [ScopeOptions](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-scopeoptions): Optional parent, behavior flags, and start time for a native scope.
* [ScopeStack](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-scopestack)
* [ScopeStackBinding](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-scopestackbinding)
* [ScopeStackEntry](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-scopestackentry): Identity of one entry in the visible Relay scope stack.
* [ScopeStackSnapshot](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-scopestacksnapshot): Owned root-to-top values from one coherent read of a visible scope stack.
* [ThreadScopeStackGuard](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-threadscopestackguard)
* [ToolAttributes](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-toolattributes): Bitflags that modify tool-call behavior and observability.
* [ToolExecutionContext](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-toolexecutioncontext): Transport-independent input supplied to a plugin tool execution interceptor.
* [ToolExecutionInterceptOutcome](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-toolexecutioninterceptoutcome): Canonical result returned by a tool execution intercept.
* [ToolExecutionResult](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-toolexecutionresult): Canonical application-visible result of tool execution.
* [ToolNext](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-toolnext)
* [Usage](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-usage): Token usage statistics from an LLM API response.

## Enums

* [BuiltinLlmCodec](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-builtinllmcodec): Relay's built-in LLM codec identities.
* [ContentSelection](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-contentselection): Selection applied before extraction. Invalid source/selection pairs are errors.
* [ContentSource](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-contentsource): Borrowed normalized input for content inspection; no provider decoding occurs.
* [DiagnosticLevel](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-diagnosticlevel): Severity of a plugin configuration or activation diagnostic.
* [Event](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-event): Tagged union covering the two ATOF event kinds emitted by the runtime.
* [HandleAttributes](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-handleattributes): Attribute bitflags attached to a concrete handle kind.
* [LlmCodecIdentity](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-llmcodecidentity): Per-call LLM codec identity supplied to sanitizer and SDK callbacks.
* [LlmOptimizationEvidenceQuality](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-llmoptimizationevidencequality): Whether token evidence was observed directly or estimated.
* [LlmOptimizationSummaryStatus](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-llmoptimizationsummarystatus): Completeness of close-time optimization accounting.
* [LogSeverity](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-logseverity): Severity attached to a mark that may be projected as an OpenTelemetry log.
* [MetricKind](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-metrickind): OpenTelemetry instrument kind represented by a metric measurement mark.
* [MetricValueType](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-metricvaluetype): Numeric representation used by a metric measurement.
* [PluginError](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-pluginerror): Error type for generic plugin operations.
* [PluginLogLevel](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-pluginloglevel): Operational log severity routed through the component runtime.
* [RuntimeRegistrationKind](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-runtimeregistrationkind): A global runtime registration surface that can be selected by a conditional middleware guardrail.
* [RuntimeRegistrationOwnerKind](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-runtimeregistrationownerkind): The owner category reported for a global runtime registration.
* [ScopeCategory](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-scopecategory): Agent Trajectory Observability Format (ATOF) lifecycle phase for a scope event.
* [ScopeType](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/enum-scopetype): Semantic category attached to a scope lifecycle span.

## Constants

* [METRIC_DATA_SCHEMA_NAME](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/constant-metric-data-schema-name): Relay-owned schema name for mark payloads containing metric measurements.
* [METRIC_DATA_SCHEMA_VERSION](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/constant-metric-data-schema-version): Current Relay-owned metric measurement schema version.
* [TOOL_EXECUTION_INTERCEPT_OUTCOME_SCHEMA](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/constant-tool-execution-intercept-outcome-schema): Versioned native-plugin JSON envelope schema for [`ToolExecutionInterceptOutcome`](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-toolexecutioninterceptoutcome).
* [TOOL_EXECUTION_RESULT_SCHEMA](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/constant-tool-execution-result-schema): Versioned native-plugin JSON envelope schema for [`ToolExecutionResult`](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/struct-toolexecutionresult).

## Traits

* [LlmOptimizationPayload](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/trait-llmoptimizationpayload): Trait implemented by typed plugin payloads embedded in an optimization contribution.
* [NativePlugin](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/trait-nativeplugin)
* [Plugin](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/trait-plugin)

## Functions

* [http_error_message](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/fn-http-error-message): Formats an upstream HTTP error for transport through string-based plugin callbacks.

## Type Aliases

* [Json](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/type-json): Type alias for [`serde_json::Value`](https://docs.rs/serde_json/1.0.149/serde_json/value/enum.Value.html), used as the universal JSON representation throughout NeMo Relay APIs.
* [LlmJsonAsyncStream](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/type-llmjsonasyncstream)
* [PluginFuture](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/type-pluginfuture): Shared future returned by Rust plugin activation methods.
* [Result](/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-plugin/type-result): Result returned by native SDK helpers.