Skip to main content
This quickstart shows you how to automatically log your application’s LLM calls to Braintrust using native SDK wrappers for common AI providers. Wrappers are available for TypeScript, Python, and other languages. Specifically, these guides show how to wrap OpenAI, Anthropic, and Gemini calls and send those log traces to Braintrust. We also provide native SDK wrappers for a range of other providers through our AI proxy.
  • OpenAI
  • Anthropic
  • Gemini
  • Other AI providers
  • SDK integrations
OpenAI provides access to GPT models including GPT-5 and other cutting-edge language models. Braintrust integrates seamlessly with OpenAI through direct API access, wrapper functions for automatic tracing, and proxy support.

1. Configure your API keys

You need both Braintrust and OpenAI API keys to set up logging OpenAI LLM calls.
OPENAI_API_KEY=<your-openai-api-key>
BRAINTRUST_API_KEY=<your-braintrust-api-key>
API keys are encrypted using 256-bit AES-GCM encryption and are not stored or logged by Braintrust.

2. Install Braintrust and OpenAI libraries

Install the Braintrust and OpenAI libraries for your programming language.
pnpm add braintrust openai

3. Send logs to Braintrust

Braintrust provides automatic tracing for OpenAI API calls, handling streaming, metrics collection, and other details.
  • TypeScript & Python: Use wrapOpenAI / wrap_openai wrapper functions
  • Go: Use the tracing middleware with the OpenAI client
  • Ruby: Use Braintrust::Trace::OpenAI.wrap to wrap the OpenAI client
  • Java: Use the tracing interceptor with the OpenAI client
import OpenAI from "openai";

// Initialize the Braintrust logger
const logger = initLogger({
  projectName: "My Project", // Your project name
  apiKey: process.env.BRAINTRUST_API_KEY,
});

// Wrap the OpenAI client with wrapOpenAI
const client = wrapOpenAI(
  new OpenAI({
    apiKey: process.env.OPENAI_API_KEY,
  }),
);

// All API calls are automatically logged
const result = await client.chat.completions.create({
  model: "gpt-5",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "What is machine learning?" },
  ],
});

4. View your logs

Select Logs in the Braintrust dashboard to view your log traces.

Next steps