Vercel AI SDK

generateText, streamText, generateObject, and tool calls capture once you opt in with experimental_telemetry.

The Vercel AI SDK emits OpenTelemetry spans only when you enable telemetry per call. With the Trodo SDK initialised, every ai call inside wrap your agent flagged with experimental_telemetry becomes a span.

On Next.js with @vercel/otel? You can skip the Trodo SDK install and use the env-var-only OTLP path instead. See Use your existing OpenTelemetry. The SDK install below is the right choice when you want wrapAgent boundaries, feedback, or MCP.

What's captured

CallSpan kindAuto-extracted
generateTextllmmodel, provider, tokens, prompt, completion
streamTextllmsame, accumulated
generateObject / streamObjectllmmodel, tokens, schema, parsed object
tool() and the tool-call looptooltool name, input, output
embed / embedManyllmmodel, tokens

The provider field is whichever adapter you use (openai, anthropic, google).

Install

npm install ai @ai-sdk/openai

No OpenTelemetry package is needed; the ai SDK includes its own OTel integration.

Minimal example

import trodo from 'trodo-node';
import { generateText, tool } from 'ai';
import { openai } from '@ai-sdk/openai';
import { z } from 'zod';

trodo.init({ siteId: process.env.TRODO_SITE_ID });

await trodo.wrapAgent('ai-sdk-bot', async (run) => {
  const { text } = await generateText({
    model: openai('gpt-4o-mini'),
    prompt: 'What is the weather in SF?',
    tools: {
      get_weather: tool({
        description: 'Current weather in a city',
        parameters: z.object({ city: z.string() }),
        execute: async ({ city }) => `Sunny in ${city}, 72F`,
      }),
    },
    experimental_telemetry: { isEnabled: true }, // required
  });
  run.setOutput(text);
});

The experimental_telemetry: { isEnabled: true } flag is required. Without it, the AI SDK emits no spans.

On this page