This directory contains examples demonstrating how to use the Braintrust Go SDK. Examples are organized by complexity and use case.
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
- genkit/ - Trace Genkit model generation with middleware
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
Examples for other AI providers and client libraries:
- sashabaranov-openai/ - OpenAI tracing with sashabaranov/go-openai library
- openrouter/ - Trace OpenRouter requests
- langchaingo/ - Trace LangChainGo multi-turn conversations
- adk-go/ - Trace agents built with the ADK framework
More specialized use cases and integrations:
- manual-llm-logging/ - Manually log LLM calls (for custom AI proxies)
- attachments/ - Include images and files in traces
- prompts/ - Use Braintrust hosted prompts in evaluations
- distributed-tracing/ - W3C baggage propagation across services
- otel/ - Add Braintrust to existing OpenTelemetry setup
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.
Each example is a standalone Go program. To run an example:
cd examples/openai
go run main.goMake sure you have the required API keys set as environment variables (e.g., OPENAI_API_KEY, ANTHROPIC_API_KEY, BRAINTRUST_API_KEY).