Google Gen AI
Adds instrumentation for Google Gen AI SDK.
Import name: Sentry.googleGenAIIntegration
The googleGenAIIntegration adds instrumentation for the @google/genai SDK to capture spans by wrapping Google Gen AI SDK calls and recording LLM interactions.
Enabled by default and automatically captures spans for Google Gen AI SDK calls. Requires Sentry SDK version 10.28.0 or higher.
To customize what data is captured (such as inputs and outputs), see the Options in the Configuration section.
The following options control what data is captured from Google Gen AI SDK calls:
Type: boolean (optional)
Records inputs to Google Gen AI SDK calls (such as prompts and messages).
Defaults to true if sendDefaultPii is true.
Type: boolean (optional)
Records outputs from Google Gen AI SDK calls (such as generated text and responses).
Defaults to true if sendDefaultPii is true.
Usage
Using the googleGenAIIntegration integration:
Sentry.init({
dsn: "____PUBLIC_DSN____",
// Tracing must be enabled for agent monitoring to work
tracesSampleRate: 1.0,
integrations: [
Sentry.googleGenAIIntegration({
// your options here
}),
],
});
By default, tracing support is added to the following Google Gen AI SDK calls:
models.generateContent()- Generate content with a given modelmodels.generateContentStream()- Stream content generation with a given modelchats.create()- Create chat sessionssendMessage()- Send messages in chat sessionssendMessageStream()- Stream messages in chat sessions
Streaming and non-streaming requests are automatically detected and handled 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").