Skip to main content
Applies to:


Summary

Goal: Containerize Python SDK scripts for automated logging and cronjobs using Docker. Features: Python SDK, Docker containerization, environment variables for API key configuration.

Configuration Steps

Step 1: Create Dockerfile

Use a minimal Python base image and install the Braintrust SDK.
FROM python:3.11-slim

WORKDIR /app

RUN pip install --no-cache-dir braintrust

COPY . .

ENV BRAINTRUST_API_KEY=""

CMD ["python", "your_script.py"]

Step 2: Set API key at runtime

Pass your Braintrust API key as an environment variable when running the container.
docker run -e BRAINTRUST_API_KEY=your_api_key your_image

Step 3: Add dependencies

If your script requires additional packages, add a requirements.txt file.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .

Notes

  • Braintrust does not publish an official Docker image
  • Python 3.9+ is required
  • Use standard Docker best practices for production deployments