> 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 > NeMo Relay Core 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`. ## NeMo Relay Core The core runtime library for the NeMo Relay multi-language agent framework. This crate provides execution scope management, lifecycle event tracking, and middleware pipelines (guardrails and intercepts) for tool and LLM calls. ### Architecture The runtime is organized around a **global context** ([`api::runtime::NemoRelayContextState`](/reference/api/rust-library-reference/nemo-relay/api/runtime/state/struct-nemorelaycontextstate)) that holds all registered middleware (guardrails, intercepts, subscribers) and a **scope stack** ([`api::runtime::ScopeStack`](/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/struct-scopestack)) that tracks the hierarchical execution context via task-local or thread-local storage. ### Primary Entry Points Most integrations start with the high-level lifecycle helpers in [`api`](/reference/api/rust-library-reference/nemo-relay/api): * [`api::scope::push_scope`](/reference/api/rust-library-reference/nemo-relay/api/scope/fn-push-scope) / [`api::scope::pop_scope`](/reference/api/rust-library-reference/nemo-relay/api/scope/fn-pop-scope) create nested execution scopes. * [`api::tool::tool_call_execute`](/reference/api/rust-library-reference/nemo-relay/api/tool/fn-tool-call-execute) runs a complete tool middleware pipeline. * [`api::llm::llm_call_execute`](/reference/api/rust-library-reference/nemo-relay/api/llm/fn-llm-call-execute) and [`api::llm::llm_stream_call_execute`](/reference/api/rust-library-reference/nemo-relay/api/llm/fn-llm-stream-call-execute) run non-streaming and streaming LLM middleware pipelines. * [`api::registry`](/reference/api/rust-library-reference/nemo-relay/api/registry) exposes global and scope-local middleware registration APIs. * [`api::subscriber`](/reference/api/rust-library-reference/nemo-relay/api/subscriber) exposes lifecycle event subscriber registration APIs. #### Modules * [`api`](/reference/api/rust-library-reference/nemo-relay/api) - Public API functions, handles, lifecycle event types, runtime helpers, and guardrail/intercept/subscriber registration. These are the primary entry points. * [`error`](/reference/api/rust-library-reference/nemo-relay/error) - Error types ([`error::FlowError`](/reference/api/rust-library-reference/nemo-relay/error/enum-flowerror)) and the [`error::Result`](/reference/api/rust-library-reference/nemo-relay/error/type-result) type alias. * [`json`](/reference/api/rust-library-reference/nemo-relay/json) - JSON type alias ([`json::Json`](/reference/api/rust-library-reference/nemo-relay/json/type-json)) and the [`json::merge_json`](/reference/api/rust-library-reference/nemo-relay/json/fn-merge-json) utility. * [`logging`](/reference/api/rust-library-reference/nemo-relay/logging) - Process operational logging (`log` facade + configurable stderr/file sinks). * [`observability`](/reference/api/rust-library-reference/nemo-relay/observability) - Built-in observability backends including [`atif::AtifExporter`](/reference/api/rust-library-reference/nemo-relay/observability/atif/struct-atifexporter), [`otel::OpenTelemetrySubscriber`](/reference/api/rust-library-reference/nemo-relay/observability/otel/struct-opentelemetrysubscriber), with full, GenAI, or OpenInference projection. * [`stream`](/reference/api/rust-library-reference/nemo-relay/stream) - [`stream::LlmStreamWrapper`](/reference/api/rust-library-reference/nemo-relay/stream/struct-llmstreamwrapper) - a stream adapter that applies per-chunk intercepts and aggregates streaming LLM responses. ### Middleware Pipeline Both tool and LLM calls flow through a configurable middleware pipeline: 1. **Request intercepts** - transform the request before execution 2. **Sanitize request guardrails** - sanitize/normalize the request 3. **Conditional execution guardrails** - gate execution (reject if criteria not met) 4. **Execution intercepts** - optionally replace the execution function entirely 5. **Sanitize response guardrails** - sanitize/normalize the response All middleware is priority-ordered (ascending) and registered by name for easy addition and removal at runtime. ## Modules * [api](/reference/api/rust-library-reference/nemo-relay/api): Public API for the NeMo Relay runtime. * [codec](/reference/api/rust-library-reference/nemo-relay/codec): LLM codecs and the shared JSON format for tool results. * [config_editor](/reference/api/rust-library-reference/nemo-relay/config_editor): Typed configuration editor metadata. * [diagnostics](/reference/api/rust-library-reference/nemo-relay/diagnostics): Bounded, process-local diagnostic evidence, independent of logger startup. * [error](/reference/api/rust-library-reference/nemo-relay/error): Error types for the NeMo Relay runtime. * [json](/reference/api/rust-library-reference/nemo-relay/json): JSON utilities for the NeMo Relay runtime. * [logging](/reference/api/rust-library-reference/nemo-relay/logging): Operational process logging for Relay (stderr + optional file sinks). * [observability](/reference/api/rust-library-reference/nemo-relay/observability): Optional observability integrations for NeMo Relay Core. * [plugin](/reference/api/rust-library-reference/nemo-relay/plugin): Generic plugin infrastructure for NeMo Relay runtimes. * [plugins](/reference/api/rust-library-reference/nemo-relay/plugins): First-party plugin implementations for NeMo Relay Core. * [stream](/reference/api/rust-library-reference/nemo-relay/stream): Streaming LLM response wrapper. ## Macros * [editor_config](/reference/api/rust-library-reference/nemo-relay/macro-editor-config): Implements [`EditorConfig`](/reference/api/rust-library-reference/nemo-relay/config_editor/trait-editorconfig) for a configuration type. ## Docs - [Module api](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api.md): Public API for the NeMo Relay runtime. - [api](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/llms.txt): section index (llms.txt) listing 9 pages - [event](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/event/llms.txt): section index (llms.txt) listing 35 pages - [llm](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/llm/llms.txt): section index (llms.txt) listing 17 pages - [optimization](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/optimization/llms.txt): section index (llms.txt) listing 7 pages - [registry](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/registry/llms.txt): section index (llms.txt) listing 67 pages - [resource_metrics](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/resource_metrics/llms.txt): section index (llms.txt) listing 47 pages - [runtime](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/runtime/llms.txt): section index (llms.txt) listing 10 pages - [callbacks](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/runtime/callbacks/llms.txt): section index (llms.txt) listing 36 pages - [global](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/runtime/global/llms.txt): section index (llms.txt) listing 1 page - [scope_stack](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/llms.txt): section index (llms.txt) listing 31 pages - [state](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/runtime/state/llms.txt): section index (llms.txt) listing 1 page - [subscriber_dispatcher](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/runtime/subscriber_dispatcher/llms.txt): section index (llms.txt) listing 2 pages - [scope](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/scope/llms.txt): section index (llms.txt) listing 16 pages - [subscriber](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/subscriber/llms.txt): section index (llms.txt) listing 5 pages - [tool](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/api/tool/llms.txt): section index (llms.txt) listing 16 pages - [Module codec](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec.md): LLM codecs and the shared JSON format for tool results. - [codec](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/llms.txt): section index (llms.txt) listing 13 pages - [anthropic](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/anthropic/llms.txt): section index (llms.txt) listing 2 pages - [gemini_generate_content](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/gemini_generate_content/llms.txt): section index (llms.txt) listing 2 pages - [model_pricing](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/model_pricing/llms.txt): section index (llms.txt) listing 26 pages - [oci_genai](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/oci_genai/llms.txt): section index (llms.txt) listing 2 pages - [openai_chat](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/openai_chat/llms.txt): section index (llms.txt) listing 2 pages - [openai_responses](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/openai_responses/llms.txt): section index (llms.txt) listing 2 pages - [optimization](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/optimization/llms.txt): section index (llms.txt) listing 10 pages - [request](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/request/llms.txt): section index (llms.txt) listing 16 pages - [resolve](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/resolve/llms.txt): section index (llms.txt) listing 11 pages - [response](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/response/llms.txt): section index (llms.txt) listing 7 pages - [streaming](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/streaming/llms.txt): section index (llms.txt) listing 4 pages - [tool](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/tool/llms.txt): section index (llms.txt) listing 1 page - [traits](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/codec/traits/llms.txt): section index (llms.txt) listing 3 pages - [Module config_editor](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/config_editor.md): Typed configuration editor metadata. - [config_editor](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/config_editor/llms.txt): section index (llms.txt) listing 11 pages - [Module diagnostics](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/diagnostics.md): Bounded, process-local diagnostic evidence, independent of logger startup. - [diagnostics](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/diagnostics/llms.txt): section index (llms.txt) listing 109 pages - [classifiers](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/diagnostics/classifiers/llms.txt): section index (llms.txt) listing 1 page - [embedded](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/diagnostics/embedded/llms.txt): section index (llms.txt) listing 9 pages - [Module error](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/error.md): Error types for the NeMo Relay runtime. - [error](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/error/llms.txt): section index (llms.txt) listing 4 pages - [Module json](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/json.md): JSON utilities for the NeMo Relay runtime. - [json](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/json/llms.txt): section index (llms.txt) listing 2 pages - [Module logging](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/logging.md): Operational process logging for Relay (stderr + optional file sinks). - [logging](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/logging/llms.txt): section index (llms.txt) listing 15 pages - [Module observability](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/observability.md): Optional observability integrations for NeMo Relay Core. - [observability](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/observability/llms.txt): section index (llms.txt) listing 18 pages - [atif](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/observability/atif/llms.txt): section index (llms.txt) listing 14 pages - [atof](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/observability/atof/llms.txt): section index (llms.txt) listing 11 pages - [otel](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/observability/otel/llms.txt): section index (llms.txt) listing 11 pages - [otel_file](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/observability/otel_file/llms.txt): section index (llms.txt) listing 4 pages - [otel_logs](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/observability/otel_logs/llms.txt): section index (llms.txt) listing 3 pages - [otel_metrics](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/observability/otel_metrics/llms.txt): section index (llms.txt) listing 4 pages - [plugin_component](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/observability/plugin_component/llms.txt): section index (llms.txt) listing 19 pages - [Module plugin](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/plugin.md): Generic plugin infrastructure for NeMo Relay runtimes. - [plugin](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/plugin/llms.txt): section index (llms.txt) listing 23 pages - [dynamic](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/plugin/dynamic/llms.txt): section index (llms.txt) listing 74 pages - [Module plugins](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/plugins.md): First-party plugin implementations for NeMo Relay Core. - [plugins](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/plugins/llms.txt): section index (llms.txt) listing 3 pages - [model_pricing](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/plugins/model_pricing/llms.txt): section index (llms.txt) listing 2 pages - [nemo_guardrails](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/plugins/nemo_guardrails/llms.txt): section index (llms.txt) listing 1 page - [component](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/plugins/nemo_guardrails/component/llms.txt): section index (llms.txt) listing 10 pages - [resource_metrics](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/plugins/resource_metrics/llms.txt): section index (llms.txt) listing 2 pages - [Module stream](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/stream.md): Streaming LLM response wrapper. - [stream](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/stream/llms.txt): section index (llms.txt) listing 1 page - [Macro editor_config](https://docs.nvidia.com/nemo/relay/v0.11.3/reference/api/rust-library-reference/nemo-relay/macro-editor-config.md): Implements `EditorConfig` for a configuration type.