Vercel AI SDK

Vercel AI SDK Integration

Pass getLumiqVercelTelemetry() to experimental_telemetry. Works with generateText, streamText, and useChat — no restructuring required.

Vercel AI SDK is a TypeScript library for building AI-powered applications with Next.js, supporting multiple LLM providers through a unified interface.

zespan.com — vercel ai sdk trace
Zespan trace showing a Vercel AI SDK generateText call with token usage and latency

Getting Started

1

Install the SDK

Install @zespan/sdk alongside your existing Vercel AI SDK setup.

bash
npm install @zespan/sdk ai
2

Add telemetry to your AI calls

Pass getLumiqVercelTelemetry() to the experimental_telemetry option. Works with generateText, streamText, generateObject, and streamObject.

typescript
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { getLumiqVercelTelemetry } from '@zespan/sdk';

const result = await generateText({
  model: openai('gpt-4o'),
  prompt: 'Explain quantum entanglement simply',
  experimental_telemetry: getLumiqVercelTelemetry({
    apiKey: process.env.ZESPAN_API_KEY,
    recordInputs: true,
    recordOutputs: true,
  }),
});
3

View traces in Zespan

Open Trace Explorer. Vercel AI SDK calls appear with provider, model, token usage, cost, and latency.

What's captured automatically

  • Works with generateText, streamText, generateObject, streamObject
  • All Vercel AI SDK providers: OpenAI, Anthropic, Google, Groq, and more
  • Next.js App Router and Pages Router compatible
  • Streaming: time-to-first-token tracked accurately
  • useChat: client-side conversations linked to server-side traces via session propagation
  • Zero restructuring: attaches via experimental_telemetry option

FAQ

Does this work in Next.js Server Actions?

Yes. getLumiqVercelTelemetry() works in API routes, Server Actions, and edge functions.

Can I use this with useChat on the client side?

Yes. Pass session_id from the client-side useChat hook through to the server-side AI call and Zespan will group all turns into a session.

Start for free — 10K traces/month, no card needed

Vercel AI SDK integration works on all plans including the free tier.

← All integrations