Skip to main content

Braintrust Python SDK

PyPI version

The official Python SDK for logging, tracing, and evaluating AI applications with Braintrust.

Installation

Install the SDK:

pip install braintrust

Quickstart

Run a simple evaluation:

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"},
    ],
    task=lambda input: "Hi " + input,
    scores=[is_equal],
)

Then run:

BRAINTRUST_API_KEY=<YOUR_API_KEY> braintrust eval tutorial_eval.py

Optional Extras

Install extras as needed for specific workflows:

pip install "braintrust[audio]"
pip install "braintrust[cli]"
pip install "braintrust[openai-agents]"
pip install "braintrust[otel]"
pip install "braintrust[temporal]"
pip install "braintrust[all]"

Available extras:

  • audio: installs PyAV for Opus/Ogg session recording on Python 3.12+
  • performance: installs orjson for faster JSON serialization
  • cli: installs optional dependencies used by the Braintrust CLI
  • openai-agents: installs OpenAI Agents integration support
  • otel: installs OpenTelemetry integration dependencies
  • temporal: installs Temporal integration dependencies
  • all: installs all optional extras

Audio encoding

braintrust[audio] requires Python 3.12+ and uses PyAV's bundled FFmpeg codecs. On Python 3.10–3.11, the extra does not install PyAV; use PCM/WAV recording. Each Opus/Ogg segment is an independent file with exact playable duration. Installing the extra does not enable capture; framework adapters still require their audio opt-ins and privacy permission. Without PyAV, default recording warns once and uses raw PCM. Explicit Opus configuration requires the extra. PCM/WAV need no native codecs.

Audio uploads use Attachment.upload() directly. Span customizers and masking apply to trace records published afterward; removing an attachment reference does not prevent or undo its upload.

Documentation

License

Apache-2.0

Metadata

Release files for braintrust 0.52.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for braintrust 0.52.0
File Size Uploaded Provenance Actions
braintrust-0.52.0.tar.gz 701.7 kB With provenance Details for braintrust-0.52.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for braintrust 0.52.0
File Interpreter ABI Platform Actions
braintrust-0.52.0-py3-none-any.whl Python 3 none any Details for braintrust-0.52.0-py3-none-any.whl

Total release size: 1.5 MB

Release files / braintrust-0.52.0.tar.gz

Download URL braintrust-0.52.0.tar.gz
Size 701.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b7bcc2fbf224fb2836c7bbaa55f120469e98600cc9c2380f7088cbb9079780ba
BLAKE2b-256 checksum
How to use checksums
46df3df9b4a03e867c0302a692199fe2a41eba362bcb4dcfca34252436c296f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / braintrust-0.52.0-py3-none-any.whl

Download URL braintrust-0.52.0-py3-none-any.whl
Size 841.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b91e2a0635531b17ba46036c8088a1c02190186dcf7c9d317758d185c694bda4
BLAKE2b-256 checksum
How to use checksums
284b2b19ea629d15fcc2ed31e1e60a3319d0225e7ed9b25b265152bd5cb36a8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for braintrust 0.52.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for braintrust-0.52.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.52.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page