Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Tools · Const

Braintrust

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.

How it works

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.

Syntax

new BraintrustExporter({ parent: 'project_name:your-project-name', filterAISpans: true })

Parameters

NameTypeDescription
parentstringThe Braintrust project or experiment destination for exported traces.
filterAISpansbooleanWhen true, restricts exported telemetry to AI-related spans.

Returns

The integration registers telemetry export; traced AI SDK calls are then captured in Braintrust.

Key points

  • Braintrust provides an end-to-end platform for developing AI applications.
  • The integration supports logging, monitoring, and acting on production interactions.
  • Use the integration in either a Next.js application or a standalone Node.js process.
  • Next.js applications use BraintrustExporter together with @vercel/otel.
  • Standalone Node.js applications can use BraintrustSpanProcessor when configuring the OpenTelemetry Node SDK.
  • Streaming calls such as streamText are represented as ai.streamText spans.

Common mistakes

  • Set parent to the intended Braintrust project or experiment; otherwise traces will not be associated with the desired destination.
  • After registration, avoid adding redundant per-call instrumentation for the basic tracing setup.

Example: Next.js Braintrust instrumentation

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.

When to use it

Export AI SDK traces through @vercel/otel

Next.js application

Process AI SDK spans with BraintrustSpanProcessor

Standalone Node.js service

Trace streamText calls in Braintrust

Streaming generation

  • BraintrustExporter
  • BraintrustSpanProcessor
  • @vercel/otel
  • OpenTelemetry
  • streamText
  • experimental_telemetry

Source: Braintrust. Checked 2026-10-15.