Vercel AI

Adds instrumentation for Vercel AI SDK.

Import name: Sentry.vercelAIIntegration

The vercelAIIntegration adds instrumentation for the ai library by Vercel to capture spans using the AI SDK's built-in Telemetry.

Copied
Sentry.init({
  integrations: [new Sentry.vercelAIIntegration()],
});

To enhance the spans collected by this integration, we recommend providing a functionId to identify the function that the telemetry data is for. For more details, see the AI SDK Telemetry Metadata docs.

Copied
const result = await generateText({
  model: openai("gpt-4-turbo"),
  experimental_telemetry: { functionId: "my-awesome-function" },
});

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

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

If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each function call by setting experimental_telemetry.recordInputs and experimental_telemetry.recordOutputs to true.

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

  • dataloader: >=3.0.0 <5
Help improve this content
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").