V

Vercel AI SDK

Native telemetry integration for the Vercel AI SDK. Every generateText, streamText, agent loop, and tool call traced with tokens, cost, and latency.

Built by

telemetry.dev

Language

TypeScript

Packages

@telemetry-dev/ai-sdk

Category

AI frameworks

About the Vercel AI SDK integration

@telemetry-dev/ai-sdk plugs into the AI SDK's telemetry surface. On ai@7 it covers generateText, streamText, Agent, generateObject, streamObject, embed, embedMany, and rerank; a dedicated @telemetry-dev/ai-sdk/v6 entry covers ai@6. Each call becomes its own OpenTelemetry trace: a root span, a chat span per model step, and an execute_tool span per tool call — with provider requests and tool execute runs parented into the same trace.

Key features

  • One integration entry: Add telemetryDev() to telemetry.integrations (or experimental_telemetry on v6) — no manual spans, no exporter config.
  • Agent loops and tools: Multi-step runs and nested AI SDK calls made from inside a tool stay in the outer call's trace.
  • Tokens and cost: Cache-read, cache-write, and reasoning token breakdowns when the provider reports them; cost computed server-side from real usage and current pricing.
  • Explicit user context: runtimeContext keys reach telemetry only when opted in via includeRuntimeContextuserId maps to user.id, sessionId to the conversation id.
  • Standard OTLP, no lock-in: Built on OpenTelemetry, so your data stays portable.

Get started

import { generateText } from "ai";
import { telemetryDev } from "@telemetry-dev/ai-sdk";

const { text } = await generateText({
  model,
  prompt: "Summarize the incident report.",
  runtimeContext: { userId: "u_123", sessionId: "s_456" },
  telemetry: {
    functionId: "summarize-incident",
    includeRuntimeContext: { userId: true, sessionId: true },
    integrations: [telemetryDev()],
  },
});

Set TELEMETRY_DEV_API_KEY and your first traces land in about five minutes — no key means the integration is a complete no-op. Requires ai >= 6.0.111; import from the entry matching your major version.