Braintrust tracing provider for agents.
  • TypeScript 100%
Find a file
James Peret 8ce199cc7c
Upgrade to AI SDK V6: bump ai/ai-sdk packages to V6
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-09 17:25:07 -03:00
src Initial implementation of BraintrustProvider for AI SDK experimental_telemetry 2025-09-18 21:49:15 -03:00
.gitignore Initial implementation of BraintrustProvider for AI SDK experimental_telemetry 2025-09-18 21:49:15 -03:00
package-lock.json Upgrade to AI SDK V6: bump ai/ai-sdk packages to V6 2026-03-09 17:25:07 -03:00
package.json Upgrade to AI SDK V6: bump ai/ai-sdk packages to V6 2026-03-09 17:25:07 -03:00
README.md Initial implementation of BraintrustProvider for AI SDK experimental_telemetry 2025-09-18 21:49:15 -03:00
tsconfig.json Initial implementation of BraintrustProvider for AI SDK experimental_telemetry 2025-09-18 21:49:15 -03:00

@fractal-synapse/braintrust-tracer

Braintrust tracing provider for Fractal Synapse agents. This package enables automatic tracing and monitoring of AI agent interactions using Braintrust.

Features

  • Automatic Model Wrapping: Wraps AI SDK models with Braintrust tracing
  • Request/Response Logging: Captures all model interactions
  • Performance Metrics: Tracks execution time and token usage
  • Error Monitoring: Logs and tracks errors in model calls
  • Tool Call Tracing: Monitors AI agent tool executions

Installation

npm install @fractal-synapse/braintrust-tracer braintrust

Usage

Basic Setup

import { BraintrustProvider } from '@fractal-synapse/braintrust-tracer';
import { modelRegistry } from '@fractal-synapse/agent-core';

// Initialize the Braintrust provider
const braintrustProvider = new BraintrustProvider(
  process.env.BRAINTRUST_API_KEY!,
  'my-project-name'
);

// Apply tracing to all registered models
modelRegistry.applyTracing(braintrustProvider);

Environment Variables

Make sure to set the following environment variables:

BRAINTRUST_API_KEY=your_braintrust_api_key_here

Integration with Agents

When used with Fractal Synapse agents, all model calls will be automatically traced:

// All these calls will be traced
const response = await modelRegistry.getModel('openai-gpt-4o').generateText({
  messages: [{ role: 'user', content: 'Hello!' }]
});

API Reference

BraintrustProvider

Constructor

new BraintrustProvider(apiKey: string, projectName: string)
  • apiKey: Your Braintrust API key
  • projectName: Name of your Braintrust project for organizing traces

Methods

wrapModel(model: any): any

Wraps an AI SDK model with Braintrust tracing capabilities.

  • model: The AI SDK model to wrap
  • Returns: The wrapped model with tracing enabled

Requirements

  • Node.js 16+
  • Valid Braintrust API key
  • AI SDK compatible models

License

MIT