langfuse-ergonomic
Ergonomic Rust client for Langfuse, the open-source LLM observability platform.
Features
- 🏗️ Builder Pattern - Intuitive API using the Bon builder pattern library
- 🔄 Async/Await - Full async support with Tokio
- 🔒 Type Safe - Strongly typed with compile-time guarantees
- 🚀 Easy Setup - Simple configuration from environment variables
- 📊 Comprehensive - Support for traces, observations, scores, and more
Installation
[]
= "0.1"
= { = "1", = ["full"] }
= "1"
Quick Start
use LangfuseClient;
use json;
async
Configuration
Set these environment variables:
LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
LANGFUSE_BASE_URL=https://cloud.langfuse.com # Optional
Or configure explicitly:
let client = builder
.public_key
.secret_key
.base_url
.build;
Examples
Check the examples/ directory for more usage examples:
# Trace examples
# Observations (spans, generations, events)
# Scoring and evaluation
API Coverage
Currently Implemented ✅
Traces
- Full trace creation with metadata support
- Session and user tracking
- Tags and custom timestamps
- Input/output data capture
Observations
- Spans - Track execution steps and nested operations
- Generations - Monitor LLM calls with token usage
- Events - Log important milestones and errors
- Nested observations with parent-child relationships
- Log levels (DEBUG, INFO, WARNING, ERROR)
Scoring
- Numeric scores - Evaluate with decimal values (0.0-1.0)
- Categorical scores - Text-based classifications
- Binary scores - Success/failure tracking
- Rating scores - Star ratings and scales
- Trace-level and observation-level scoring
- Score metadata and comments
Coming Soon 🚧
- Dataset management
- Prompt management
- Batch operations
- Fetching existing traces
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
Contributing
See CONTRIBUTING.md for guidelines.