# OpenAI | Sentry for Azure Functions

This integration works in the Node.js, Cloudflare Workers, Vercel Edge Functions runtimes. It requires SDK version `10.2.0` or higher.

*Import name: `Sentry.openAIIntegration`*

The `openAIIntegration` adds instrumentation for the `openai` API to capture spans by automatically wrapping OpenAI client calls and recording LLM interactions with configurable input/output recording.

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

```javascript
Sentry.init({
  dsn: "____PUBLIC_DSN____",
  tracesSampleRate: 1.0,
  integrations: [
    Sentry.openAIIntegration({
      recordInputs: true,
      recordOutputs: true,
    }),
  ],
});
```

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

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

*Type: `boolean`*

Records inputs to OpenAI API method calls (such as prompts and messages).

Defaults to `true` if `sendDefaultPii` is `true`.

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

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

*Type: `boolean`*

Records outputs from OpenAI API method calls (such as generated text and responses).

Defaults to `true` if `sendDefaultPii` is `true`.

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

## [Configuration](https://docs.sentry.io/platforms/javascript/guides/azure-functions/configuration/integrations/openai.md#configuration)

By default this integration adds tracing support to OpenAI API method calls including:

* `chat.completions.create()` - Chat completion requests
* `responses.create()` - Response API requests

The integration will automatically detect streaming vs non-streaming requests and handle them appropriately.

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

* `openai`: `>=4.0.0 <6`
