Export AI SDK traces through @vercel/otel
Next.js application
AI Tools · Const
Braintrust integrates with the AI SDK through OpenTelemetry to log and monitor LLM interactions. Configure its exporter for Next.js or its span processor for standalone Node.js.
Braintrust integrates with the AI SDK through OpenTelemetry. Register its exporter for Next.js or configure the Node.js SDK directly; afterward, AI SDK calls are captured automatically and associated with the Braintrust project or experiment named by the exporter’s parent setting.
new BraintrustExporter({ parent: 'project_name:your-project-name', filterAISpans: true })| Name | Type | Description |
|---|---|---|
parent | string | The Braintrust project or experiment destination for exported traces. |
filterAISpans | boolean | When true, restricts exported telemetry to AI-related spans. |
The integration registers telemetry export; traced AI SDK calls are then captured in Braintrust.
BraintrustExporter together with @vercel/otel.BraintrustSpanProcessor when configuring the OpenTelemetry Node SDK.streamText are represented as ai.streamText spans.parent to the intended Braintrust project or experiment; otherwise traces will not be associated with the desired destination.import { registerTelemetry } from 'ai';
import { LegacyOpenTelemetry } from '@ai-sdk/otel';
import { registerOTel } from '@vercel/otel';
import { BraintrustExporter } from 'braintrust';
registerTelemetry(new LegacyOpenTelemetry());
export function register() {
registerOTel({
serviceName: 'my-braintrust-app',
traceExporter: new BraintrustExporter({
parent: 'project_name:your-project-name',
filterAISpans: true,
}),
});
}Register the Braintrust exporter with OpenTelemetry so AI SDK telemetry is sent to the selected Braintrust project.
Next.js application
Standalone Node.js service
Streaming generation
BraintrustExporterBraintrustSpanProcessor@vercel/otelOpenTelemetrystreamTextexperimental_telemetry