examples/

directory
v0.1.1-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2025 License: Apache-2.0

README

Braintrust Go SDK Examples

This directory contains examples demonstrating how to use the Braintrust Go SDK. Examples are organized by complexity and use case.

Getting Started (5 minutes)

Start here to learn basic tracing with popular AI providers:

  • openai/ - Trace OpenAI chat completions
  • anthropic/ - Trace Anthropic Claude messages
  • genai/ - Trace Google Gemini requests

Evaluations (15 minutes)

Learn how to evaluate and improve your AI applications:

  • evals/ - Simple eval with inline dataset and scorers
  • datasets/ - Run evals against downloaded datasets
  • dataset-api/ - Complete workflow: create datasets, use prompts, run evals
  • scorers/ - Custom scoring with online and code-based scorers

Alternative Providers & Libraries

Examples for other AI providers and client libraries:

Advanced Features (30 minutes)

More specialized use cases and integrations:

Internal Examples

The internal/ directory contains comprehensive examples that test all SDK features. These are primarily used for SDK development and validation, not for learning. See internal/README.md for details.

Running Examples

Each example is a standalone Go program. To run an example:

cd examples/openai
go run main.go

Make sure you have the required API keys set as environment variables (e.g., OPENAI_API_KEY, ANTHROPIC_API_KEY, BRAINTRUST_API_KEY).

Directories

Path Synopsis
This example demonstrates basic Anthropic tracing with Braintrust.
This example demonstrates basic Anthropic tracing with Braintrust.
Package main demonstrates manual attachment usage in Braintrust traces.
Package main demonstrates manual attachment usage in Braintrust traces.
Package main demonstrates distributed tracing using W3C baggage propagation.
Package main demonstrates distributed tracing using W3C baggage propagation.
This example demonstrates basic Google Gemini tracing with Braintrust.
This example demonstrates basic Google Gemini tracing with Braintrust.
internal
anthropic command
Anthropic kitchen sink - tests all the Anthropic features with minimal code
Anthropic kitchen sink - tests all the Anthropic features with minimal code
email-evals command
This is a realistic eval example.
This is a realistic eval example.
eval-updates command
This example demonstrates using the Update option to append results to an existing experiment.
This example demonstrates using the Update option to append results to an existing experiment.
functions command
kitchensink command
Package main demonstrates a comprehensive "kitchen sink" example that combines as much Braintrust SDK functionality as possible into a single executable.
Package main demonstrates a comprehensive "kitchen sink" example that combines as much Braintrust SDK functionality as possible into a single executable.
rewrite command
This example demonstrates basic OpenAI tracing with Braintrust.
This example demonstrates basic OpenAI tracing with Braintrust.
This example demonstrates using a Braintrust prompt in an evaluation.
This example demonstrates using a Braintrust prompt in an evaluation.
This example demonstrates OpenAI tracing with Braintrust using the sashabaranov/go-openai library.
This example demonstrates OpenAI tracing with Braintrust using the sashabaranov/go-openai library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL