From 732bc1b2bf6c6ad80005bb4a00744fc2c9e6cd80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Halber?= Date: Fri, 31 Jul 2026 01:22:48 +0000 Subject: [PATCH] Send identifying User-Agent from the Python SDK Set User-Agent: braintrust-python/ on the requests session so the Braintrust backend can attribute object creation (projects, experiments, datasets, prompts, playgrounds) to the Python SDK vs other clients. Co-Authored-By: Claude Opus 4.8 --- py/src/braintrust/logger.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/py/src/braintrust/logger.py b/py/src/braintrust/logger.py index 7c89d51a..9b8a2c0a 100644 --- a/py/src/braintrust/logger.py +++ b/py/src/braintrust/logger.py @@ -109,6 +109,7 @@ merge_dicts, response_raise_for_status, ) +from .version import VERSION from .xact_ids import prettify_xact @@ -828,6 +829,9 @@ def _set_adapter(self, adapter: HTTPAdapter | None) -> None: def _reset(self, **retry_kwargs: Any) -> None: self.session = requests.Session() + # Identifies SDK-originated traffic so the backend can attribute object + # creation to the Python SDK. + self.session.headers.update({"User-Agent": f"braintrust-python/{VERSION}"}) adapter = self.adapter if adapter is None: