pub struct LangfuseClient { /* private fields */ }Expand description
Async Langfuse ingestion client.
Implementations§
Source§impl LangfuseClient
impl LangfuseClient
Sourcepub fn new(base_url: impl Into<String>, auth: LangfuseAuth) -> Result<Self>
pub fn new(base_url: impl Into<String>, auth: LangfuseAuth) -> Result<Self>
Creates a client from a base URL and auth mode.
base_url may be a Langfuse origin such as https://langfuse.example
or a TinyHumans backend origin. Basic Auth appends Langfuse’s
/api/public/ingestion path; Bearer Auth appends the backend proxy path
/telemetry/langfuse/ingestion.
Sourcepub fn direct(
base_url: impl Into<String>,
public_key: impl Into<String>,
secret_key: impl Into<String>,
) -> Result<Self>
pub fn direct( base_url: impl Into<String>, public_key: impl Into<String>, secret_key: impl Into<String>, ) -> Result<Self>
Creates a direct-to-Langfuse client using Basic Auth.
Sourcepub fn proxy(
base_url: impl Into<String>,
token: impl Into<String>,
) -> Result<Self>
pub fn proxy( base_url: impl Into<String>, token: impl Into<String>, ) -> Result<Self>
Creates a client for the TinyHumans backend proxy.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Reads configuration from environment variables.
Direct mode: LANGFUSE_BASE_URL, LANGFUSE_PUBLIC_KEY,
LANGFUSE_SECRET_KEY.
Proxy mode: TINYHUMANS_LANGFUSE_PROXY_URL, TINYHUMANS_AUTH_TOKEN.
Proxy mode wins when TINYHUMANS_LANGFUSE_PROXY_URL is set.
Sourcepub fn build_ingestion_batch(
&self,
trace: LangfuseTraceConfig,
observations: &[AgentObservation],
) -> Result<Value>
pub fn build_ingestion_batch( &self, trace: LangfuseTraceConfig, observations: &[AgentObservation], ) -> Result<Value>
Builds a Langfuse ingestion payload without sending it.
Sourcepub fn build_score_batch(&self, score: LangfuseScore) -> Value
pub fn build_score_batch(&self, score: LangfuseScore) -> Value
Builds a score-create ingestion batch for score without sending it.
The score id defaults to a deterministic value derived from the trace,
observation, and name so re-scoring the same target is idempotent
(Langfuse upserts scores by id). Pair with a trace_id that matches an
exported trace — recall the harness/graph exporters default their trace
id to the run’s root_run_id — to attach an evaluation to a run.
Sourcepub async fn create_score(&self, score: LangfuseScore) -> Result<Value>
pub async fn create_score(&self, score: LangfuseScore) -> Result<Value>
Attaches an evaluation score to an already-exported trace (or one of
its observations) by sending a score-create ingestion batch. Mirrors
Langfuse’s createScore — the way LangChain/LangGraph traces are graded
after the fact (human ratings, LLM-as-judge, regression metrics).
Sourcepub async fn send_observations(
&self,
trace: LangfuseTraceConfig,
observations: &[AgentObservation],
) -> Result<Value>
pub async fn send_observations( &self, trace: LangfuseTraceConfig, observations: &[AgentObservation], ) -> Result<Value>
Sends observations as one Langfuse ingestion batch.
Sourcepub async fn send_batch(&self, payload: Value) -> Result<Value>
pub async fn send_batch(&self, payload: Value) -> Result<Value>
Posts a pre-built ingestion payload to the configured endpoint,
attaching the right auth header and translating transport/HTTP errors.
This is the shared transport used by Self::send_observations. Other
exporters that build their own { "batch": [...] } payload — such as the
graph observability exporter — reuse this method so authentication,
endpoint normalization, and the Langfuse 207 Multi-Status handling live
in one place.
Trait Implementations§
Source§impl Clone for LangfuseClient
impl Clone for LangfuseClient
Source§fn clone(&self) -> LangfuseClient
fn clone(&self) -> LangfuseClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more