text
stringlengths
0
59.1k
debug: true, // set to true for development
});
// Initialize OpenTelemetry SDK
const sdk = new NodeSDK({
traceExporter: voltAgentExporter,
instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();
```
:::note
Complete working example: https://github.com/VoltAgent/vercel-ai-sdk-observability
Track AI calls, tool usage, and multi-agent workflows with minimal code changes.
:::
## Basic Telemetry
Insert a single line in your current Vercel AI code:
```typescript
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
const result = await generateText({
model: openai("gpt-4o-mini"),
prompt: "Hello, how are you?",
experimental_telemetry: {
isEnabled: true, // ← That's it!
},
});
```
![Vercel AI SDK Integration Basic Exampla](https://cdn.voltagent.dev/docs/vercel-ai-observability-demo/vercel-ai-demo-basic.gif)
And done! πŸŽ‰
You may look at your agent in the VoltOps LLM Observability dashboard. It will be displayed by default as "ai-assistant" but _no problems_. For the moment, your calls to AI are being tracked, you can look at the execution flow.
You'll have a message like this in the console:
```
πŸ“‹ VoltAgent: Using default agent for tracking.
πŸ’‘ For improved tracking, add agentId to your metadata
```
:::tip Don't Worry!
This message is completely normal! VoltAgent automatically uses a default agent when no `agentId` is provided. This is actually helpful for getting started quickly. You can always customize it later.
:::
Don't worry about this, this is normal. Let's move on to the next step for improved tracking.
## Name Your Agent & Tool Usage
```typescript
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { z } from "zod";
const result = await generateText({
model: openai("gpt-4o-mini"),
prompt: "What's the weather in Tokyo?",
tools: {
weather: {
description: "Get the weather in a place",
parameters: z.object({
location: z.string().describe("The place to get the weather for"),
}),
execute: async ({ location }) => {
await new Promise((resolve) => setTimeout(resolve, 1000));
return {
location,
temperature: 72 + Math.floor(Math.random() * 21) - 10,
};
},
},
},
experimental_telemetry: {
isEnabled: true,
metadata: {
agentId: "weather-assistant", // ← Now it has a name!
instructions: "You are a helpful weather assistant",
},
},
});
```
![Vercel AI SDK Integration Basic Exampla](https://cdn.voltagent.dev/docs/vercel-ai-observability-demo/vercel-ai-demo-with-tools.gif)
**What's the difference?**
- You see "weather-assistant" in the VoltOps dashboard rather than "ai-assistant"
- You see tool usage - which tool was applied when, inputs/outputs
- You can view instructions as documentation
Seriously, this is _very_ useful already.
## Production-Ready Tracking