Skip to main content
Sentry provides automatic instrumentation for popular AI and LLM providers, capturing detailed telemetry about model interactions, token usage, and performance.

Supported AI Providers

OpenAI

Monitor GPT-4, GPT-3.5, and other OpenAI models

Anthropic

Track Claude interactions and responses

Google GenAI

Instrument Gemini and other Google AI models

Vercel AI SDK

Monitor ai library function calls

AI Frameworks

LangChain

Automatic instrumentation for LangChain applications

LangGraph

Monitor agent workflows and state graphs

What Gets Captured

AI integrations follow OpenTelemetry Semantic Conventions for Generative AI:

Model Interactions

  • Operation Type: Chat completion, text generation, embedding
  • Model Name: GPT-4, Claude, Gemini, etc.
  • Provider: OpenAI, Anthropic, Google
  • Token Usage: Prompt tokens, completion tokens, total tokens
  • Timestamps: Start time, end time, duration

Performance Metrics

  • Response Time: How long each API call takes
  • Token Efficiency: Tokens per second
  • Error Rates: Failed API calls
  • Cost Tracking: Token usage for cost estimation

Content (Optional)

  • Prompts: Input messages and system prompts
  • Responses: Model completions and responses
  • Tool Calls: Function calling and tool usage
Content capture respects your sendDefaultPii setting.

Quick Start

Node.js

AI integrations are enabled by default in Node.js:
Just use your AI SDK normally:

Browser & Edge

For client-side AI monitoring, use manual instrumentation:

Privacy & Data Control

Default Behavior

By default, integrations do not capture prompts and responses:

Capturing Inputs and Outputs

Enable full content capture:

Granular Control

Control capture per integration:

Viewing AI Data in Sentry

AI operations appear as spans in your traces:

Span Attributes

Each AI span includes:

Performance Monitoring

Token Usage Tracking

Monitor token consumption across your application:

Cost Estimation

Use token data to estimate costs:

Latency Analysis

Error Tracking

AI errors are automatically captured:

Best Practices

Start with sendDefaultPii: false and enable content capture only where needed.

1. Privacy First

2. Monitor Token Usage

3. Use Sampling for High-Volume Apps

4. Add Business Context

Integration Compatibility

LangChain Auto-Disables Provider Integrations

When using LangChain, the OpenAI, Anthropic, and Google GenAI integrations are automatically disabled to prevent duplicate spans:

Manual Provider Usage

If you use providers directly alongside LangChain:

Platform Support

Auto: Enabled by default with automatic instrumentation Manual: Requires manual client instrumentation : Not supported

Next Steps

OpenAI Integration

Set up OpenAI monitoring

LangChain Integration

Instrument LangChain apps

Performance Best Practices

Optimize AI application performance

Privacy Guidelines

Handle sensitive AI data safely