Expand description
Langfuse SDK for Rust — LLM observability, prompt management, and evaluation.
§Quick Start
use langfuse::Langfuse;
let client = Langfuse::new(
langfuse_core::LangfuseConfig::builder()
.public_key("pk-lf-...")
.secret_key("sk-lf-...")
.build()
.unwrap()
).unwrap();Re-exports§
pub use client::Langfuse;pub use langfuse_tracing::context::get_current_observation_id;pub use langfuse_tracing::context::get_current_trace_id;pub use langfuse_tracing::context::propagate_as_baggage;pub use langfuse_tracing::context::propagate_attributes;pub use langfuse_tracing::context_apis::get_current_trace_url;pub use langfuse_tracing::context_apis::score_current_span;pub use langfuse_tracing::context_apis::score_current_span_with;pub use langfuse_tracing::context_apis::score_current_trace;pub use langfuse_tracing::context_apis::set_current_trace_as_public;pub use langfuse_tracing::context_apis::update_current_generation;pub use langfuse_tracing::context_apis::update_current_span;pub use langfuse_tracing::embedding::LangfuseEmbedding;pub use langfuse_tracing::generation::LangfuseGeneration;pub use langfuse_tracing::observe::with_agent;pub use langfuse_tracing::observe::with_chain;pub use langfuse_tracing::observe::with_embedding;pub use langfuse_tracing::observe::with_evaluator;pub use langfuse_tracing::observe::with_generation;pub use langfuse_tracing::observe::with_guardrail;pub use langfuse_tracing::observe::with_observation;pub use langfuse_tracing::observe::with_retriever;pub use langfuse_tracing::observe::with_span;pub use langfuse_tracing::observe::with_tool;pub use langfuse_tracing::span::LangfuseSpan;pub use langfuse_tracing::stream_wrapper::ObservingIterator;pub use langfuse_tracing::stream_wrapper::ObservingStream;
Modules§
- client
- The top-level Langfuse client that ties together all managers and the tracing pipeline.
- datasets
- Dataset management and experiment runner for the Langfuse SDK.
- evaluation
- Evaluation result types for dataset evaluators. Evaluation result types for dataset experiment evaluators.
- http
- HTTP client utilities: shared client builder and retry logic.
- langfuse_
tracing - OpenTelemetry-native tracing pipeline for Langfuse.
- media
- Media management — upload, fetch, and reference-token parsing.
- observation
- Observation types, levels, usage/cost details, and span attributes.
- prompt
- Prompt template types (text and chat).
- prompts
- Prompt management: fetching, caching, and template compilation.
- score
- Score types, values, and builder.
- scoring
- Score management with batched async flush.
Structs§
- Chat
Message - A chat message in a chat prompt template.
- Cost
Details - Cost details for LLM generations.
- Evaluation
- An evaluation result produced by an
Evaluator. - Langfuse
Config - Configuration for the Langfuse client.
- Media
Content - Content type and raw bytes for media.
- Media
Reference - Reference token format used in Langfuse for inline media.
Format:
@@@langfuseMedia:type=<content_type>|id=<media_id>|source=<source>@@@ - Propagate
Attributes - Attributes that propagate from a parent trace to child spans.
- Score
Body - Body for creating a score.
- Score
Body Builder - Builder for constructing a
ScoreBodywith a fluent API. - Span
Update Params - Parameters for batch-updating span attributes.
- Usage
Details - Token usage details for LLM generations.
Enums§
- Langfuse
Error - Primary error type for all Langfuse operations.
- Observation
Type - The 10 observation types supported by Langfuse.
- Prompt
Type - The type of prompt template.
- Score
Data Type - The data type of a score.
- Score
Value - A score value — can be numeric, categorical, or boolean.
- Span
Level - Severity level for spans.
Type Aliases§
- Result
- Convenience result type for Langfuse operations.
Attribute Macros§
- observe
- Instrument a function with Langfuse tracing.