Google Gen AI
Adds instrumentation for Google Gen AI SDK.
This integration works in the Node.js, Cloudflare Workers, and Vercel Edge Functions runtimes. It requires SDK version 10.14.0 or higher.
Import name: Sentry.googleGenAIIntegration
The googleGenAIIntegration adds instrumentation for the @google/genai SDK to capture spans by automatically wrapping Google Gen AI client calls and recording LLM interactions with configurable input/output recording.
It is enabled by default and will automatically capture spans for Google Gen AI SDK method calls. You can opt-in to capture inputs and outputs by setting recordInputs and recordOutputs in the integration config:
Sentry.init({
dsn: "",
tracesSampleRate: 1.0,
integrations: [
Sentry.googleGenAIIntegration({
recordInputs: true,
recordOutputs: true,
}),
],
});
Type: boolean
Records inputs to Google Gen AI SDK method calls (such as prompts and messages).
Defaults to true if sendDefaultPii is true.
Sentry.init({
integrations: [Sentry.googleGenAIIntegration({ recordInputs: true })],
});
Type: boolean
Records outputs from Google Gen AI SDK method calls (such as generated text and responses).
Defaults to true if sendDefaultPii is true.
Sentry.init({
integrations: [Sentry.googleGenAIIntegration({ recordOutputs: true })],
});
By default this integration adds tracing support to Google Gen AI SDK method calls including:
models.generateContent()- Make an API request to generate content with a given model.models.generateContentStream()- Make an API request to generate content with a given model and yields the response in chunks.chats.create()- Create chat sessions.sendMessage()- Send messages in chat sessions.sendMessageStream()- Stream messages in chat sessions.
The integration will automatically detect streaming vs non-streaming requests and handle them appropriately.
@google/genai:>=0.10.0 <2
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").