Skip to main content

SDK for integrating Braintrust

Project description

Braintrust

A Python library for logging data to Braintrust. braintrust is distributed as a library on PyPI. It is open source and available on GitHub.

Quickstart

Install the library with pip.

pip install braintrust

Performance tip: For 3-5x faster JSON serialization, install with the optional performance extra:

pip install braintrust[performance]

Or install orjson separately:

pip install orjson

The SDK automatically detects and uses orjson if available, with seamless fallback to standard json. See ORJSON_OPTIMIZATION.md for details.

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

from braintrust import Eval

def is_equal(expected, output):
    return expected == output

Eval(
  "Say Hi Bot",
  data=lambda: [
      {
          "input": "Foo",
          "expected": "Hi Foo",
      },
      {
          "input": "Bar",
          "expected": "Hello Bar",
      },
  ],  # Replace with your eval dataset
  task=lambda input: "Hi " + input,  # Replace with your LLM call
  scores=[is_equal],
)

Performance Optimization

For 3-5x faster JSON serialization, install orjson. The SDK automatically detects and uses orjson if available, with seamless fallback to standard json.

Project details


Release history Release notifications | RSS feed

This version

0.5.5

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

braintrust-0.5.5.tar.gz (331.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

braintrust-0.5.5-py3-none-any.whl (384.0 kB view details)

Uploaded Python 3

File details

Details for the file braintrust-0.5.5.tar.gz.

File metadata

  • Download URL: braintrust-0.5.5.tar.gz
  • Upload date:
  • Size: 331.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for braintrust-0.5.5.tar.gz
Algorithm Hash digest
SHA256 8dc2bc5d58bccf846d179a860eb26acce0244b00cdcf2fbbeef19be46c52710e
MD5 3a9801252c89481a4eade34ec8a361c6
BLAKE2b-256 20b265c5f9dbacc6c9e8ba34d531d4e144587abaca9e014a892c3fcf972dd0f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for braintrust-0.5.5.tar.gz:

Publisher: publish-py-sdk.yaml on braintrustdata/braintrust-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file braintrust-0.5.5-py3-none-any.whl.

File metadata

  • Download URL: braintrust-0.5.5-py3-none-any.whl
  • Upload date:
  • Size: 384.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for braintrust-0.5.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9efd7ff0d5c963c6426c64a26befc7d3e2249df19321658c07e85a906d3322da
MD5 5128ea21d2a0ae074d70cb6335fe76ba
BLAKE2b-256 7ff96107b08fc075a4c198a8661f3f617e4a5ebeae630bdf64c63a00c355a359

See more details on using hashes here.

Provenance

The following attestation bundles were made for braintrust-0.5.5-py3-none-any.whl:

Publisher: publish-py-sdk.yaml on braintrustdata/braintrust-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page