Setup
This integration uses Braintrust’s Python SDK OpenTelemetry configuration. Install Traceloop alongside the Braintrust SDK, then point it at Braintrust’s OpenTelemetry endpoint.1
Install the packages
Install Traceloop with the Braintrust SDK’s OpenTelemetry support and the OpenAI client:
2
Configure environment variables
Point Traceloop at Braintrust by setting its base URL and headers:
.env
When setting the bearer token, encode the space between “Bearer” and your API key using
%20.OpenTelemetry
To send traces to Braintrust, initialize Traceloop. It exports spans to the project named in thex-bt-parent header:traceloop_braintrust.py