Vercel AI SDK Tracing
Automatically trace Vercel AI SDK agent executions, tool calls, and multi-step workflows.
Vercel AI SDK integration captures traces from your Vercel AI SDK applications, including agent execution flow, tool invocations, and multi-step reasoning processes. This integration is designed for TypeScript applications.
Quickstart
AI SDK 7 registers telemetry once at startup with @ai-sdk/otel. After that,
AI SDK calls emit OpenTelemetry spans through the registered integration.
Install Dependencies
npm install ai@^7 @ai-sdk/openai@^4 @ai-sdk/otel judgeval zodyarn add ai@^7 @ai-sdk/openai@^4 @ai-sdk/otel judgeval zodpnpm add ai@^7 @ai-sdk/openai@^4 @ai-sdk/otel judgeval zodbun add ai@^7 @ai-sdk/openai@^4 @ai-sdk/otel judgeval zodInitialize Tracer
Create an instrumentation file that initializes the Judgment tracer and registers AI SDK OpenTelemetry globally:
import { OpenTelemetry } from "@ai-sdk/otel";
import { registerTelemetry } from "ai";
import { Tracer } from "judgeval";
await Tracer.init({
projectName: "AI SDK Weather Agent",
});
registerTelemetry(
new OpenTelemetry({
tracer: Tracer.getOTELTracer(),
}),
);Run Your Agent
Import the instrumentation file before your AI SDK calls.
import "./instrumentation";
import { openai } from "@ai-sdk/openai";
import { generateText, tool } from "ai";
import * as z from "zod/v4";
import { Tracer } from "judgeval";
async function main() {
const result = await generateText({
model: openai("gpt-5.2"),
tools: {
weather: tool({
description: "Get the weather in a location",
inputSchema: z.object({
location: z.string().describe("The location to get the weather for"),
}),
execute: async ({ location }) => ({
location,
temperature: 72 + Math.floor(Math.random() * 21) - 10,
}),
}),
},
prompt: "What is the weather in San Francisco?",
});
return result;
}
await main().catch(console.error);
await Tracer.shutdown(); 

Example: Math Agent with Multi-Step Reasoning
Install mathjs for this example:
npm install mathjsyarn add mathjspnpm add mathjsbun add mathjsimport { OpenTelemetry } from "@ai-sdk/otel";
import { registerTelemetry } from "ai";
import { Tracer } from "judgeval";
await Tracer.init({
projectName: "AI SDK Math Agent",
});
registerTelemetry(
new OpenTelemetry({
tracer: Tracer.getOTELTracer(),
}),
);import "./instrumentation";
import { openai } from "@ai-sdk/openai";
import { generateText, stepCountIs, tool } from "ai";
import * as mathjs from "mathjs";
import * as z from "zod/v4";
import { Tracer } from "judgeval";
async function main() {
return await generateText({
model: openai("gpt-5.2"),
tools: {
calculate: tool({
description:
"A tool for evaluating mathematical expressions. Example expressions: " +
"'1.2 * (2 + 4.5)', '12.7 cm to inch', 'sin(45 deg) ^ 2'.",
inputSchema: z.object({ expression: z.string() }),
execute: async ({ expression }) => mathjs.evaluate(expression),
}),
},
stopWhen: stepCountIs(10),
system:
"You are solving math problems. " +
"Reason step by step. " +
"Use the calculator when necessary. " +
"The calculator can only do simple additions, subtractions, multiplications, and divisions. " +
"When you give the final answer, provide an explanation for how you got it.",
prompt:
"A taxi driver earns $9461 per 1-hour work. " +
"If he works 12 hours a day and in 1 hour he uses 14-liters petrol with price $134 for 1-liter. " +
"How much money does he earn in one day?",
});
}
await Tracer.observe(main)().catch(console.error);
await Tracer.shutdown();Quickstart
AI SDK 6 and older enables telemetry on each AI SDK call with
experimental_telemetry.
Install Dependencies
npm install ai @ai-sdk/openai judgeval zodyarn add ai @ai-sdk/openai judgeval zodpnpm add ai @ai-sdk/openai judgeval zodbun add ai @ai-sdk/openai judgeval zodInitialize Tracer
import { Tracer } from "judgeval";
await Tracer.init({
projectName: "AI SDK Weather Agent",
});Enable Telemetry
Enable experimental_telemetry and pass the Judgment OpenTelemetry tracer.
import "./instrumentation";
import { openai } from "@ai-sdk/openai";
import { generateText, tool } from "ai";
import { z } from "zod";
import { Tracer } from "judgeval";
async function main() {
const result = await generateText({
model: openai("gpt-5.2"),
tools: {
weather: tool({
description: "Get the weather in a location",
inputSchema: z.object({
location: z.string().describe("The location to get the weather for"),
}),
execute: async ({ location }) => ({
location,
temperature: 72 + Math.floor(Math.random() * 21) - 10,
}),
}),
},
experimental_telemetry: {
isEnabled: true,
tracer: Tracer.getOTELTracer(),
},
prompt: "What is the weather in San Francisco?",
});
return result;
}
await main().catch(console.error);
await Tracer.shutdown(); Next Steps
- OpenTelemetry Integration - Learn more about OpenTelemetry tracing with Judgment.
- Agent Behavior Monitoring - Monitor your Vercel AI SDK agents in production with behavioral scoring.
- Tracing Reference - Learn more about Judgment's tracing capabilities and advanced configuration.