Skip to main content

License GitHub Release Codecov PyPI npm node Crates.io Crates.io Crates.io Ask DeepWiki

NeMo Relay

nemo-relay is the NeMo Relay package for Python applications. It gives Python code access to a portable agent runtime for execution scopes, middleware, plugins, lifecycle events, adaptive behavior, and observability around tool and LLM calls.

The package wraps the shared Rust runtime, so Python applications use the same runtime semantics as the Rust and Node.js surfaces.

Why Use It?

Use the Python binding for the following tasks:

  • Own execution context in Python: Group agent, tool, and LLM work into one scope tree from Python application code.
  • Package policy around callbacks: Use guardrails and intercepts to block work, sanitize observability payloads, rewrite requests, or wrap execution.
  • Emit one lifecycle stream: Send runtime events to in-process subscribers, Agent Trajectory Interchange Format (ATIF), or typed OpenTelemetry workflows.
  • Integrate without a framework migration: Wrap framework or provider callbacks while preserving the application’s orchestration model.

What You Get

The Python package provides the following capabilities:

  • Scope, tool, and LLM helpers: Managed boundaries that emit lifecycle events and run middleware in a consistent order.
  • Middleware APIs: Guardrails and intercepts for tool and LLM requests, responses, and execution, plus mark and scope event sanitizers for data, category_profile, and metadata.
  • Subscribers and exporters: OpenTelemetrySubscriber exports traces; OpenTelemetryLogSubscriber and OpenTelemetryMetricSubscriber export severity-tagged marks and typed metric measurements. Bare OTLP/HTTP origins resolve to /v1/traces, /v1/logs, or /v1/metrics for the selected signal. Each direct OTLP subscriber exposes runtime_diagnostics() for bounded exporter and event-processing failure summaries. Trace export failures use otel.traces_export_failed; after a trace export fails, force_flush() continues to return an error until a later trace batch exports successfully. The nemo_relay.observability helpers configure plugin-owned endpoint fan-out.
  • Plugin and typed helpers: Public modules for plugins, codecs, typed wrappers, adaptive runtime behavior, and observability plugin configuration.
  • Shared Rust runtime semantics: Python behavior aligned with the Rust and Node.js surfaces.

Installation

Install the published package with uv:

uv add nemo-relay

If you are not using uv, install it with pip:

pip install nemo-relay

Optional Dependencies

LangChain Integration

LangChain integration is available with the langchain extra:

# With uv
uv add "nemo-relay[langchain]"

# With pip
pip install "nemo-relay[langchain]"

LangGraph Integration

LangGraph integration is available with the langgraph extra, this builds upon and includes the langchain extra as well.

# With uv
uv add "nemo-relay[langgraph]"

# With pip
pip install "nemo-relay[langgraph]"

Deep Agents Integration

Deep Agents integration is available with the deepagents extra. This extra builds upon and includes the langgraph and langchain extras.

# With uv
uv add "nemo-relay[deepagents]"

# With pip
pip install "nemo-relay[deepagents]"

LangChain NVIDIA Integration

The LangChain NVIDIA extra builds upon the langchain extra adding a compatible version of the langchain-nvidia-ai-endpoints package.

# With uv
uv add "nemo-relay[langchain-nvidia]"

# With pip
pip install "nemo-relay[langchain-nvidia]"

To install this along with the langgraph extra, use:

# With uv
uv add "nemo-relay[langgraph,langchain-nvidia]"
# With pip
pip install "nemo-relay[langgraph,langchain-nvidia]"

Getting Started

Register a subscriber, create a scope, and emit a mark event:

import nemo_relay


def on_event(event) -> None:
    print(f"{event.kind} {event.name}")


nemo_relay.subscribers.register("printer", on_event)

with nemo_relay.scope.scope("demo-agent", nemo_relay.ScopeType.Agent) as handle:
    nemo_relay.scope.event("initialized", handle=handle, data={"binding": "python"})

nemo_relay.subscribers.flush()
nemo_relay.subscribers.deregister("printer")

Use nemo_relay.scope.event(..., severity=nemo_relay.LogSeverity.Info) for a mark intended for log export. Use nemo_relay.scope.metric() with nemo_relay.MetricMeasurement objects for metrics; Relay validates the complete measurement group before publishing it.

OTLP Logs and Metrics

For plugin-managed export, configure version 4 and enable logs and metrics. Omitting their endpoint lists derives /v1/logs and /v1/metrics from the trace endpoint:

from nemo_relay.observability import (
    ComponentSpec,
    ObservabilityConfig,
    OpenTelemetryEndpointConfig,
    OpenTelemetryLogSectionConfig,
    OpenTelemetryMetricSectionConfig,
    OpenTelemetrySectionConfig,
)

component = ComponentSpec(
    ObservabilityConfig(
        opentelemetry=OpenTelemetrySectionConfig(
            enabled=True,
            endpoints=[
                OpenTelemetryEndpointConfig(
                    type="gen_ai", endpoint="http://localhost:4318/v1/traces"
                )
            ],
            logs=OpenTelemetryLogSectionConfig(enabled=True),
            metrics=OpenTelemetryMetricSectionConfig(enabled=True),
        )
    )
)

Emit a typed log mark and an atomically validated metric group with the public scope helpers:

from nemo_relay import DataSchema, LogSeverity, MetricKind, MetricMeasurement, MetricValueType
from nemo_relay import scope

scope.event(
    "cache-nearly-full",
    data={"entries": 900},
    data_schema=DataSchema("example.cache", "1"),
    severity=LogSeverity.Warn,
)
scope.metric(
    "cache-entries",
    [MetricMeasurement("example.cache.entries", MetricKind.Gauge, MetricValueType.U64, 900)],
)

Direct log and metric subscribers are independently managed. Register each before emitting marks, then deregister, force-flush, and shut it down during graceful teardown. Their runtime_diagnostics() snapshots contain bounded code, message, and count entries:

A successful direct log or trace force_flush() also updates this snapshot with any queue drops observed so far; the diagnostic count remains cumulative through later flushes and shutdown.

from nemo_relay import (
    OpenTelemetryLogConfig,
    OpenTelemetryLogSubscriber,
    OpenTelemetryMetricConfig,
    OpenTelemetryMetricSubscriber,
)

# Equivalent explicit OTLP/HTTP paths are /v1/logs and /v1/metrics, respectively.
logs = OpenTelemetryLogSubscriber(OpenTelemetryLogConfig("http://localhost:4318"))
metrics = OpenTelemetryMetricSubscriber(OpenTelemetryMetricConfig("http://localhost:4318"))
logs.register("otlp-logs")
metrics.register("otlp-metrics")
try:
    for diagnostic in logs.runtime_diagnostics().entries:
        print(diagnostic.code, diagnostic.message)
finally:
    logs.deregister("otlp-logs")
    logs.force_flush()
    logs.shutdown()
    metrics.deregister("otlp-metrics")
    metrics.force_flush()
    metrics.shutdown()

Native subscriber delivery is asynchronous, so call nemo_relay.subscribers.flush() before you read subscriber output or exit. From an asyncio task, use await nemo_relay.subscribers.flush_async() so async event sanitizers can continue running on that event loop.

For host integrations that need a serialized event shape, consume the canonical JSON payload from the subscriber event object:

import json
import nemo_relay


def on_event(event) -> None:
    payload = event.to_dict()
    print(payload["kind"], payload["name"])
    assert json.loads(event.to_json()) == payload


nemo_relay.subscribers.register("host-exporter", on_event)
try:
    with nemo_relay.scope.scope("demo-agent", nemo_relay.ScopeType.Agent):
        nemo_relay.scope.event("initialized", data={"binding": "python"})
finally:
    nemo_relay.subscribers.flush()
    nemo_relay.subscribers.deregister("host-exporter")

Package Surface

The public package modules are:

  • nemo_relay.scope
  • nemo_relay.tools
  • nemo_relay.llm
  • nemo_relay.guardrails
  • nemo_relay.intercepts
  • nemo_relay.subscribers
  • nemo_relay.plugin
  • nemo_relay.adaptive
  • nemo_relay.observability
  • nemo_relay.typed
  • nemo_relay.codecs

Integrations

  • nemo_relay.integrations.langchain
  • nemo_relay.integrations.langgraph
  • nemo_relay.integrations.deepagents

The compiled extension is exposed as nemo_relay._native.

Documentation

NeMo Relay Documentation: https://docs.nvidia.com/nemo/relay

Metadata

Release files for nemo-relay 0.8.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nemo-relay 0.8.4
File Size Uploaded
nemo_relay-0.8.4.tar.gz 1.6 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for nemo-relay 0.8.4
File
nemo_relay-0.8.4-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details
nemo_relay-0.8.4-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
nemo_relay-0.8.4-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details
nemo_relay-0.8.4-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details
nemo_relay-0.8.4-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details
nemo_relay-0.8.4-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details
nemo_relay-0.8.4-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details

Total release size: 72.7 MB

Release files / nemo_relay-0.8.4.tar.gz

Download URL nemo_relay-0.8.4.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
daaa980f1627e88cf1d2c6dbebc5b07bcc778150384323fc99fe52fba8713ce9
BLAKE2b-256 checksum
How to use checksums
b70f274daf96d674f0611b058ba2cc820cc266624360db086eceaa9e99a4f491
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / nemo_relay-0.8.4-cp311-abi3-win_arm64.whl

Download URL nemo_relay-0.8.4-cp311-abi3-win_arm64.whl
Size 9.2 MB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
89aedb375df24b9f312f1f8fc085898f25b5dceca6fbcbac52d2cce6a8b2678d
BLAKE2b-256 checksum
How to use checksums
24dc85a8bf6199725c0e582bed7a8956d08d02c3b797a611fe93819bc095aba1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / nemo_relay-0.8.4-cp311-abi3-win_amd64.whl

Download URL nemo_relay-0.8.4-cp311-abi3-win_amd64.whl
Size 9.7 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ffea09482334e136189ec7c759902cfde933756e9418d04b32f8bad7550b484f
BLAKE2b-256 checksum
How to use checksums
80a52fbab4fbf2b57e0c9a13b2b47cc45cfcf0c476f4ef3ad40829a34c442192
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / nemo_relay-0.8.4-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL nemo_relay-0.8.4-cp311-abi3-musllinux_1_2_x86_64.whl
Size 11.7 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
62e51d16e2c0dbe7f2e6ea27213baea3966f9ee5e838e376387cf86bb9a77abc
BLAKE2b-256 checksum
How to use checksums
9877c4539b6f00f7a89748738e851847031a4773d8c5dab3c7f338b56823a5d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / nemo_relay-0.8.4-cp311-abi3-musllinux_1_2_aarch64.whl

Download URL nemo_relay-0.8.4-cp311-abi3-musllinux_1_2_aarch64.whl
Size 11.3 MB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
6bd22b891d98f0da5ac302939627e85911b3f8a1647d27a96b52ed854722947b
BLAKE2b-256 checksum
How to use checksums
31ea0f878346fad556b45f59276c80486e256f7dcfe85d99640546509c44729f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / nemo_relay-0.8.4-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL nemo_relay-0.8.4-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 9.8 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
1fa379865236beafe2d116e5375f043a7393da8712476b81e8fdc84a1abd6449
BLAKE2b-256 checksum
How to use checksums
8e3f4637c46d565f0cabc5a1426ff04e824de82762941874158a44faeb734321
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / nemo_relay-0.8.4-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL nemo_relay-0.8.4-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 9.2 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
eb1e314ed83ab90c614fb4972d79489dd126a15b777004ffebe6b0fa4dab734a
BLAKE2b-256 checksum
How to use checksums
2c785b5d3ae13dd29dda9c0a2dc27490d207c78e47f3dd1901a272783a210e3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / nemo_relay-0.8.4-cp311-abi3-macosx_11_0_arm64.whl

Download URL nemo_relay-0.8.4-cp311-abi3-macosx_11_0_arm64.whl
Size 10.2 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
542e67a2ad6874450e01193c127ee526f2550b26c3769ab2583b57fab08f70b0
BLAKE2b-256 checksum
How to use checksums
168a7137f02f9e9e8b550f6db0e95e5bf5a145071f012d1fd085cee2932beccd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release history Release notifications | RSS feed

0.9.4

8 release files

0.9.3

8 release files

0.9.2

8 release files

0.9.1

8 release files

0.9.0

8 release files

This release

0.8.4 This release

8 release files

0.8.3

8 release files

0.8.2

8 release files

0.8.1

8 release files

0.8.0

8 release files

0.7.3

8 release files

0.7.2

8 release files

0.7.1

8 release files

0.7.0

8 release files

0.6.0

8 release files

0.5.0

5 release files

0.4.0

5 release files

0.3.0

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page