braintrust-sdk-rust
Rust SDK for Braintrust logging and tracing.
Early Development Notice: This SDK is in early development (alpha). Expect backwards-incompatible changes between releases until we reach 1.0.
Installation
Add this to your Cargo.toml:
[]
= "0.1.0-alpha.1"
Usage
use ;
use json;
async
Features
- Span-based logging: Create spans to track LLM calls and other operations
- Usage metrics extraction: Built-in extractors for OpenAI and Anthropic usage metrics
- Async-first: Built on Tokio for high-performance async operations
- Background submission: Logs are submitted in the background to minimize latency
Extracting Usage Metrics
The SDK includes helpers for extracting usage metrics from provider responses:
use ;
use json;
// Extract from OpenAI response
let openai_response = json!;
let usage = extract_openai_usage;
// Extract from Anthropic response
let anthropic_response = json!;
let usage = extract_anthropic_usage;
License
This project is licensed under the Apache License, Version 2.0.