---
title: "Google Gen AI"
description: "Adds instrumentation for the Google Gen AI SDK. (default)"
url: https://docs.sentry.io/platforms/javascript/guides/gcp-functions/configuration/integrations/google-genai/
---

# Google Gen AI | Sentry for Google Cloud Functions

Requires SDK version `11.0.0` or higher. On earlier versions, see the [Agent Tracing](https://docs.sentry.io/platforms/javascript/agent-tracing.md) setup for your SDK.

*Import name: `Sentry.googleGenAIIntegration`*

This integration is enabled by default when tracing is enabled. If you'd like to modify your default integrations, read [this](https://docs.sentry.io/platforms/javascript/guides/gcp-functions/configuration/integrations.md#modifying-default-integrations).

The `googleGenAIIntegration` adds instrumentation for the [`@google/genai`](https://www.npmjs.com/package/@google/genai) SDK to capture [agent tracing](https://docs.sentry.io/platforms/javascript/guides/gcp-functions/agent-tracing.md) `gen_ai` spans, recording model, token usage, latency, and (when enabled) inputs and outputs.

```javascript
Sentry.init({
  dsn: "https://<key>@o<orgId>.ingest.sentry.io/<projectId>",
  // Tracing must be enabled for agent tracing to work
  tracesSampleRate: 1.0,
  integrations: [Sentry.googleGenAIIntegration()],
});
```

## [Supported Operations](https://docs.sentry.io/platforms/javascript/guides/gcp-functions/configuration/integrations/google-genai.md#supported-operations)

By default, tracing support is added to the following Google Gen AI SDK calls:

* `models.generateContent()` - Generate content with a given model
* `models.generateContentStream()` - Stream content generation with a given model
* `models.embedContent()` - Generate embeddings with a given model
* `chats.create()` - Create chat sessions
* `sendMessage()` - Send messages in chat sessions
* `sendMessageStream()` - Stream messages in chat sessions

Streaming and non-streaming requests are automatically detected and handled appropriately.

## [Supported Versions](https://docs.sentry.io/platforms/javascript/guides/gcp-functions/configuration/integrations/google-genai.md#supported-versions)

* `@google/genai`: `>=0.10.0 <3`

## [Options](https://docs.sentry.io/platforms/javascript/guides/gcp-functions/configuration/integrations/google-genai.md#options)

### [`recordInputs`](https://docs.sentry.io/platforms/javascript/guides/gcp-functions/configuration/integrations/google-genai.md#recordinputs)

*Type: `boolean` (optional)*

Records inputs to Google Gen AI SDK calls (such as prompts and messages).

Defaults to `true` if `dataCollection.genAI.inputs` is `true` (which is the default when using `dataCollection`), or if the deprecated `sendDefaultPii` is `true`.

### [`recordOutputs`](https://docs.sentry.io/platforms/javascript/guides/gcp-functions/configuration/integrations/google-genai.md#recordoutputs)

*Type: `boolean` (optional)*

Records outputs from Google Gen AI SDK calls (such as generated text and responses).

Defaults to `true` if `dataCollection.genAI.outputs` is `true` (which is the default when using `dataCollection`), or if the deprecated `sendDefaultPii` is `true`.

```javascript
Sentry.init({
  dsn: "https://<key>@o<orgId>.ingest.sentry.io/<projectId>",
  tracesSampleRate: 1.0,
  integrations: [
    Sentry.googleGenAIIntegration({
      recordInputs: true,
      recordOutputs: true,
    }),
  ],
});
```
