For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
  • About NVIDIA NeMo Relay
    • Overview
    • Architecture
    • Ecosystem
    • Concepts
    • Release Notes
  • Getting Started
    • Agent Runtime Primer
    • Prerequisites
    • Installation
    • Configuration / Setup
    • Quick Start
  • NVIDIA NeMo Relay CLI
    • About
    • Basic Usage
    • Claude Code
    • Codex
    • Cursor
    • Hermes Agent
  • Supported Integrations
    • About
    • OpenClaw Plugin Guide
    • LangChain Integration Guide
    • LangGraph Integration Guide
    • Deep Agents Integration Guide
  • Instrument Applications
    • About
    • Adding Scopes and Marks
    • Instrument a Tool Call
    • Instrument an LLM Call
    • Add Middleware
    • Code Examples
  • Observability Plugin
    • About
    • Configuration
    • Agent Trajectory Interchange Format (ATIF)
    • Agent Trajectory Observability Format (ATOF)
    • OpenTelemetry
    • OpenInference
  • Adaptive Plugin
    • About
    • Configuration
    • Adaptive Cache Governor (ACG)
    • Adaptive Hints
  • NeMo Guardrails Plugin
    • About
    • Configuration
  • Integrate into Frameworks
    • About
    • Adding Scopes
    • Wrap Tool Calls
    • Wrap LLM Calls
    • Handle Non-Serializable Data
    • Using Codecs
    • Provider Codecs
    • Provider Response Codecs
    • Code Examples
  • Build Plugins
    • About
    • Define a Plugin
    • Validate Plugin Configuration
    • Plugin Configuration Files
    • Register Plugin Behavior
    • Design Plugin Configuration
    • NeMo Guardrails Example Plugin
    • Code Examples
  • Contribute
    • About
    • Development Setup
    • Workflow and Reviews
    • Testing and Documentation
  • Reference
    • APIs
      • Python Library Reference
      • Node.js Library Reference
      • Rust Library Reference
        • nemo-relay
          • api
          • codec
          • config_editor
          • error
          • json
          • observability
          • plugin
          • plugins
          • stream
          • editor_config
        • nemo-relay-adaptive
        • nemo-relay-ffi
    • Performance
  • Resources
    • Support and FAQs
    • Glossary
    • Troubleshooting Guide
    • Community
    • Legal
NVIDIANVIDIA
Developer-friendly docs for your API
Privacy Policy | Your Privacy Choices | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact

Copyright © 2026, NVIDIA Corporation.

LogoLogo
On this page
  • NeMo Relay Core
  • Architecture
  • Primary Entry Points
  • Modules
  • Middleware Pipeline
  • Modules
  • Macros
ReferenceAPIsRust Library Reference

nemo-relay

||View as Markdown|
Previous

Rust Library Reference

Next

Module api

Generated from cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-ffi.

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) that holds all registered middleware (guardrails, intercepts, subscribers) and a scope stack (api::runtime::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:

  • api::scope::push_scope / api::scope::pop_scope create nested execution scopes.
  • api::tool::tool_call_execute runs a complete tool middleware pipeline.
  • api::llm::llm_call_execute and api::llm::llm_stream_call_execute run non-streaming and streaming LLM middleware pipelines.
  • api::registry exposes global and scope-local middleware registration APIs.
  • api::subscriber exposes lifecycle event subscriber registration APIs.

Modules

  • api - Public API functions, handles, lifecycle event types, runtime helpers, and guardrail/intercept/subscriber registration. These are the primary entry points.
  • error - Error types (error::FlowError) and the error::Result type alias.
  • json - JSON type alias (json::Json) and the json::merge_json utility.
  • observability - Built-in observability backends including atif::AtifExporter, otel::OpenTelemetrySubscriber, and openinference::OpenInferenceSubscriber.
  • stream - stream::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: Public API for the NeMo Relay runtime.
  • codec: LLM codec types, traits, and built-in implementations.
  • config_editor: Typed configuration editor metadata.
  • error: Error types for the NeMo Relay runtime.
  • json: JSON utilities for the NeMo Relay runtime.
  • observability: Optional observability integrations for NeMo Relay Core.
  • plugin: Generic plugin infrastructure for NeMo Relay runtimes.
  • plugins: First-party plugin implementations for NeMo Relay Core.
  • stream: Streaming LLM response wrapper.

Macros

  • editor_config: Implements EditorConfig for a configuration type.