Skip to main content
This module provides automatic instrumentation for the Anthropic SDK TypeScript, which may be used in conjunction with @arizeai/phoenix-otel.

Install

Setup

To instrument your application, use the register function from @arizeai/phoenix-otel and manually instrument the Anthropic SDK. Create the instrumentation.ts file:
From @anthropic-ai/sdk 0.134.0, the Anthropic SDK also records its own traces. With the instrumentation on, every call would appear twice in Phoenix, with tokens and cost counted twice. Pass openTelemetry: false when you create the client, as in the example below, or set ANTHROPIC_OPEN_TELEMETRY=false in your environment.

Run Anthropic

Import the instrumentation.ts file first, then use Anthropic as usual.

Observe

After setting up instrumentation and running your Anthropic application, traces will appear in the Phoenix UI for visualization and analysis.

Custom Tracer Provider

You can specify a custom tracer provider for Anthropic instrumentation:

Pass tracerProvider on instantiation

Set tracerProvider after instantiation

Resources