Vercel AI
为 Vercel AI SDK 添加插装。
此集成仅在 Node.js 和 Bun 运行时中工作。需要 SDK 版本 8.43.0
或更高版本。
Import name: Sentry.vercelAIIntegration
vercelAIIntegration
为 Vercel 的 ai
库添加了插装,以使用 AI SDK 内置的遥测功能
捕获跨度。
Copied
Sentry.init({
integrations: [new Sentry.vercelAIIntegration()],
});
为了增强此集成收集的跨度,我们建议提供一个 functionId
以标识遥测数据对应的函数。更多详情,请参阅 AI SDK 遥测元数据文档。
Copied
const result = await generateText({
model: openai("gpt-4-turbo"),
experimental_telemetry: { functionId: "my-awesome-function" },
});
默认情况下,此集成会为所有 ai
函数调用添加跟踪支持。如果您需要禁用特定调用的跨度收集,可以通过在函数调用的第一个参数中将 experimental_telemetry.isEnabled
设置为 false
来实现。
Copied
const result = await generateText({
model: openai("gpt-4-turbo"),
experimental_telemetry: { isEnabled: false },
});
如果您想收集特定调用的输入和输出,您必须通过将 experimental_telemetry.recordInputs
和 experimental_telemetry.recordOutputs
设置为 true
来明确选择每个函数调用。
Copied
const result = await generateText({
model: openai("gpt-4-turbo"),
experimental_telemetry: {
isEnabled: true,
recordInputs: true,
recordOutputs: true,
},
});
ai
:>=3.0.0 <5