Skip to main content
Phoenix traces Vercel AI SDK (>= 7) applications through the AI SDK’s OpenTelemetry integration (@ai-sdk/otel). The simplest setup is @arizeai/phoenix-otel, which handles the OpenTelemetry provider, OpenInference span processing, and export to Phoenix in a single register() call.

Version compatibility

AI SDK v7 telemetry requires Node.js 22 or newer.

Installation

Ensure your installed version of @opentelemetry/api matches the version installed by @ai-sdk/otel otherwise the AI SDK will not emit traces to the TracerProvider that you configure. If you install ai before the other packages, then dependency resolution in your package manager should install the correct version.

Setup

Since AI SDK v7, telemetry is emitted once you register a telemetry integration with registerTelemetry(new OpenTelemetry(...)). Pair that with register() from @arizeai/phoenix-otel, which processes the resulting spans and exports them to Phoenix:
Import this file before the rest of your program executes, e.g. node --import ./instrumentation.ts index.ts, or import "./instrumentation.js" at the top of your application’s entrypoint. Once the telemetry integration is registered, AI SDK calls are traced by default; no per-call configuration is required. Use the telemetry option for per-call metadata such as functionId, or to opt out with isEnabled: false.
This applies to agents as well: a ToolLoopAgent run is traced end to end, with the agent, each LLM step, and every tool call captured as spans in a single trace. See the AI SDK agent example for a complete runnable project.
register() uses a batch span processor by default, so spans still queued when a short-lived script exits may not be exported. Call await provider.shutdown() before exit to flush them, or pass batch: false to register() for immediate export.

Next.js

In a Next.js project, register the telemetry integration and @vercel/otel from the register() function in instrumentation.ts, using the OpenInference span processor from @arizeai/openinference-vercel, the same processor @arizeai/phoenix-otel uses under the hood:
See Vercel’s instrumentation guide for more details on configuring your instrumentation file and @vercel/otel within a Next.js project.
When instrumenting a Next.js application, traced spans will not be “root spans” when the OpenInference span filter is configured. This is because Next.js parents spans underneath http requests, which do not meet the requirements to be an OpenInference span.

Examples

For details on Vercel AI SDK telemetry see the Vercel AI SDK Telemetry documentation.