• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
charmaine

charmaine

BraintrustSDK

Quickstart for Braintrust's SDK
Public
Like
BraintrustSDK
Home
Code
2
README.md
tutorial
Branches
1
Pull requests
Remixes
2
History
Environment variables
1
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
2/3/2025
Viewing readonly version of main branch: v29
View latest version
README.md

Braintrust SDK

Braintrust is a platform for evaluating and shipping AI products. To learn more about Braintrust or sign up for free, visit our website or check out the docs.

This repository contains the Javascript SDKs for Braintrust. The SDKs include utilities to:

  • Log experiments and datasets to Braintrust
  • Run evaluations (via the Eval framework)

This template shows you how to use the Braintrust SDK. This starter templated was ported from this one on GitHub.

To run it:

  • Click Fork on this val
  • Get your Braintrust API key at https://www.braintrust.dev/app/settings?subroute=api-keys
  • Add it to your project Environment Variables (on the left side bar of this project) as BRAINTRUST_API_KEY
  • Click Run on the tutorial val

Quick start: TypeScript (Outside of Val Town)

First, install the Braintrust SDK:

npm install braintrust autoevals

or


yarn add braintrust autoevals

Then, create a file named tutorial.eval.ts with the following code:

import { Eval } from "braintrust"; import { LevenshteinScorer } from "autoevals"; Eval("Say Hi Bot", { data: () => { return [ { input: "Foo", expected: "Hi Foo", }, { input: "Bar", expected: "Hello Bar", }, ]; // Replace with your eval dataset }, task: (input) => { return "Hi " + input; // Replace with your LLM call }, scores: [LevenshteinScorer], });

Then, run the following command:

BRAINTRUST_API_KEY=<YOUR_API_KEY> \ npx braintrust eval tutorial.eval.ts

Documentation

For more information, check out the docs:

  • TypeScript
  • Python
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.