Skip to main content

Requirements

OpenInference JavaScript requires:
  • Node.js 10 or higher
  • npm, yarn, or pnpm package manager

Installation

Core Dependencies

First, install the OpenTelemetry SDK packages:
npm install --save @opentelemetry/exporter-trace-otlp-http \
  @opentelemetry/exporter-trace-otlp-proto \
  @opentelemetry/resources \
  @opentelemetry/sdk-trace-node \
  @opentelemetry/instrumentation

Instrumentation Packages

Install the instrumentation for your LLM framework:
# OpenAI
npm install --save @arizeai/openinference-instrumentation-openai

# LangChain
npm install --save @arizeai/openinference-instrumentation-langchain

# Anthropic
npm install --save @arizeai/openinference-instrumentation-anthropic

# AWS Bedrock
npm install --save @arizeai/openinference-instrumentation-bedrock

Manual Instrumentation

For manual instrumentation, install the semantic conventions package:
npm install --save @arizeai/openinference-semantic-conventions

Core Utilities (Optional)

For advanced tracing features like context propagation and span wrappers:
npm install --save @arizeai/openinference-core

Basic Setup

Create an instrumentation file to configure OpenTelemetry:
instrumentation.ts
import { registerInstrumentations } from "@opentelemetry/instrumentation";
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
import { OpenAIInstrumentation } from "@arizeai/openinference-instrumentation-openai";

const provider = new NodeTracerProvider();
provider.register();

registerInstrumentations({
  instrumentations: [new OpenAIInstrumentation()],
});
The instrumentation must run before any other code in your application. Load it using the -r flag:
node -r ./instrumentation.js ./app.js

Next Steps

Core Package

Learn about OITracer, context attributes, and span wrappers

Semantic Conventions

Explore OpenInference semantic conventions for JavaScript

Instrumentations

View all available instrumentation packages

Quickstart

Follow the quickstart guide

Build docs developers (and LLMs) love