🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

braintrust

Package Overview
Dependencies
Maintainers
2
Versions
294
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

braintrust

SDK for integrating Braintrust

Source
npmnpm
Version
2.2.2
Version published
Weekly downloads
1.2M
7.8%
Maintainers
2
Weekly downloads
 
Created
Source

An isomorphic JS library for logging data to Braintrust.

Version information

2.x is the current stable release. Zod is now a peer dependency instead of a bundled dependency. This gives you control over the Zod version in your project and reduces bundle size if you’re already using Zod.

The SDK requires Zod v3.25.34 or later.

Upgrading from 1.x

See the Migrate from v1.x to v2.x guide for instructions.

Upgrading from 0.x

First follow the Migrate from v0.x to v1.x guide, then proceed to the Migrate from v1.x to v2.x guide.

Note: If you do not have OpenTelemetry you can upgrade directly from v0.x to v2.x.

Quickstart

Install the library with npm (or yarn).

npm install braintrust zod

Then, run a simple experiment with the following code (replace YOUR_API_KEY with your Braintrust API key):

import * as braintrust from "braintrust";

async function main() {
  const experiment = await braintrust.init("NodeTest", {
    apiKey: "YOUR_API_KEY",
  });
  experiment.log({
    input: { test: 1 },
    output: "foo",
    expected: "bar",
    scores: {
      n: 0.5,
    },
    metadata: {
      id: 1,
    },
  });
  console.log(await experiment.summarize());
}

main().catch(console.error);

FAQs

Package last updated on 12 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts