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:Configuration
Integration Options
boolean
default:"auto-detected"
Force the integration to be enabled even if the
ai package is not detectedPer-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 mainai library functions:
Text Generation
generateText()- Generate text completionstreamText()- Stream text completion
Structured Output
generateObject()- Generate structured datastreamObject()- Stream structured data
Embeddings
embed()- Generate single embeddingembedMany()- Generate multiple embeddings
Practical Examples
Chat Application
Data Extraction
Content Moderation
Semantic Search
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
Selective Recording
Filter Sensitive Data
Troubleshooting
Spans Not Appearing
Ensure you’ve added the integration:Telemetry Not Captured
Ensureexperimental_telemetry.isEnabled: true is set: