skillfed

braintrust-api

The official Python library for the braintrust API

braintrust-api v0.6.0 218.1K downloads/30d#9,343 on PyPI5
Permissive license Apache-2.0 Active released

What it is and what it does

Braintrust-api is the official Python client for the Braintrust REST API, generated using Stainless. It wraps HTTP calls to Braintrust's service with full type annotations for request parameters and response objects, enabling IDE autocomplete and type checking. The library ships both synchronous and asynchronous clients powered by httpx, so you can choose the concurrency model that fits your application.

Typical usage involves instantiating a Braintrust client with an API key, then calling methods like client.projects.create() or client.projects.list(). Responses are Pydantic models with helper methods for JSON serialization and dictionary conversion. The library handles pagination automatically via iterators, retries transient errors up to 2 times by default, and raises specific exception types (APIConnectionError, RateLimitError, APIStatusError) so you can handle failures gracefully.

Use it for:

  • Build a Python application that creates and manages Braintrust projects programmatically with full type safety.
  • Integrate Braintrust API calls into an async/await workflow for non-blocking I/O in concurrent applications.
  • Iterate over paginated Braintrust API responses automatically without manually tracking cursors or page tokens.
  • Catch and handle specific API errors (rate limits, authentication failures, timeouts) with dedicated exception types.
  • Serialize Braintrust API responses to JSON or dictionaries for logging, caching, or downstream processing.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a Python client library for the Braintrust REST API with type-safe request and response handling, supporting both synchronous and asynchronous operations.

Yes. The library is actively maintained, has low install friction, carries no known vulnerabilities, and is licensed permissively. It is well-suited for any Python project that needs to interact with the Braintrust API. The main prerequisite is a valid API key and network access to Braintrust's service.

Install

braintrust-api on PyPI

pip

pip install braintrust-api

uv

uv add braintrust-api

poetry

poetry add braintrust-api

Installing braintrust-api

Before you install

Low install friction with a pure-wheel distribution and standard dependencies (httpx, pydantic, anyio). Actively maintained with recent commits and support for current Python versions (3.8–3.12).

License in practice

Apache-2.0 is permissive; you can use, modify, and distribute this library freely in commercial and open-source projects with minimal restrictions.

Quickstart

pip install braintrust-api

import os
from braintrust_api import Braintrust

client = Braintrust(
    api_key=os.environ.get("BRAINTRUST_API_KEY"),
)

project = client.projects.create(name="foobar")
print(project.id)

Requires a valid BRAINTRUST_API_KEY environment variable or passed as an argument to authenticate with the Braintrust service.

Verify before relying

  • Whether the library's auto-retry behavior (2 times by default) and timeout handling (1 minute default) meet typical production requirements.
  • Rate of API changes and backward compatibility guarantees between minor versions.

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 6 — anyio, distro, httpx, pydantic, sniffio, typing-extensions
Maintenance actively maintained — 624 days since the last release
Last repo commit
First released
Downloads 218,120/month — #9,343 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: braintrust_api-0.6.0-py3-none-any.whl

Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: OS IndependentOperating System :: POSIXOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

braintrust api clientpython rest api clienttyped api wrapperasync http client libraryapi sdk pythonbraintrust python sdk
api-clientasync-supporttype-safe

More Python Modules packages