# Vercel AI | Sentry for Electron

Requires SDK version `10.6.0` or higher for Node.js, Cloudflare Workers, Vercel Edge Functions and Bun. Requires SDK version `10.12.0` or higher for Deno.

*Import name: `Sentry.vercelAIIntegration`*

The `vercelAIIntegration` adds instrumentation for the [`ai`](https://www.npmjs.com/package/ai) SDK by Vercel to capture spans using the [`AI SDK's built-in Telemetry`](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).

It is enabled by default and will automatically capture spans for all `ai` function calls. You can opt-in to capture inputs and outputs by setting `recordInputs` and `recordOutputs` in the integration config:

```javascript
Sentry.init({
  dsn: "
example-org / example-project
"
  tracesSampleRate: 1.0,
  integrations: [
    Sentry.vercelAIIntegration({
      recordInputs: true,
      recordOutputs: true,
    }),
  ],
});
```

## [Options](https://docs.sentry.io/platforms/javascript/guides/electron/configuration/integrations/vercelai.md#options)

### [`force`](https://docs.sentry.io/platforms/javascript/guides/electron/configuration/integrations/vercelai.md#force)

Requires SDK version `9.29.0` or higher.

*Type: `boolean`*

Forces the integration to be active, even when the `ai` module is not detected or available. This is useful when you want to ensure the integration is always enabled regardless of module detection.

Defaults to `false`.

```javascript
Sentry.init({
  integrations: [Sentry.vercelAIIntegration({ force: true })],
});
```

### [`recordInputs`](https://docs.sentry.io/platforms/javascript/guides/electron/configuration/integrations/vercelai.md#recordinputs)

Requires SDK version `9.27.0` or higher.

*Type: `boolean`*

Records inputs to the `ai` function call.

Defaults to `true` if `sendDefaultPii` is `true` or if you explicitly set `experimental_telemetry.isEnabled` to `true` in your `ai` function callsites.

```javascript
Sentry.init({
  integrations: [Sentry.vercelAIIntegration({ recordInputs: true })],
});
```

### [`recordOutputs`](https://docs.sentry.io/platforms/javascript/guides/electron/configuration/integrations/vercelai.md#recordoutputs)

Requires SDK version `9.27.0` or higher.

*Type: `boolean`*

Records outputs to the `ai` function call.

Defaults to `true` if `sendDefaultPii` is `true` or if you explicitly set `experimental_telemetry.isEnabled` to `true` in your `ai` function callsites.

```javascript
Sentry.init({
  integrations: [Sentry.vercelAIIntegration({ recordOutputs: true })],
});
```

## [Identifying functions](https://docs.sentry.io/platforms/javascript/guides/electron/configuration/integrations/vercelai.md#identifying-functions)

In order to make it easier to correlate captured spans with the function calls we recommend setting `functionId` in `experimental_telemetry` in all generation function calls:

```javascript
const result = await generateText({
  model: openai("gpt-4o"),
  experimental_telemetry: {
    isEnabled: true,
    functionId: "my-awesome-function",
  },
});
```

## [Configuration](https://docs.sentry.io/platforms/javascript/guides/electron/configuration/integrations/vercelai.md#configuration)

By default this integration adds tracing support to all `ai` function callsites. If you need to disable span collection for a specific call, you can do so by setting `experimental_telemetry.isEnabled` to `false` in the first argument of the function call.

```javascript
const result = await generateText({
  model: openai("gpt-4o"),
  experimental_telemetry: { isEnabled: false },
});
```

If you set `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs` it will override the default behavior of collecting inputs and outputs for that function call.

```javascript
const result = await generateText({
  model: openai("gpt-4o"),
  experimental_telemetry: {
    isEnabled: true,
    recordInputs: true,
    recordOutputs: true,
  },
});
```

## [Supported Versions](https://docs.sentry.io/platforms/javascript/guides/electron/configuration/integrations/vercelai.md#supported-versions)

* `ai`: `>=3.0.0 <6`
