Skip to main content
The Vercel AI SDK integration adds tracing support for the ai library from Vercel.
This integration is not enabled by default. You must manually add it to your Sentry configuration.

Installation

1

Add the Integration

2

Enable Telemetry Per Call

You must opt-in to telemetry for each AI function call:

Basic Usage

Generate Text

Stream Text

Generate Object

Capturing Inputs and Outputs

To capture prompts and responses, you must opt-in per function call:
Unlike other AI integrations, sendDefaultPii does not affect the Vercel AI integration. You must explicitly set recordInputs and recordOutputs in each function call.

Configuration

Integration Options

boolean
default:"auto-detected"
Force the integration to be enabled even if the ai package is not detected

Per-Call Telemetry Options

boolean
default:"false"
Enable telemetry for this specific call
boolean
default:"false"
Capture input prompts for this call
boolean
default:"false"
Capture output responses for this call

Supported Functions

The integration supports all main ai library functions:

Text Generation

  • generateText() - Generate text completion
  • streamText() - Stream text completion

Structured Output

  • generateObject() - Generate structured data
  • streamObject() - Stream structured data

Embeddings

  • embed() - Generate single embedding
  • embedMany() - Generate multiple embeddings

Practical Examples

Chat Application

Data Extraction

Content Moderation

Multi-Step Agent

Platform Support

Viewing Data in Sentry

Vercel AI operations appear as spans in traces:

Performance Monitoring

  • Response Times: Track AI function call latency
  • Token Usage: Monitor token consumption
  • Error Rates: Identify failed AI calls
  • Model Performance: Compare different models

Source Code

The Vercel AI integration is implemented in: packages/node/src/integrations/tracing/vercelai/index.ts:19

Privacy Best Practices

Only enable recordInputs and recordOutputs for non-sensitive use cases.

Selective Recording

Filter Sensitive Data

Troubleshooting

Spans Not Appearing

Ensure you’ve added the integration:

Telemetry Not Captured

Ensure experimental_telemetry.isEnabled: true is set:

Missing Input/Output Data

Explicitly enable recording: