Skip to main content

Crate langfuse

Crate langfuse 

Source
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§

ChatMessage
A chat message in a chat prompt template.
CostDetails
Cost details for LLM generations.
Evaluation
An evaluation result produced by an Evaluator.
LangfuseConfig
Configuration for the Langfuse client.
MediaContent
Content type and raw bytes for media.
MediaReference
Reference token format used in Langfuse for inline media. Format: @@@langfuseMedia:type=<content_type>|id=<media_id>|source=<source>@@@
PropagateAttributes
Attributes that propagate from a parent trace to child spans.
ScoreBody
Body for creating a score.
ScoreBodyBuilder
Builder for constructing a ScoreBody with a fluent API.
SpanUpdateParams
Parameters for batch-updating span attributes.
UsageDetails
Token usage details for LLM generations.

Enums§

LangfuseError
Primary error type for all Langfuse operations.
ObservationType
The 10 observation types supported by Langfuse.
PromptType
The type of prompt template.
ScoreDataType
The data type of a score.
ScoreValue
A score value — can be numeric, categorical, or boolean.
SpanLevel
Severity level for spans.

Type Aliases§

Result
Convenience result type for Langfuse operations.

Attribute Macros§

observe
Instrument a function with Langfuse tracing.