braintrust-api
The official Python library for the braintrust API
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-apiuv
uv add braintrust-apipoetry
poetry add braintrust-apiInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
braintrustBraintrust is a Python SDK for logging,…
permissive · top 5,000 on PyPI
supermemoryProvides a Python client library for the…
permissive · top 15,000 on PyPI
braintrust-coreProvides shared core dependencies for packages…
unclear · top 5,000 on PyPI
arcadepyProvides a typed Python client library for the…
permissive · top 15,000 on PyPI
parallel-webProvides a Python client library for the…
permissive · top 5,000 on PyPI
opencode-aiProvides a Python client library for the…
permissive · top 15,000 on PyPI
composio-clientA Python client library for the Composio REST…
permissive · top 5,000 on PyPI
agentex-clientProvides a typed Python REST client for the…
permissive · top 15,000 on PyPI
sambanovaProvides a Python client library for accessing…
permissive · top 15,000 on PyPI
pipedreamProvides a Python client library for accessing…
unclear · top 15,000 on PyPI