OpenInference Core utilities for LLM tracing in TypeScript
This package provides OpenInference Core utilities for LLM Traces, including tracing helpers, decorators, and context attribute propagation.
If you are tracing into Phoenix, @arizeai/phoenix-otel re-exports this package’s helpers, context utilities, attribute builders, and OITracer from a single import path alongside Phoenix registration. The wrappers resolve the default tracer when the wrapped function runs, which is useful for experiments and other workflows that swap providers.
The remaining OpenInference span kinds each have a matching wrapper. Like traceChain/traceAgent/traceTool, each is a shorthand for withSpan(fn, { ...options, kind }) and accepts the same options minus kind. These wrappers are marked @experimental and may change in a future release.
Wrapper
Span kind
Use it for
traceLLM
LLM
Language-model invocations — chat/text completions and other inference calls
traceRetriever
RETRIEVER
Fetching documents from a knowledge base, vector store, or search index (RAG)
traceReranker
RERANKER
Reordering or scoring candidate documents by relevance
traceEmbedding
EMBEDDING
Converting text or data into vector representations
traceGuardrail
GUARDRAIL
Safety, validation, or policy checks (moderation, PII, compliance)
traceEvaluator
EVALUATOR
Scoring output quality — relevance, correctness, or LLM-as-a-judge
tracePrompt
PROMPT
Constructing, rendering, or templating a prompt before a model call
import { context } from "@opentelemetry/api";import { setSession } from "@arizeai/openinference-core";context.with(setSession(context.active(), { sessionId: "session-id" }), () => { // Calls within this block will generate spans with the attributes: // "session.id" = "session-id"});
Control settings like data privacy and payload sizes. You may want to keep sensitive information from being logged for security reasons, or limit the size of base64 encoded images.
These values can also be controlled via environment variables. See the configuration spec for more information.
import { OpenAIInstrumentation } from "@arizeai/openinference-instrumentation-openai";const traceConfig = { hideInputs: true };const instrumentation = new OpenAIInstrumentation({ traceConfig });