> ## Documentation Index
> Fetch the complete documentation index at: https://docs.braintrust.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Trace LLM calls

> Enable auto-instrumentation once and every call to a supported AI provider is logged — inputs, outputs, latency, token usage, and costs.

> [!TIP]
>
> Use the [Braintrust CLI](https://docs.braintrust.dev/reference/cli/quickstart.md) to automatically instrument your project with your preferred coding agent.

## Auto-instrumentation

Auto-instrumentation patches supported AI libraries at startup so every LLM call is captured without wrapping individual clients. This is the recommended way to set up tracing.

The examples on this page use OpenAI, but Braintrust supports [many providers and frameworks](#supported-libraries).

> [tab] TypeScript
>
> Auto-instrumentation in TypeScript uses a startup hook that patches supported AI libraries automatically.
>
> **1. Install the dependencies**
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> npm install braintrust openai
> ```
>
> **2. Set your environment variables**
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> export BRAINTRUST_API_KEY="your-api-key"
> export OPENAI_API_KEY="your-api-key"
> ```
>
> For local development, the Braintrust Node.js SDK can instead read `BRAINTRUST_API_KEY` from a `.env.braintrust` file. When no key is set explicitly or through the environment, the SDK searches upward from the working directory to the filesystem root for a file like this:
>
> ```bash .env.braintrust theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> BRAINTRUST_API_KEY=your-api-key
> ```
>
> The nearest file wins. Discovery runs the first time the SDK needs the key, so construction succeeds even when no key is present at startup. This applies to the Node.js SDK only, not the browser, edge, or workerd builds. Add `.env.braintrust` to your `.gitignore` so the key isn't committed.
>
> **3. Trace your LLM calls**
>
> This example traces a single OpenAI call:
>
> ```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> import { initLogger } from "braintrust";
> import OpenAI from "openai";
>
> // Call once at startup — all LLM calls are traced automatically
> initLogger({
>   apiKey: process.env.BRAINTRUST_API_KEY,
>   projectName: "My Project (TypeScript)",
> });
>
> const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
> const response = await client.responses.create({
>   model: "gpt-5-mini",
>   input: "What is the capital of France?",
> });
> ```
>
> > [accordion] Disabling specific integrations
> >
> > Auto-instrumentation enables every supported TypeScript integration by default. Disable individual integrations with the `BRAINTRUST_DISABLE_INSTRUMENTATION` environment variable, a comma-separated, case-insensitive list of integration names to skip:
> >
> > ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > # Disable one integration
> > BRAINTRUST_DISABLE_INSTRUMENTATION=openai node --import braintrust/hook.mjs app.js
> >
> > # Disable multiple integrations
> > BRAINTRUST_DISABLE_INSTRUMENTATION=openai,anthropic node --import braintrust/hook.mjs app.js
> > ```
> >
> > The names match the supported libraries, such as `openai`, `anthropic`, `ai-sdk`, `langchain`, and `aws-bedrock`. See [Supported libraries](#supported-libraries) for the full list.
>
> **4. Run your app**
>
> Run with the `--import` flag to enable auto-instrumentation:
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> node --import braintrust/hook.mjs app.js
> ```
>
> > [accordion] Using a bundler?
> >
> > If you're using a bundler or a framework that uses one, use the appropriate bundler plugin instead of the `--import` flag. The plugins are included in the Braintrust SDK:
> >
> > | Bundler / Framework | Import path |
> > | - | - |
> > | Vite / SvelteKit | `braintrust/vite` |
> > | Nuxt | `braintrust/vite` (client) + `braintrust/rollup` (Nitro server) |
> > | Next.js | `braintrust/next` |
> > | Webpack | `braintrust/webpack` |
> > | esbuild | `braintrust/esbuild` |
> > | Rollup | `braintrust/rollup` |
> >
> > **Vite** (`vite.config.ts`):
> >
> > ```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > import { defineConfig } from "vite";
> > import { braintrustVitePlugin } from "braintrust/vite";
> >
> > export default defineConfig({
> >   plugins: [braintrustVitePlugin()],
> > });
> > ```
> >
> > **Next.js** (`next.config.ts`):
> >
> > Wrap your config with `wrapNextjsConfigWithBraintrust`. It selects the webpack plugin or the Turbopack loader based on the active Next.js build, so the same setup works whether you use Webpack (Next.js 15 and earlier) or Turbopack (Next.js 16+).
> >
> > ```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > import { wrapNextjsConfigWithBraintrust } from "braintrust/next";
> >
> > const nextConfig = {};
> >
> > export default wrapNextjsConfigWithBraintrust(nextConfig);
> > ```
> >
> > **Nuxt** (`nuxt.config.ts`) — Nuxt uses Vite for the client build and Rollup (via Nitro) for the server build, so both plugins are needed:
> >
> > ```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > import { braintrustVitePlugin } from "braintrust/vite";
> > import { braintrustRollupPlugin } from "braintrust/rollup";
> >
> > export default defineNuxtConfig({
> >   vite: {
> >     plugins: [braintrustVitePlugin()],
> >   },
> >   nitro: {
> >     rollupConfig: {
> >       plugins: [braintrustRollupPlugin()],
> >     },
> >   },
> > });
> > ```
>
> > [accordion] Running TypeScript directly?
> >
> > To run `.ts` files without compiling them first, load your TypeScript loader with its own `--import` flag alongside the hook:
> >
> > ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > node --import @poppinss/ts-exec --import braintrust/hook.mjs app.ts
> > ```
> >
> > Loaders that use Node.js synchronous module hooks, such as `@poppinss/ts-exec`, require Braintrust v3.40.0 or later and Node.js v22.22.3+, v24.11.1+, or v25.1.0+. On earlier versions, these loaders load your TypeScript modules as empty modules without an error, so compile your TypeScript to JavaScript instead.
>
> > [accordion] Node.js version requirements
> >
> > Requires Node.js 18.19.0+ or 20.6.0+ for `--import` flag support. Check with `node --version`.

> [tab] Python
>
> Auto-instrumentation in Python uses `auto_instrument()` to patch supported AI libraries at startup.
>
> **1. Install the dependencies**
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> pip install braintrust openai
> ```
>
> **2. Set your environment variables**
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> export BRAINTRUST_API_KEY="your-api-key"
> export OPENAI_API_KEY="your-api-key"
> ```
>
> For local development, the Python SDK can instead read `BRAINTRUST_API_KEY` from a `.env.braintrust` file. When no key is set explicitly or through the environment, the SDK searches upward from the working directory (up to 64 parent directories) for a file like this:
>
> ```bash .env.braintrust theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> BRAINTRUST_API_KEY=your-api-key
> ```
>
> The nearest file wins. Discovery runs the first time the SDK needs the key, so construction succeeds even when no key is present at startup. The file is read for the key only and does not modify your process environment. Add `.env.braintrust` to your `.gitignore` so the key isn't committed.
>
> **3. Trace your LLM calls**
>
> This example traces a single OpenAI call:
>
> ```python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> import os
> import braintrust
>
> # Call once at startup — all LLM calls are traced automatically
> braintrust.auto_instrument()
> braintrust.init_logger(
>     api_key=os.environ["BRAINTRUST_API_KEY"],
>     project="My Project (Python)",
> )
>
> from openai import OpenAI
>
> client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
> response = client.responses.create(
>     model="gpt-5-mini",
>     input="What is the capital of France?",
> )
> ```
>
> > [accordion] Disabling specific integrations
> >
> > `braintrust.auto_instrument()` enables every supported Python integration by default. Disable individual integrations by passing `False` for a specific keyword.
> >
> > | Parameter | Default | Library or framework |
> > | - | - | - |
> > | `openai` | `True` | OpenAI Python SDK |
> > | `anthropic` | `True` | Anthropic Python SDK |
> > | `litellm` | `True` | LiteLLM |
> > | `ai_sdk` | `True` | Vercel AI SDK for Python |
> > | `pydantic_ai` | `True` | Pydantic AI |
> > | `google_genai` | `True` | Google GenAI |
> > | `instructor` | `True` | Instructor |
> > | `openrouter` | `True` | OpenRouter native Python SDK |
> > | `mistral` | `True` | Mistral Python SDK |
> > | `huggingface_hub` | `True` | Hugging Face Hub |
> > | `transformers` | `True` | Hugging Face Transformers |
> > | `agno` | `True` | Agno |
> > | `agentscope` | `True` | AgentScope |
> > | `claude_agent_sdk` | `True` | Claude Agent SDK |
> > | `cursor_sdk` | `True` | Cursor SDK |
> > | `dspy` | `True` | DSPy |
> > | `adk` | `True` | Google ADK |
> > | `langchain` | `True` | LangChain and LangGraph |
> > | `llamaindex` | `True` | LlamaIndex |
> > | `openai_agents` | `True` | OpenAI Agents SDK |
> > | `cohere` | `True` | Cohere Python SDK |
> > | `autogen` | `True` | AutoGen |
> > | `crewai` | `True` | CrewAI |
> > | `strands` | `True` | Strands Agents |
> > | `temporal` | `True` | Temporal |
> > | `typesafe` | `True` | [TypeSafe](https://docs.braintrust.dev/integrations/ai-providers/typesafe.md#tracing-python) (Braintrust v0.41.0+) |
> > | `livekit_agents` | `True` | LiveKit Agents |
> > | `pipecat` | `True` | Pipecat |
> > | `google_discoveryengine` | `True` | Google Discovery Engine v1 |
> > | `mcp_client` | `True` | [MCP](https://docs.braintrust.dev/integrations/sdk-integrations/mcp-sdk.md#auto-instrumentation-python) clients (Braintrust v0.49.1+) |
> > | `mcp_server` | `True` | [MCP](https://docs.braintrust.dev/integrations/sdk-integrations/mcp-sdk.md#auto-instrumentation-python) servers (Braintrust v0.49.1+) |
> >
> > For example:
> >
> > ```python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > braintrust.auto_instrument(openrouter=False)
> > ```
>
> **4. Run your app**
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> python app.py
> ```

> [tab] Ruby
>
> Auto-instrumentation in Ruby uses the `braintrust/setup` require to patch supported AI libraries on load.
>
> **1. Install the dependencies**
>
> Add the Braintrust gem to your Gemfile, using the `braintrust/setup` require to enable auto-instrumentation on load:
>
> ```ruby theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> # Gemfile
> gem "braintrust", require: "braintrust/setup"
> gem "ruby-openai"
> ```
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> bundle install
> ```
>
> **2. Set your environment variables**
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> export BRAINTRUST_API_KEY="your-api-key"
> export OPENAI_API_KEY="your-api-key"
> export BRAINTRUST_DEFAULT_PROJECT=<your-project-name>  # Project that spans are logged to
> ```
>
> For local development, the Ruby SDK can instead read `BRAINTRUST_API_KEY` from a `.braintrust.json` file. When no key is set through the environment or an explicit `api_key:` argument, the SDK searches upward from the working directory for a file like this:
>
> ```json .braintrust.json theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> { "BRAINTRUST_API_KEY": "your-api-key" }
> ```
>
> The nearest file wins, and the file is read for the key only without modifying your process environment. Add `.braintrust.json` to your `.gitignore` so the key isn't committed.
>
> **3. Trace your LLM calls**
>
> This example traces a single OpenAI call:
>
> ```ruby theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> require 'bundler/setup'
> Bundler.require
>
> client = OpenAI::Client.new(access_token: ENV['OPENAI_API_KEY'])
> response = client.responses.create(
>   parameters: {
>     model: 'gpt-5-mini',
>     input: 'What is the capital of France?'
>   }
> )
> ```
>
> **4. Run your app**
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> ruby app.rb
> ```

> [tab] Go
>
> Auto-instrumentation in Go uses [Orchestrion](https://github.com/DataDog/orchestrion) for compile-time tracing. Each provider integration is installed as a separate Go module.
>
> **1. Install and register the integration**
>
> Install the Braintrust SDK, the provider connector module, and Orchestrion:
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> go get github.com/braintrustdata/braintrust-sdk-go
> go get github.com/braintrustdata/braintrust-sdk-go/trace/contrib/openai
> go get github.com/openai/openai-go
> go install github.com/DataDog/orchestrion@latest
> ```
>
> Then create `orchestrion.tool.go` in your project root to register which integrations Orchestrion should instrument:
>
> ```go #skip-compile theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> //go:build tools
>
> package main
>
> import (
> 	_ "github.com/DataDog/orchestrion"
> 	_ "github.com/braintrustdata/braintrust-sdk-go/trace/contrib/openai"
> )
> ```
>
> > [accordion] Other providers
> >
> > Each tracing integration is published as its own Go module. Install the ones you need and add them to `orchestrion.tool.go`:
> >
> > ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > go get github.com/braintrustdata/braintrust-sdk-go/trace/contrib/anthropic
> > go get github.com/braintrustdata/braintrust-sdk-go/trace/contrib/bedrockruntime
> > go get github.com/braintrustdata/braintrust-sdk-go/trace/contrib/genai
> > go get github.com/braintrustdata/braintrust-sdk-go/trace/contrib/genkit
> > go get github.com/braintrustdata/braintrust-sdk-go/trace/contrib/adk
> > go get github.com/braintrustdata/braintrust-sdk-go/trace/contrib/cloudwego/eino
> > go get github.com/braintrustdata/braintrust-sdk-go/trace/contrib/langchaingo
> > go get github.com/braintrustdata/braintrust-sdk-go/trace/contrib/github.com/sashabaranov/go-openai
> > ```
> >
> > Or use the `trace/contrib/all` meta-module to install and register every integration at once:
> >
> > ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > go get github.com/braintrustdata/braintrust-sdk-go/trace/contrib/all
> > ```
> >
> > ```go #skip-compile theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > //go:build tools
> >
> > package main
> >
> > import (
> > 	_ "github.com/DataDog/orchestrion"
> > 	_ "github.com/braintrustdata/braintrust-sdk-go/trace/contrib/all"
> > )
> > ```
>
> **2. Set your environment variables**
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> export BRAINTRUST_API_KEY="your-api-key"
> export OPENAI_API_KEY="your-api-key"
> ```
>
> For local development, the Go SDK can instead read `BRAINTRUST_API_KEY` from a `.braintrust.json` file. When no key is set through the environment or the `WithAPIKey` option, the SDK searches upward from the working directory for a file like this:
>
> ```json .braintrust.json theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> { "BRAINTRUST_API_KEY": "your-api-key" }
> ```
>
> The nearest file wins. Discovery runs the first time the SDK authenticates or exports, so `braintrust.New()` succeeds even when no key is present at startup. Passing a blank or whitespace-only string to `WithAPIKey` is treated as unset and preserves this fallback. Add `.braintrust.json` to your `.gitignore` so the key isn't committed.
>
> **3. Trace your LLM calls**
>
> This example traces a single OpenAI call. The Go SDK sends traces to Braintrust via [OpenTelemetry](https://opentelemetry.io/), so you create a `TracerProvider` and pass it to Braintrust:
>
> ```go theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> package main
>
> import (
> 	"context"
> 	"fmt"
> 	"log"
> 	"os"
>
> 	"github.com/braintrustdata/braintrust-sdk-go"
> 	"github.com/openai/openai-go"
> 	"github.com/openai/openai-go/option"
> 	"github.com/openai/openai-go/responses"
> 	"go.opentelemetry.io/otel"
> 	sdktrace "go.opentelemetry.io/otel/sdk/trace"
> )
>
> func main() {
> 	tp := sdktrace.NewTracerProvider()
> 	defer tp.Shutdown(context.Background())
> 	otel.SetTracerProvider(tp)
>
> 	_, err := braintrust.New(tp,
> 		braintrust.WithProject("My Project (Go)"),
> 		braintrust.WithAPIKey(os.Getenv("BRAINTRUST_API_KEY")),
> 	)
> 	if err != nil {
> 		log.Fatal(err)
> 	}
>
> 	client := openai.NewClient(option.WithAPIKey(os.Getenv("OPENAI_API_KEY")))
>
> 	response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
> 		Model: "gpt-5-mini",
> 		Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("What is the capital of France?")},
> 	})
> 	if err != nil {
> 		log.Fatal(err)
> 	}
>
> 	fmt.Println(response.OutputText())
> }
> ```
>
> **4. Build and run your app**
>
> Build with Orchestrion to enable auto-instrumentation:
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> go mod tidy
> orchestrion go build -o myapp
> ./myapp
> ```
>
> > [accordion] Enable Orchestrion via GOFLAGS
> >
> > Instead of running `orchestrion go build`, you can set a `GOFLAGS` environment variable to enable Orchestrion for normal `go build` commands:
> >
> > ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > export GOFLAGS="-toolexec='orchestrion toolexec'"
> > go build ./...
> > ```

> [tab] Java
>
> The Braintrust Java agent uses ByteBuddy to automatically instrument supported AI libraries at JVM startup.
>
> **1. Add the agent dependency**
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> # build.gradle
> configurations {
>     braintrustAgent
> }
>
> dependencies {
>     braintrustAgent 'dev.braintrust:braintrust-java-agent:+'
> }
>
> tasks.withType(JavaExec).configureEach {
>     jvmArgs "-javaagent:${configurations.braintrustAgent.asPath}"
> }
> ```
>
> **2. Set your environment variables**
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> export BRAINTRUST_API_KEY="your-api-key"
> ```
>
> For local development, the Java SDK can instead read `BRAINTRUST_API_KEY` from a `.env.braintrust` file. When no key is set explicitly or through the environment, the SDK searches upward from the working directory (up to 64 parent directories) for a file like this:
>
> ```bash .env.braintrust theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> BRAINTRUST_API_KEY=your-api-key
> ```
>
> The nearest file wins. Discovery runs the first time the SDK needs the key, so construction succeeds even when no key is present at startup. The file is read for the key only and does not modify your process environment. Add `.env.braintrust` to your `.gitignore` so the key isn't committed.
>
> **3. Run your app**
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> ./gradlew run
> ```
>
> The agent automatically configures OTel and injects a Braintrust span exporter. For Spring Boot, use `./gradlew bootRun` instead.
>
> > [!NOTE]
> >
> > Not using Gradle? Download the agent JAR from the [GitHub releases page](https://github.com/braintrustdata/braintrust-sdk-java/releases) and add `-javaagent:/path/to/braintrust-java-agent-<version>.jar` to your JVM startup flags directly.
>
> > [accordion] Using with the OpenTelemetry Java agent
> >
> > When the [OpenTelemetry Java agent](https://opentelemetry.io/docs/zero-code/java/agent/) is also attached, the Braintrust agent's auto-instrumentation is suppressed to avoid duplicate spans. To get Braintrust tracing of LLM calls in this setup, use the [`braintrust-otel-extension`](https://central.sonatype.com/artifact/dev.braintrust/braintrust-otel-extension) as an [OTel agent extension](https://opentelemetry.io/docs/zero-code/java/agent/extensions/#single-extension).
> >
> > ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > # build.gradle
> > configurations {
> >     otelAgent
> >     braintrustExtension
> > }
> >
> > dependencies {
> >     otelAgent 'io.opentelemetry.javaagent:opentelemetry-javaagent:<version>'
> >     braintrustExtension 'dev.braintrust:braintrust-otel-extension:+'
> > }
> >
> > tasks.withType(JavaExec).configureEach {
> >     jvmArgs "-javaagent:${configurations.otelAgent.asPath}"
> >     jvmArgs "-Dotel.javaagent.extensions=${configurations.braintrustExtension.asPath}"
> > }
> > ```
> >
> > Then run as normal:
> >
> > ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > ./gradlew run
> > ```
> >
> > > [!NOTE]
> > >
> > > Not using Gradle? Download the `braintrust-otel-extension` JAR from the [GitHub releases page](https://github.com/braintrustdata/braintrust-sdk-java/releases) and pass `-Dotel.javaagent.extensions=/path/to/braintrust-otel-extension-<version>.jar` alongside your existing `-javaagent` flag.
>
> > [accordion] Using with the Datadog Java agent
> >
> > List the Braintrust `-javaagent` flag after the Datadog `-javaagent` flag:
> >
> > ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > java -javaagent:/path/to/dd-java-agent.jar \
> >      -javaagent:/path/to/braintrust-java-agent-<version>.jar \
> >      -jar your-app.jar
> > ```
>
> > [accordion] Filter non-AI spans
> >
> > By default, the Braintrust agent exports all spans. Set `BRAINTRUST_FILTER_AI_SPANS=true` to export only AI-related spans (LLM calls, model invocations) and drop spans from generic instrumentation like HTTP clients and database calls.
> >
> > ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > export BRAINTRUST_FILTER_AI_SPANS=true
> > ```
> >
> > You can also set this programmatically via `BraintrustConfig.builder().filterAISpans(true)`.
> >
> > > [!NOTE]
> > >
> > > Enabling this reduces noise in Braintrust but means you won't see the surrounding trace context (e.g., the HTTP request that triggered an LLM call).
>
> > [accordion] Compress OTel payloads
> >
> > By default, the Braintrust agent gzip-compresses OpenTelemetry span and log payloads before export, reducing network bandwidth with no changes on your side. Set `BRAINTRUST_COMPRESS_OTEL_PAYLOAD=false` to disable span compression.
> >
> > ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > export BRAINTRUST_COMPRESS_OTEL_PAYLOAD=false
> > ```
> >
> > You can also set this programmatically via `BraintrustConfig.builder().compressOtelPayload(false)`.
> >
> > > [!NOTE]
> > >
> > > Compression reduces network bandwidth, but Braintrust span size limits still apply to the uncompressed payload.
>
> > [accordion] Extract base64 attachments
> >
> > By default, the Braintrust span processor detects base64-encoded attachments (images, PDFs, and other binary data) in span inputs and outputs, uploads them to object storage, and replaces them with [attachment](https://docs.braintrust.dev/instrument/attachments.md) references. This reduces span payload sizes and the chance of exceeding OpenTelemetry span size limits. OpenAI, Anthropic, Google Gemini, and AWS Bedrock Converse formats are supported.
> >
> > Each converted attachment is replaced with a reference object in the span data:
> >
> > ```json theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > { "type": "braintrust_attachment", "content_type": "image/png", "filename": "attachment.png", "key": "..." }
> > ```
> >
> > Set `BRAINTRUST_AUTO_CONVERT_AI_ATTACHMENTS=false` to disable conversion.
> >
> > ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> > export BRAINTRUST_AUTO_CONVERT_AI_ATTACHMENTS=false
> > ```
> >
> > You can also set this programmatically via `BraintrustConfig.builder().autoConvertAIAttachments(false)`.
> >
> > > [!NOTE]
> > >
> > > If an attachment upload fails, the span is exported with its original content unchanged, so no data is lost.

> [tab] .NET
>
> Auto-instrumentation in .NET coming soon. Use [manual instrumentation](#manual-instrumentation) for now.

Run your app and check [Braintrust](https://www.braintrust.dev/app) — your LLM calls will appear in the project logs.

> [!NOTE]
>
> Streaming responses are fully supported — Braintrust automatically collects streamed chunks and logs the complete response as a single span.

## Manual instrumentation

Manual instrumentation lets you explicitly instrument individual client instances. This is an alternative to auto-instrumentation, useful if you prefer explicit control or if auto-instrumentation isn't supported by the libraries you're using. Unlike auto-instrumentation, you need to wrap each client instance in your application.

> [tab] TypeScript
>
> ```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> import { initLogger, wrapOpenAI } from "braintrust";
> import OpenAI from "openai";
>
> initLogger({
>   apiKey: process.env.BRAINTRUST_API_KEY,
>   projectName: "My Project (TypeScript)",
> });
>
> // Wrap the OpenAI client to trace all calls
> const client = wrapOpenAI(new OpenAI({ apiKey: process.env.OPENAI_API_KEY }));
> const response = await client.responses.create({
>   model: "gpt-5-mini",
>   input: "What is the capital of France?",
> });
> ```

> [tab] Python
>
> ```python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> import os
> import braintrust
> from braintrust import wrap_openai
> from openai import OpenAI
>
> braintrust.init_logger(
>     api_key=os.environ["BRAINTRUST_API_KEY"],
>     project="My Project (Python)",
> )
>
> # Wrap the OpenAI client to trace all calls
> client = wrap_openai(OpenAI(api_key=os.environ["OPENAI_API_KEY"]))
> response = client.responses.create(
>     model="gpt-5-mini",
>     input="What is the capital of France?",
> )
> ```

> [tab] Ruby
>
> Use `Braintrust.instrument!` with a `target:` to instrument a specific client instance:
>
> ```ruby theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> require 'braintrust'
> require 'openai'
>
> Braintrust.init(
>   api_key: ENV['BRAINTRUST_API_KEY'],
>   default_project: 'My Project (Ruby)',
>   auto_instrument: false
> )
>
> # Wrap a specific OpenAI client to trace all calls
> client = OpenAI::Client.new(access_token: ENV['OPENAI_API_KEY'])
> Braintrust.instrument!(:ruby_openai, target: client)
>
> response = client.responses.create(
>   parameters: {
>     model: 'gpt-5-mini',
>     input: 'What is the capital of France?'
>   }
> )
> ```
>
> Use `:openai` if you're using the [`openai`](https://rubygems.org/gems/openai) gem, or `:ruby_openai` for the [`ruby-openai`](https://rubygems.org/gems/ruby-openai) gem.

> [tab] Go
>
> The Go SDK provides tracing middleware that you pass to your AI provider's client constructor:
>
> ```go theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> package main
>
> import (
> 	"context"
> 	"fmt"
> 	"log"
> 	"os"
>
> 	"github.com/braintrustdata/braintrust-sdk-go"
> 	traceopenai "github.com/braintrustdata/braintrust-sdk-go/trace/contrib/openai"
> 	"github.com/openai/openai-go"
> 	"github.com/openai/openai-go/option"
> 	"github.com/openai/openai-go/responses"
> 	"go.opentelemetry.io/otel"
> 	sdktrace "go.opentelemetry.io/otel/sdk/trace"
> )
>
> func main() {
> 	tp := sdktrace.NewTracerProvider()
> 	defer tp.Shutdown(context.Background())
> 	otel.SetTracerProvider(tp)
>
> 	_, err := braintrust.New(tp,
> 		braintrust.WithProject("My Project (Go)"),
> 		braintrust.WithAPIKey(os.Getenv("BRAINTRUST_API_KEY")),
> 	)
> 	if err != nil {
> 		log.Fatal(err)
> 	}
>
> 	// Create an OpenAI client with tracing middleware
> 	client := openai.NewClient(
> 		option.WithAPIKey(os.Getenv("OPENAI_API_KEY")),
> 		option.WithMiddleware(traceopenai.NewMiddleware()),
> 	)
>
> 	response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
> 		Model: "gpt-5-mini",
> 		Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("What is the capital of France?")},
> 	})
> 	if err != nil {
> 		log.Fatal(err)
> 	}
>
> 	fmt.Println(response.OutputText())
> }
> ```

> [tab] Java
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> # build.gradle
> dependencies {
>     implementation 'dev.braintrust:braintrust-sdk-java:+'
>     implementation 'com.openai:openai-java:+'
> }
> ```
>
> ```java #skip-compile theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> import com.openai.client.OpenAIClient;
> import com.openai.client.okhttp.OpenAIOkHttpClient;
> import com.openai.models.chat.completions.ChatCompletionCreateParams;
> import com.openai.models.chat.completions.ChatCompletionUserMessageParam;
> import dev.braintrust.Braintrust;
> import dev.braintrust.config.BraintrustConfig;
> import dev.braintrust.instrumentation.openai.BraintrustOpenAI;
>
> class Main {
>     public static void main(String[] args) {
>         var config = BraintrustConfig.builder()
>             .apiKey(System.getenv("BRAINTRUST_API_KEY"))
>             .defaultProjectName("My Project (Java)")
>             .build();
>         var braintrust = Braintrust.get(config);
>         var openTelemetry = braintrust.openTelemetryCreate();
>
>         // Wrap the OpenAI client to trace all calls
>         OpenAIClient openaiClient = OpenAIOkHttpClient.builder()
>             .apiKey(System.getenv("OPENAI_API_KEY"))
>             .build();
>         OpenAIClient client = BraintrustOpenAI.wrapOpenAI(openTelemetry, openaiClient);
>
>         var params = ChatCompletionCreateParams.builder()
>             .model("gpt-5-mini")
>             .addMessage(ChatCompletionUserMessageParam.builder()
>                 .content("What is the capital of France?")
>                 .build())
>             .build();
>         var response = client.chat().completions().create(params);
>     }
> }
> ```

> [tab] .NET
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> dotnet add package Braintrust.Sdk
> dotnet add package Braintrust.Sdk.OpenAI
> dotnet add package OpenAI
> ```
>
> ```csharp #skip-compile theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> using System;
> using Braintrust.Sdk;
> using Braintrust.Sdk.Config;
> using Braintrust.Sdk.OpenAI;
> using OpenAI;
> using OpenAI.Chat;
>
> var config = BraintrustConfig.Of(
>     ("BRAINTRUST_API_KEY", Environment.GetEnvironmentVariable("BRAINTRUST_API_KEY")),
>     ("BRAINTRUST_DEFAULT_PROJECT_NAME", "My Project (.NET)"));
> var braintrust = Braintrust.Sdk.Braintrust.Get(config);
> var activitySource = braintrust.GetActivitySource();
>
> // Wrap the OpenAI client to trace all calls
> var openAIClient = BraintrustOpenAI.WrapOpenAI(
>     activitySource, Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
>
> var chatClient = openAIClient.GetChatClient("gpt-5-mini");
> var response = await chatClient.CompleteChatAsync(
>     new ChatMessage[]
>     {
>         new UserChatMessage("What is the capital of France?")
>     });
> ```
>
> For local development, the .NET SDK can instead read `BRAINTRUST_API_KEY` from a `.env.braintrust` file. When no key is set explicitly or through the environment, the SDK searches upward from the working directory (up to 64 parent directories) for a file like this:
>
> ```bash .env.braintrust theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> BRAINTRUST_API_KEY=your-api-key
> ```
>
> The nearest file wins. Discovery runs the first time the SDK needs the key, so construction succeeds even when no key is present at startup. The file is read for the key only and does not modify your process environment. Add `.env.braintrust` to your `.gitignore` so the key isn't committed.

## Braintrust gateway

The [Braintrust gateway](https://docs.braintrust.dev/deploy/gateway.md) provides a unified OpenAI-compatible API for accessing models from many providers. When you call a model through the gateway, your requests are automatically traced — no SDK instrumentation needed. The gateway also provides automatic caching and observability across providers.

## Supported libraries

To help you log traces, Braintrust's SDKs support automatic and manual instrumentation for many common libraries. Select a language to get started.

> [tab] TypeScript
>
> | Library | Min. library version | Setup guide |
> | - | - | - |
> | [openai](https://www.npmjs.com/package/openai) | 4.0.0 | [OpenAI](https://docs.braintrust.dev/integrations/ai-providers/openai.md) |
> | [@anthropic-ai/sdk](https://www.npmjs.com/package/@anthropic-ai/sdk) | 0.60.0 | [Anthropic](https://docs.braintrust.dev/integrations/ai-providers/anthropic.md) |
> | [@anthropic-ai/bedrock-sdk](https://www.npmjs.com/package/@anthropic-ai/bedrock-sdk) | 0.30.2 | [Anthropic](https://docs.braintrust.dev/integrations/ai-providers/anthropic.md#anthropic-bedrock-typescript) |
> | [@aws-sdk/client-bedrock-runtime](https://www.npmjs.com/package/@aws-sdk/client-bedrock-runtime) | 3.1048.0 | [AWS Bedrock](https://docs.braintrust.dev/integrations/ai-providers/bedrock.md#tracing-typescript) |
> | [@google/genai](https://www.npmjs.com/package/@google/genai) | 1.0.0 | [Gemini](https://docs.braintrust.dev/integrations/ai-providers/gemini.md) |
> | [@google/adk](https://www.npmjs.com/package/@google/adk) | 0.6.x, 1.x | [Google ADK](https://docs.braintrust.dev/integrations/agent-frameworks/google.md) |
> | [ai](https://www.npmjs.com/package/ai) (Vercel AI SDK) | 3.0.0 | [Vercel AI SDK](https://docs.braintrust.dev/integrations/sdk-integrations/vercel.md) |
> | [@anthropic-ai/claude-agent-sdk](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk) | 0.1.0 | [Claude Agent SDK](https://docs.braintrust.dev/integrations/agent-frameworks/claude-agent-sdk.md) |
> | [@mistralai/mistralai](https://www.npmjs.com/package/@mistralai/mistralai) | 1.0.0 | [Mistral](https://docs.braintrust.dev/integrations/ai-providers/mistral.md) |
> | [@openrouter/agent](https://www.npmjs.com/package/@openrouter/agent) | 0.1.2 | [OpenRouter Agent](https://docs.braintrust.dev/integrations/agent-frameworks/openrouter-agent.md) |
> | [@openrouter/sdk](https://www.npmjs.com/package/@openrouter/sdk) | 0.9.11 | [OpenRouter SDK](https://docs.braintrust.dev/integrations/ai-providers/openrouter.md) |
> | [@huggingface/inference](https://www.npmjs.com/package/@huggingface/inference) | 2.0.0 | [Hugging Face](https://docs.braintrust.dev/integrations/ai-providers/huggingface.md) |
> | [cohere-ai](https://www.npmjs.com/package/cohere-ai) | 7.0.0 | [Cohere](https://docs.braintrust.dev/integrations/ai-providers/cohere.md) |
> | [groq-sdk](https://www.npmjs.com/package/groq-sdk) | 1.0.0 | [Groq](https://docs.braintrust.dev/integrations/ai-providers/groq.md) |
> | [@openai/agents](https://www.npmjs.com/package/@openai/agents) | 0.0.14 | [OpenAI Agents SDK](https://docs.braintrust.dev/integrations/agent-frameworks/openai-agents-sdk.md) |
> | [@openai/codex-sdk](https://www.npmjs.com/package/@openai/codex-sdk) | 0.128.0 | [OpenAI Codex SDK](https://docs.braintrust.dev/integrations/agent-frameworks/openai-codex-sdk.md) |
> | [@cursor/sdk](https://www.npmjs.com/package/@cursor/sdk) | 1.0.7 | [Cursor SDK](https://docs.braintrust.dev/integrations/agent-frameworks/cursor-sdk.md) |
> | [@flue/runtime](https://www.npmjs.com/package/@flue/runtime) | 0.8.0 | [Flue](https://docs.braintrust.dev/integrations/agent-frameworks/flue.md) |
> | [@strands-agents/sdk](https://www.npmjs.com/package/@strands-agents/sdk) | 1.0.0 | [Strands Agent SDK](https://docs.braintrust.dev/integrations/agent-frameworks/strands-agent.md#setup-typescript) |
> | [@typesafe-ai/sdk](https://www.npmjs.com/package/@typesafe-ai/sdk) | 0.6.0 (below 1.0.0) | [TypeSafe](https://docs.braintrust.dev/integrations/ai-providers/typesafe.md#tracing-typescript), Braintrust v3.34.0+ |
> | [@langchain/core](https://www.npmjs.com/package/@langchain/core) | 0.3.42 | [LangChain](https://docs.braintrust.dev/integrations/sdk-integrations/langchain.md) |
> | [langsmith](https://www.npmjs.com/package/langsmith) | 0.3.30 | [LangSmith](https://docs.braintrust.dev/integrations/sdk-integrations/langsmith.md#tracing-typescript) |
> | [genkit](https://www.npmjs.com/package/genkit) | 1.0.0 | [Firebase Genkit](https://docs.braintrust.dev/integrations/sdk-integrations/firebase-genkit.md) |
> | [@mastra/core](https://www.npmjs.com/package/@mastra/core) | 1.20.0 | [Mastra](https://docs.braintrust.dev/integrations/agent-frameworks/mastra.md) |
> | [eve](https://www.npmjs.com/package/eve) | 0.20.0 | [Eve](https://docs.braintrust.dev/integrations/agent-frameworks/eve.md) |
> | [@earendil-works/pi-coding-agent](https://www.npmjs.com/package/@earendil-works/pi-coding-agent) | 0.79.0 | [Pi Coding Agent SDK](https://docs.braintrust.dev/integrations/agent-frameworks/pi-coding-agent.md), Braintrust v3.40.0+ for v1.x |
> | [agents](https://www.npmjs.com/package/agents) | 0.17.0 | [Cloudflare Agents](https://docs.braintrust.dev/integrations/agent-frameworks/cloudflare-agents.md) |
> | [@cloudflare/ai-chat](https://www.npmjs.com/package/@cloudflare/ai-chat) | 0.9.0 | [Cloudflare AI Chat](https://docs.braintrust.dev/integrations/agent-frameworks/cloudflare-ai-chat.md) |
> | [@cloudflare/think](https://www.npmjs.com/package/@cloudflare/think) | 0.13.0 (below 0.21.0) | [Cloudflare Think](https://docs.braintrust.dev/integrations/agent-frameworks/cloudflare-think.md) |
> | [@huggingface/transformers](https://www.npmjs.com/package/@huggingface/transformers) | 3.0.0 | [Hugging Face Transformers.js](https://docs.braintrust.dev/integrations/ai-providers/huggingface.md#transformers-typescript) |
> | [voyageai](https://www.npmjs.com/package/voyageai) | 0.2.0 | [Voyage AI](https://docs.braintrust.dev/integrations/ai-providers/voyageai.md) |
> | [@elevenlabs/elevenlabs-js](https://www.npmjs.com/package/@elevenlabs/elevenlabs-js) | 2.67.0 | [ElevenLabs](https://docs.braintrust.dev/integrations/ai-providers/elevenlabs.md) |
> | [@livekit/agents](https://www.npmjs.com/package/@livekit/agents) | 1.9.1 (below 1.10.0) | [LiveKit Agents](https://docs.braintrust.dev/integrations/agent-frameworks/livekit-agents.md#auto-instrumentation-typescript), Braintrust v3.39.0+ |
> | [@modelcontextprotocol/sdk](https://www.npmjs.com/package/@modelcontextprotocol/sdk) | 1.2.0 (below 2.0.0) | [MCP SDK](https://docs.braintrust.dev/integrations/sdk-integrations/mcp-sdk.md), Braintrust v3.42.0+ |
> | [@modelcontextprotocol/server](https://www.npmjs.com/package/@modelcontextprotocol/server) | 2.0.0 (below 3.0.0) | [MCP SDK](https://docs.braintrust.dev/integrations/sdk-integrations/mcp-sdk.md), Braintrust v3.42.0+ |
> | [@google/generative-ai](https://www.npmjs.com/package/@google/generative-ai) | 0.24.0 | [Gemini (legacy SDK)](https://docs.braintrust.dev/integrations/ai-providers/gemini.md#google-generative-ai-typescript) |

> [tab] Python
>
> | Library | Min. library version | Setup guide |
> | - | - | - |
> | [openai](https://pypi.org/project/openai/) | 1.71.0 | [OpenAI](https://docs.braintrust.dev/integrations/ai-providers/openai.md) |
> | [anthropic](https://pypi.org/project/anthropic/) | 0.48.0 | [Anthropic](https://docs.braintrust.dev/integrations/ai-providers/anthropic.md) |
> | [google-genai](https://pypi.org/project/google-genai/) | 1.30.0 | [Gemini](https://docs.braintrust.dev/integrations/ai-providers/gemini.md) |
> | [openrouter](https://pypi.org/project/openrouter/) | 0.6.0 | [OpenRouter](https://docs.braintrust.dev/integrations/ai-providers/openrouter.md) |
> | [mistralai](https://pypi.org/project/mistralai/) | 1.12.4 | [Mistral](https://docs.braintrust.dev/integrations/ai-providers/mistral.md) |
> | [openai-agents](https://pypi.org/project/openai-agents/) | 0.0.19 | [OpenAI Agents SDK](https://docs.braintrust.dev/integrations/agent-frameworks/openai-agents-sdk.md) |
> | [claude-agent-sdk](https://pypi.org/project/claude-agent-sdk/) | 0.1.10 | [Claude Agent SDK](https://docs.braintrust.dev/integrations/agent-frameworks/claude-agent-sdk.md) |
> | [litellm](https://pypi.org/project/litellm/) | 1.74.0 | [LiteLLM](https://docs.braintrust.dev/integrations/sdk-integrations/litellm.md) |
> | [google-adk](https://pypi.org/project/google-adk/) | 1.14.1 | [Google ADK](https://docs.braintrust.dev/integrations/agent-frameworks/google.md) |
> | [agentscope](https://pypi.org/project/agentscope/) | 1.0.0 | [AgentScope](https://docs.braintrust.dev/integrations/agent-frameworks/agentscope.md) |
> | [pydantic-ai](https://pypi.org/project/pydantic-ai/) | 1.10.0 | [Pydantic AI](https://docs.braintrust.dev/integrations/agent-frameworks/pydantic-ai.md) |
> | [agno](https://pypi.org/project/agno/) | 2.1.0 | [Agno](https://docs.braintrust.dev/integrations/agent-frameworks/agno.md) |
> | [dspy](https://pypi.org/project/dspy/) | 2.6.0 | [DSPy](https://docs.braintrust.dev/integrations/sdk-integrations/dspy.md) |
> | [langchain-core](https://pypi.org/project/langchain-core/) | 0.3.28 | [LangChain](https://docs.braintrust.dev/integrations/sdk-integrations/langchain.md) |
> | [llama-index-core](https://pypi.org/project/llama-index-core/) | 0.13.0 | [LlamaIndex](https://docs.braintrust.dev/integrations/sdk-integrations/llamaindex.md) |
> | [cohere](https://pypi.org/project/cohere/) | 5.0.0 | [Cohere](https://docs.braintrust.dev/integrations/ai-providers/cohere.md) |
> | [autogen-agentchat](https://pypi.org/project/autogen-agentchat/) | 0.7.0 | [AutoGen](https://docs.braintrust.dev/integrations/agent-frameworks/autogen.md) |
> | [crewai](https://pypi.org/project/crewai/) | 1.13.0 | [CrewAI](https://docs.braintrust.dev/integrations/agent-frameworks/crew-ai.md) |
> | [strands-agents](https://pypi.org/project/strands-agents/) | 1.20.0 | [Strands](https://docs.braintrust.dev/integrations/agent-frameworks/strands-agent.md) |
> | [temporalio](https://pypi.org/project/temporalio/) | 1.19.0 | [Temporal](https://docs.braintrust.dev/integrations/sdk-integrations/temporal.md) |
> | [typesafe-sdk](https://pypi.org/project/typesafe-sdk/) | 0.6.0 | [TypeSafe](https://docs.braintrust.dev/integrations/ai-providers/typesafe.md#tracing-python), Braintrust v0.41.0+ |
> | [instructor](https://pypi.org/project/instructor/) | 1.11.0 | [Instructor](https://docs.braintrust.dev/integrations/sdk-integrations/instructor.md) |
> | [huggingface-hub](https://pypi.org/project/huggingface-hub/) | 0.32.0 | [Hugging Face](https://docs.braintrust.dev/integrations/ai-providers/huggingface.md) |
> | [transformers](https://pypi.org/project/transformers/) | 4.42.0 | [Hugging Face Transformers](https://docs.braintrust.dev/integrations/ai-providers/huggingface.md#setup-python) |
> | [boto3](https://pypi.org/project/boto3/) | 1.34.116 | [AWS Bedrock](https://docs.braintrust.dev/integrations/ai-providers/bedrock.md) |
> | [livekit-agents](https://pypi.org/project/livekit-agents/) | 1.3.1 | [LiveKit Agents](https://docs.braintrust.dev/integrations/agent-frameworks/livekit-agents.md#python) |
> | [pipecat-ai](https://pypi.org/project/pipecat-ai/) | 1.3.0 | [Pipecat](https://docs.braintrust.dev/integrations/agent-frameworks/pipecat.md) |
> | [google-cloud-discoveryengine](https://pypi.org/project/google-cloud-discoveryengine/) | 0.20.3 | [Google Discovery Engine](https://docs.braintrust.dev/integrations/sdk-integrations/google-discovery-engine.md) |
> | [mcp](https://pypi.org/project/mcp/) | 1.28.1 (below 3.0) | [MCP SDK](https://docs.braintrust.dev/integrations/sdk-integrations/mcp-sdk.md), Braintrust v0.49.1+ |
> | [fastmcp](https://pypi.org/project/fastmcp/) | 2.14.7 (below 5.0) | [MCP SDK](https://docs.braintrust.dev/integrations/sdk-integrations/mcp-sdk.md), Braintrust v0.49.1+ |

> [tab] Ruby
>
> | Library | Min. library version | Setup guide |
> | - | - | - |
> | [openai](https://rubygems.org/gems/openai) | 0.1.0 | [OpenAI](https://docs.braintrust.dev/integrations/ai-providers/openai.md) |
> | [ruby-openai](https://rubygems.org/gems/ruby-openai) | 7.0.0 | [OpenAI](https://docs.braintrust.dev/integrations/ai-providers/openai.md) |
> | [anthropic](https://rubygems.org/gems/anthropic) | 0.3.0 | [Anthropic](https://docs.braintrust.dev/integrations/ai-providers/anthropic.md) |
> | [ruby\_llm](https://rubygems.org/gems/ruby_llm) | 1.8.0 | [RubyLLM](https://docs.braintrust.dev/integrations/sdk-integrations/ruby-llm.md) |
> | [roast-ai](https://rubygems.org/gems/roast-ai) | 1.0.0 | [Roast](https://docs.braintrust.dev/integrations/agent-frameworks/roast.md) |

> [tab] Go
>
> | Library | Min. library version | Setup guide |
> | - | - | - |
> | [github.com/openai/openai-go](https://pkg.go.dev/github.com/openai/openai-go) | 1.12.0 | [OpenAI](https://docs.braintrust.dev/integrations/ai-providers/openai.md) |
> | [github.com/anthropics/anthropic-sdk-go](https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go) | 1.23.0 | [Anthropic](https://docs.braintrust.dev/integrations/ai-providers/anthropic.md) |
> | [github.com/aws/aws-sdk-go-v2/service/bedrockruntime](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/bedrockruntime) | 1.49.0 | [AWS Bedrock](https://docs.braintrust.dev/integrations/ai-providers/bedrock.md) |
> | [google.golang.org/genai](https://pkg.go.dev/google.golang.org/genai) | 1.41.0 | [Gemini](https://docs.braintrust.dev/integrations/ai-providers/gemini.md) |
> | [google.golang.org/adk](https://pkg.go.dev/google.golang.org/adk) | 0.4.0 | [Google ADK](https://docs.braintrust.dev/integrations/agent-frameworks/google.md) |
> | [github.com/tmc/langchaingo](https://pkg.go.dev/github.com/tmc/langchaingo) | 0.1.13 | [LangChain](https://docs.braintrust.dev/integrations/sdk-integrations/langchain.md) |
> | [github.com/sashabaranov/go-openai](https://pkg.go.dev/github.com/sashabaranov/go-openai) | 1.41.2 | [OpenAI](https://docs.braintrust.dev/integrations/ai-providers/openai.md) |
> | [github.com/cloudwego/eino](https://pkg.go.dev/github.com/cloudwego/eino) | 0.8.4 | [CloudWeGo Eino](https://docs.braintrust.dev/integrations/sdk-integrations/cloudwego-eino.md) |
> | [github.com/firebase/genkit/go](https://pkg.go.dev/github.com/firebase/genkit/go) | 1.5.0 | [Firebase Genkit](https://docs.braintrust.dev/integrations/sdk-integrations/firebase-genkit.md) |

> [tab] Java
>
> | Library | Min. library version | Setup guide |
> | - | - | - |
> | [com.openai:openai-java](https://central.sonatype.com/artifact/com.openai/openai-java) | 2.15.0 | [OpenAI](https://docs.braintrust.dev/integrations/ai-providers/openai.md) |
> | [com.anthropic:anthropic-java](https://central.sonatype.com/artifact/com.anthropic/anthropic-java) | 2.2.0 | [Anthropic](https://docs.braintrust.dev/integrations/ai-providers/anthropic.md) |
> | [com.google.genai:google-genai](https://central.sonatype.com/artifact/com.google.genai/google-genai) | 1.18.0 | [Gemini](https://docs.braintrust.dev/integrations/ai-providers/gemini.md) |
> | [dev.langchain4j:langchain4j](https://central.sonatype.com/artifact/dev.langchain4j/langchain4j) | 1.8.0 | [LangChain](https://docs.braintrust.dev/integrations/sdk-integrations/langchain.md) |
> | [org.springframework.ai:spring-ai-\*](https://central.sonatype.com/namespace/org.springframework.ai) | 1.0.0 | [Spring AI](https://docs.braintrust.dev/integrations/sdk-integrations/spring-ai.md) |
> | [software.amazon.awssdk:bedrockruntime](https://central.sonatype.com/artifact/software.amazon.awssdk/bedrockruntime) | 2.30.0 | [AWS Bedrock](https://docs.braintrust.dev/integrations/ai-providers/bedrock.md) |

> [tab] .NET
>
> | Library | Min. library version | Setup guide |
> | - | - | - |
> | [OpenAI](https://www.nuget.org/packages/OpenAI) | 2.6.0 | [OpenAI](https://docs.braintrust.dev/integrations/ai-providers/openai.md) |
> | [Anthropic](https://www.nuget.org/packages/Anthropic) | 12.5.0 | [Anthropic](https://docs.braintrust.dev/integrations/ai-providers/anthropic.md) |

> [!NOTE]
>
> Braintrust also integrates with frameworks like [LangChain](https://docs.braintrust.dev/integrations/sdk-integrations/langchain.md), [LangGraph](https://docs.braintrust.dev/integrations/agent-frameworks/langgraph.md), [AgentScope](https://docs.braintrust.dev/integrations/agent-frameworks/agentscope.md), [CrewAI](https://docs.braintrust.dev/integrations/agent-frameworks/crew-ai.md), [LlamaIndex](https://docs.braintrust.dev/integrations/sdk-integrations/llamaindex.md), [Mastra](https://docs.braintrust.dev/integrations/agent-frameworks/mastra.md), [Eve](https://docs.braintrust.dev/integrations/agent-frameworks/eve.md), and [OpenTelemetry](https://docs.braintrust.dev/integrations/sdk-integrations/opentelemetry/send-traces-and-logs.md). Many Python frameworks can be auto-instrumented directly with `braintrust.auto_instrument()`, while others still require framework-specific setup. See [Integrations](https://docs.braintrust.dev/integrations.md).

## Next steps

* [Trace application logic](https://docs.braintrust.dev/instrument/trace-application-logic.md) to trace non-LLM code like data retrieval, tool calls, and business logic
* [Advanced tracing](https://docs.braintrust.dev/instrument/advanced-tracing.md) for distributed tracing, custom rendering, and more
* [Protect sensitive data](https://docs.braintrust.dev/admin/data-management/protect-sensitive-data.md) to redact sensitive values from your traces during ingestion or before upload
* [Explore integrations](https://docs.braintrust.dev/integrations.md) with AI providers, SDKs, and developer tools


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.