Skip to main content
The Vercel AI SDK integration is available in the PandaProbe TypeScript SDK only. Vercel AI does not provide a Python SDK.

Installation

Install PandaProbe, the Vercel AI SDK, and the provider package used by your model. This example uses OpenAI.

Setup

Wrap the language model with PandaProbe middleware before passing it to generateText, streamText, or other Vercel AI SDK functions that use the language model middleware interface.
TypeScript
The wrapped model remains a normal Vercel AI language model. If there is no active PandaProbe trace, each generation creates a standalone trace. Inside withTrace(), the model call becomes a nested LLM span.

Generate text

TypeScript

Stream text

TypeScript
Streaming captures time-to-first-token, combines text deltas into one span output, and records final usage. The span is finalized if the stream completes, fails, or is cancelled before completion.

Trace an agent

For a native ToolLoopAgent in AI SDK 6 or 7, use wrapVercelAgent to capture the agent, its model steps, and actual tool executions. Use the wrapped model from Setup above:
TypeScript
The wrapper also accepts an existing agent instance. It records CHAIN → AGENT → LLM → TOOL; model middleware enriches the same LLM spans without duplicating them. Without middleware, model timing comes from native step callbacks. Proposed tool calls without execution do not create tool spans. For streaming, consume the stream through completion or explicitly cancel it. An abandoned consumer is not a completion signal. See Reflect’s Vercel integration to combine the traced constructor with persistent guidance and reflection.

What gets traced

Custom span name

The default span and standalone trace name is vercel-ai-generate. Override it when one application uses multiple wrapped models:
TypeScript

Combine with manual tracing

TypeScript
This produces one trace with the Vercel model call nested beneath it as an LLM span.