> ## Documentation Index
> Fetch the complete documentation index at: https://aivision.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Read the relevant procedure and prerequisites before suggesting commands. Cite the section and give an observable check. Treat sample data as illustrative. Report product actions and results only when verified in the user's environment.

# Connect your Agent through NeMo Relay

> Choose Python framework integration or Node.js SDK manual instrumentation and read the current Trace in AI Vision.

This guide is for developers who can change Agent code. The Python path uses Relay's framework integration. On Node.js 24+, use the official SDK to record requests and tool calls manually. For Node.js 22, see [Langfuse's local tool example](https://aivision.mintlify.site/en/integrations/langfuse.md#sdk-examples). For ready-made apps such as Codex and Claude Code, install the dedicated plugin using [Agent application integration](https://aivision.mintlify.site/en/integrations/agents.md).

> [!NOTE]
>
> For an installed Hermes Agent, use [Hermes native Relay integration](https://aivision.mintlify.site/en/integrations/hermes.md). It uses the host’s built-in runtime and Hermes application card, without this page’s framework examples, Python startup helper or Node.js manual instrumentation. The host and Relay version contracts differ between these paths.

Relay runs inside your application process and exports traces directly to AI Vision. This integration does not require a separate Relay backend. Choose the path that matches your application:

| Your application | Integration in this guide | Requirements for the first example |
| - | - | - |
| Python with LangChain, LangGraph, or Deep Agents | Official framework integration + AI Vision startup helper | Python 3.11+, AI Vision credentials, and a model API key |
| Server-side JavaScript / TypeScript | Manual instrumentation with the official Node.js SDK | Node.js 24+ and AI Vision credentials; no model API key for the local tool example |

The first success check is to find **the Trace ID from this request** in AI Vision and inspect the calls that ran. Integration credentials authorize data export to AI Vision; a model API key authorizes model calls. They are not interchangeable.

## 1. Select a language and obtain connection settings

Open **Agent Access → Agent Market → Custom Agent integrations**, choose **Via NeMo Relay**, then select **Python** for LangChain, LangGraph, or Deep Agents, or **JavaScript / TypeScript** for **Node.js SDK**. Select or create an AI Vision project and obtain complete credentials in the environment variables section.

| Setting | Purpose |
| - | - |
| `AIVISION_OTLP_ENDPOINT` | The complete, reachable `/api/public/otel/v1/traces` URL. A remote application cannot use the deployment machine's `127.0.0.1`. |
| `AIVISION_OTLP_AUTHORIZATION` | The generated Basic authorization value for the selected project and space. |
| `AIVISION_SERVICE_NAME` | Identifies the application service exporting data. |

Both the Python `relay_tracing.py` helper and the Node.js example read these variables. For your first run, execute the page's **Shell** settings in the same terminal as the example. Saving a `.env` file does not load it automatically: use the page's loading command for Python, or `--env-file` below for Node.js. Configuration alone does not add instrumentation.

## 2. Run a complete example first

The commands below use Bash/zsh. The Python example requires 3.11+; if your interpreter is called `python3`, replace `python` in both installation and execution commands.

### Python: LangChain example

For the first check, choose **Python → LangChain** and follow these steps:

[![Complete LangChain example, connection settings and download button on the Python NeMo Relay integration page](https://mintcdn.com/aivision/HGaGiOq1xpqDNh4a/assets/figures/onboarding-relay-python.en.light.jpg?fit=max\&auto=format\&n=HGaGiOq1xpqDNh4a\&q=85\&s=faa177a0e79c63a48d7cc6bf741e5efb)](https://aivision.mintlify.site/assets/figures/onboarding-relay-python.en.light.jpg)

[![Complete LangChain example, connection settings and download button on the Python NeMo Relay integration page](https://mintcdn.com/aivision/HGaGiOq1xpqDNh4a/assets/figures/onboarding-relay-python.en.dark.jpg?fit=max\&auto=format\&n=HGaGiOq1xpqDNh4a\&q=85\&s=6288a182dae4d20ed87c5ea3f6f7f033)](https://aivision.mintlify.site/assets/figures/onboarding-relay-python.en.dark.jpg)

NeMo Relay Python: complete LangChain example and connection settings · Demo data · Click to enlarge

1. Use **Select project**, or enter a name and click **Create project**. Click **Get credentials** under **Environment variables**. Ask the space administrator to check permissions if either action fails.
2. Choose **Run a complete example** and copy the **Shell** environment settings into the terminal running Python. Replace `OPENAI_API_KEY`, `OPENAI_MODEL`, and `OPENAI_BASE_URL` with working model settings. Confirm that this machine can reach `AIVISION_OTLP_ENDPOINT` and the authorization value is complete, without placeholders or masks.
3. Click **Download example** and save `relay-langchain-agent-middleware.py` in a practice directory. The complete file already contains the startup helper; no separate `relay_tracing.py` is needed. In a Python 3.11+ environment, enter that directory, install dependencies, and run:

```bash theme={null}
python --version
python -m venv .venv
source .venv/bin/activate
python -m pip install "nemo-relay[langchain]>=0.9.3,<0.10" "langchain>=1.4.3,<2" "langchain-openai>=1.6.7,<2"
python relay-langchain-agent-middleware.py
```

4. Keep the 32 hexadecimal characters printed after `AI Vision trace_id`. Enter them in **Trace ID for this request**, select **Verify this Trace**, and open the details to match the Trace ID, model, and tool nodes. You can find it again through **My Agent channel → Agent traces**.
5. After reading back this request, switch to **Add to existing code** and replace `existing_*`, input, and session placeholders with your application objects.

If no Trace ID is printed, resolve dependency, model configuration, or execution errors first. If an ID is printed but cannot be read back, check the project, reachable endpoint, complete credentials, and exporter logs. Retry or follow [No data troubleshooting](https://aivision.mintlify.site/en/help/no-data.md).

### JavaScript / TypeScript: Node.js local tool example

This example calculates `7 × 9` so you can check the connection and the request/tool relationship. It makes no model calls, needs no model API key, and produces no model usage.

[![Complete Node.js SDK example, connection settings and download button on the JavaScript TypeScript NeMo Relay integration page](https://mintcdn.com/aivision/HGaGiOq1xpqDNh4a/assets/figures/onboarding-relay-js.en.light.jpg?fit=max\&auto=format\&n=HGaGiOq1xpqDNh4a\&q=85\&s=2a1a1b1db7ac9af647303b074b5d46df)](https://aivision.mintlify.site/assets/figures/onboarding-relay-js.en.light.jpg)

[![Complete Node.js SDK example, connection settings and download button on the JavaScript TypeScript NeMo Relay integration page](https://mintcdn.com/aivision/HGaGiOq1xpqDNh4a/assets/figures/onboarding-relay-js.en.dark.jpg?fit=max\&auto=format\&n=HGaGiOq1xpqDNh4a\&q=85\&s=a96e406dc865f6e03d5df98a840d28d6)](https://aivision.mintlify.site/assets/figures/onboarding-relay-js.en.dark.jpg)

NeMo Relay JavaScript / TypeScript: complete Node.js SDK example · Demo data · Click to enlarge

1. Select **JavaScript / TypeScript → Node.js SDK → Run a complete example**. Install dependencies in a new practice directory to keep its module settings separate from your application:

```bash theme={null}
mkdir aivision-relay-quickstart
cd aivision-relay-quickstart
node --version
npm init -y
npm pkg set type=module
npm install "nemo-relay-node@>=0.9.3 <0.10"
```

`node --version` must report version 24 or newer. This example uses server-side Node.js and ESM modules; it does not run in a browser.

2. Select or create a project on the page, click **Get credentials**, and execute the **Shell** environment settings in this terminal. Use the complete authorization value and an `AIVISION_OTLP_ENDPOINT` reachable from this machine. This example only needs the three `AIVISION_*` variables.
3. Click **Download example**, place `relay-nodejs.ts` in the practice directory, and run:

```bash theme={null}
node relay-nodejs.ts
```

If you selected **.env**, save the settings as `.env` in the same directory and use:

```bash theme={null}
node --env-file=.env relay-nodejs.ts
```

4. A successful run prints output like this, with new IDs each time:

```text theme={null}
AI Vision trace_id: <32 hexadecimal characters>
63
AI Vision session_id: <session ID>
```

5. Enter this Trace ID in **Trace ID for this request** and click **Verify this Trace**. Open the details and look for a request root with a `multiply` tool child, input `a=7, b=9`, and result `63`. **No model node is expected for this example.**

If a Trace ID appears but cannot be read back, follow section 4. Resolve execution errors before checking success; printing an ID alone is not sufficient. In an existing project with `"type": "commonjs"`, save the file as `relay-nodejs.mts`, run `node relay-nodejs.mts` (optionally with `--env-file=.env`), and use `.mts` in its import path.

## 3. Integrate your existing application

### Python framework integration

Install the dependencies shown on the page. Save the supplied startup module as `relay_tracing.py` where your application can import it. Apply the “Add to existing code” snippet while preserving your model, tools, and business configuration.

| Component | Responsibility |
| - | - |
| Official callback | Records graph or Agent lifecycles and associates them with the request. |
| Official middleware | Wraps actual model and tool execution. A callback alone does not replace it. |
| AI Vision `relay_tracing.py` | Configures OTLP export, request identity, business input/output, and process lifecycle. |

Apply the changes for your framework:

* **LangChain:** add `NemoRelayMiddleware` to existing middleware and merge `NemoRelayCallbackHandler` into invocation config. Preserve business callbacks.
* **LangGraph:** the callback records graph lifecycle. Nested LangChain agents also need middleware and the parent config. Use official `create_tool_node` for standalone tool nodes.
* **Deep Agents:** `add_nemo_relay_integration` adds middleware to the main agent and dictionary subagents. Merge `NemoRelayDeepAgentsCallbackHandler`. Check internal calls separately for default general-purpose, precompiled, and remote subagents.

### Node.js / TypeScript manual instrumentation

After verifying the local example, select **Add to existing code**. Keep the downloaded `relay-nodejs.ts` and import its startup, request, and shutdown functions. It is a reusable module: importing it does not run the multiplication example. It does not need Python's `relay_tracing.py`.

Replace `existingAgent` with your application function, pass the session ID and input to `handleRequest`, and register `onShutdown` with the service shutdown handler. Preserve the business return value and await child tasks before returning from the request. Keep credentials on the server.

The request wrapper records request input and output. Instrument internal tools and models with official APIs such as `toolCallExecuteAsync` / `llmCallExecuteAsync` at boundaries you control. This example does not automatically instrument LangChain.js or LangGraph.js, or provide the coverage of Python middleware.

### Request and service lifecycle

For Python, call `start_tracing()` once at service startup. Give each request its own `request_scope`, reuse the business session ID, and set the explicit business output after execution. After all requests finish, call `stop_tracing()` during shutdown; asynchronous services use `await stop_tracing_async()`.

For Node.js, call the example's `startTracing()` once at startup, use `runWithTrace()` per request, and `await stopTracing()` after all requests finish. These functions come from the downloaded example module; they are not top-level Relay SDK APIs.

Do not shut down the process exporter after each request. Review existing telemetry before adding another collector. Keep one complete collection path per destination and preserve the application's existing environment.

Run a model and tool request with the Python framework example, or a local tool operation with the complete Node.js example. Save the printed `trace_id`, then verify actual requests after integrating your application.

## 4. Read and inspect the Trace

Enter that `trace_id` on the integration page to read the selected project's data. If you know the expected Span count from an independent execution record, enter it in the optional field before verifying. Inspect the unique Span count, storage count, read completeness, parent relationships, and usage results using the [shared verification result guide](https://aivision.mintlify.site/en/integrations/frameworks.md#verify-ingestion), then open the details and verify:

1. The record belongs to this request and project.
2. Any model or tool calls that actually ran appear under the expected parents.
3. Input, output, and errors match execution. Check usage only when the source provides it.
4. For subagents, inspect internal calls as well as the subagent node.

A complete read describes the stored data returned by the backend; it does not prove that every business call was captured. The Node.js local-tool example has no model call: when the backend confirms there are no billable calls, usage coverage is **not applicable**. Missing evidence remains **unknown**, while an explicitly reported zero remains zero. For a partial read or structural differences, inspect the listed Span IDs and compare against the application's execution record. If the record is absent, check the URL, credentials, exporter logs, and [No data troubleshooting](https://aivision.mintlify.site/en/help/no-data.md).

## Versions and further reading

Python examples use **Relay 0.9.x / Python 3.11+** (`nemo-relay>=0.9.3,<0.10`), with 0.9.3 as the validated baseline. Node.js examples use **Node.js 24+ / `nemo-relay-node>=0.9.3 <0.10`**. Relay is pre-1.0, so installation stays within the same minor series. Use the framework dependency ranges shown on the integration page. Official documentation may describe newer releases. Official capabilities and examples validated with AI Vision have separate scopes. Recheck APIs, export settings, and real requests before upgrading.

Streaming, cancellation, TTFT, and subagent cleanup have version-dependent boundaries. See the [source integration notes and validation evidence](https://github.com/ob-labs/ai-vision-ob/tree/main/ai-vision/agent-plugins/nvidia-nemo-relay) and [known issues](https://github.com/ob-labs/ai-vision-ob/blob/main/KNOWN_ISSUES.md).

Official references: [Relay overview](https://docs.nvidia.com/nemo/relay/about-nemo-relay/overview), [LangChain](https://docs.nvidia.com/nemo/relay/supported-integrations/langchain), [LangGraph](https://docs.nvidia.com/nemo/relay/supported-integrations/langgraph), [Deep Agents](https://docs.nvidia.com/nemo/relay/supported-integrations/deepagents), [Node.js quick start (0.9.x)](https://docs.nvidia.com/nemo/relay/v0.9.4/getting-started/quick-start/nodejs), and [OTLP export](https://docs.nvidia.com/nemo/relay/configure-plugins/observability/opentelemetry). Relay also provides application and CLI integrations. AI Vision recommends dedicated collectors for existing applications; this guide covers code integration for custom Agents.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.