pub struct LangfuseClient { /* private fields */ }Expand description
Main client for interacting with the Langfuse API
Implementations§
Source§impl LangfuseClient
impl LangfuseClient
Sourcepub fn configuration(&self) -> &Configuration
pub fn configuration(&self) -> &Configuration
Get the underlying API configuration
Sourcepub async fn create_batcher(
self: Arc<Self>,
config: Option<BatcherConfig>,
) -> Batcher
pub async fn create_batcher( self: Arc<Self>, config: Option<BatcherConfig>, ) -> Batcher
Create a batcher for efficient batch ingestion
The batcher automatically handles:
- Batching events up to size/count limits
- Automatic flushing on intervals
- 207 Multi-Status response parsing
- Retrying only failed events
- Exponential backoff for retryable errors
§Example
let client = Arc::new(ClientBuilder::from_env()?.build()?);
let batcher = client.create_batcher(None).await;Sourcepub fn batcher(&self) -> BatcherBuilderWithClient
pub fn batcher(&self) -> BatcherBuilderWithClient
Start building a Batcher anchored to this client.
Source§impl LangfuseClient
impl LangfuseClient
Sourcepub async fn get_trace(
&self,
trace_id: impl Into<String>,
) -> Result<TraceWithFullDetails>
pub async fn get_trace( &self, trace_id: impl Into<String>, ) -> Result<TraceWithFullDetails>
Get a trace by ID
Sourcepub async fn delete_multiple_traces(&self, trace_ids: Vec<String>) -> Result<()>
pub async fn delete_multiple_traces(&self, trace_ids: Vec<String>) -> Result<()>
Delete multiple traces
Sourcepub async fn get_observation(
&self,
observation_id: impl Into<String>,
) -> Result<ObservationsView>
pub async fn get_observation( &self, observation_id: impl Into<String>, ) -> Result<ObservationsView>
Get a specific observation
Sourcepub async fn binary_score(
&self,
trace_id: impl Into<String>,
name: impl Into<String>,
value: bool,
) -> Result<String>
pub async fn binary_score( &self, trace_id: impl Into<String>, name: impl Into<String>, value: bool, ) -> Result<String>
Create a binary score (0 or 1)
Sourcepub async fn rating_score(
&self,
trace_id: impl Into<String>,
name: impl Into<String>,
rating: u8,
max_rating: u8,
) -> Result<String>
pub async fn rating_score( &self, trace_id: impl Into<String>, name: impl Into<String>, rating: u8, max_rating: u8, ) -> Result<String>
Create a rating score (e.g., 1-5 stars)
§Validation
max_ratingmust be greater than 0ratingmust be less than or equal tomax_rating
Sourcepub async fn categorical_score(
&self,
trace_id: impl Into<String>,
name: impl Into<String>,
category: impl Into<String>,
) -> Result<String>
pub async fn categorical_score( &self, trace_id: impl Into<String>, name: impl Into<String>, category: impl Into<String>, ) -> Result<String>
Create a categorical score
Sourcepub async fn get_dataset(
&self,
dataset_name: impl Into<String>,
) -> Result<Dataset>
pub async fn get_dataset( &self, dataset_name: impl Into<String>, ) -> Result<Dataset>
Get a dataset by name
Sourcepub async fn delete_dataset_run(
&self,
dataset_name: impl Into<String>,
run_name: impl Into<String>,
) -> Result<()>
pub async fn delete_dataset_run( &self, dataset_name: impl Into<String>, run_name: impl Into<String>, ) -> Result<()>
Delete a dataset run
Sourcepub async fn get_dataset_run(
&self,
dataset_name: impl Into<String>,
run_name: impl Into<String>,
) -> Result<DatasetRunWithItems>
pub async fn get_dataset_run( &self, dataset_name: impl Into<String>, run_name: impl Into<String>, ) -> Result<DatasetRunWithItems>
Get a dataset run
Sourcepub async fn get_dataset_runs(
&self,
dataset_name: impl Into<String>,
) -> Result<PaginatedDatasetRuns>
pub async fn get_dataset_runs( &self, dataset_name: impl Into<String>, ) -> Result<PaginatedDatasetRuns>
Get all runs for a dataset
Sourcepub async fn get_dataset_item(
&self,
item_id: impl Into<String>,
) -> Result<DatasetItem>
pub async fn get_dataset_item( &self, item_id: impl Into<String>, ) -> Result<DatasetItem>
Get a specific dataset item
Sourcepub async fn delete_dataset_item(
&self,
item_id: impl Into<String>,
) -> Result<()>
pub async fn delete_dataset_item( &self, item_id: impl Into<String>, ) -> Result<()>
Delete a dataset item
Sourcepub async fn get_prompt(
&self,
prompt_name: impl Into<String>,
version: Option<i32>,
label: Option<&str>,
) -> Result<Prompt>
pub async fn get_prompt( &self, prompt_name: impl Into<String>, version: Option<i32>, label: Option<&str>, ) -> Result<Prompt>
Get a prompt by name and version
Sourcepub fn trace<'f1>(&'f1 self) -> LangfuseClientTraceBuilder<'f1>
pub fn trace<'f1>(&'f1 self) -> LangfuseClientTraceBuilder<'f1>
Create a new trace
Sourcepub fn list_traces<'f1>(&'f1 self) -> LangfuseClientListTracesBuilder<'f1>
pub fn list_traces<'f1>(&'f1 self) -> LangfuseClientListTracesBuilder<'f1>
List traces with optional filters
Sourcepub fn span<'f1>(&'f1 self) -> LangfuseClientSpanBuilder<'f1>
pub fn span<'f1>(&'f1 self) -> LangfuseClientSpanBuilder<'f1>
Create a span observation
Sourcepub fn generation<'f1>(&'f1 self) -> LangfuseClientGenerationBuilder<'f1>
pub fn generation<'f1>(&'f1 self) -> LangfuseClientGenerationBuilder<'f1>
Create a generation observation
Sourcepub fn event<'f1>(&'f1 self) -> LangfuseClientEventBuilder<'f1>
pub fn event<'f1>(&'f1 self) -> LangfuseClientEventBuilder<'f1>
Create an event observation
Sourcepub fn get_observations<'f1>(
&'f1 self,
) -> LangfuseClientGetObservationsBuilder<'f1>
pub fn get_observations<'f1>( &'f1 self, ) -> LangfuseClientGetObservationsBuilder<'f1>
Get multiple observations
Sourcepub fn update_span<'f1>(&'f1 self) -> LangfuseClientUpdateSpanBuilder<'f1>
pub fn update_span<'f1>(&'f1 self) -> LangfuseClientUpdateSpanBuilder<'f1>
Update an existing span
Sourcepub fn update_generation<'f1>(
&'f1 self,
) -> LangfuseClientUpdateGenerationBuilder<'f1>
pub fn update_generation<'f1>( &'f1 self, ) -> LangfuseClientUpdateGenerationBuilder<'f1>
Update an existing generation
Sourcepub fn score<'f1>(&'f1 self) -> LangfuseClientScoreBuilder<'f1>
pub fn score<'f1>(&'f1 self) -> LangfuseClientScoreBuilder<'f1>
Create a score
Sourcepub fn create_dataset<'f1>(&'f1 self) -> LangfuseClientCreateDatasetBuilder<'f1>
pub fn create_dataset<'f1>(&'f1 self) -> LangfuseClientCreateDatasetBuilder<'f1>
Create a dataset
Sourcepub fn list_datasets<'f1>(&'f1 self) -> LangfuseClientListDatasetsBuilder<'f1>
pub fn list_datasets<'f1>(&'f1 self) -> LangfuseClientListDatasetsBuilder<'f1>
List datasets with pagination
Sourcepub fn create_dataset_item<'f1>(
&'f1 self,
) -> LangfuseClientCreateDatasetItemBuilder<'f1>
pub fn create_dataset_item<'f1>( &'f1 self, ) -> LangfuseClientCreateDatasetItemBuilder<'f1>
Create a new dataset item
Sourcepub fn list_dataset_items<'f1>(
&'f1 self,
) -> LangfuseClientListDatasetItemsBuilder<'f1>
pub fn list_dataset_items<'f1>( &'f1 self, ) -> LangfuseClientListDatasetItemsBuilder<'f1>
List dataset items
Sourcepub fn create_prompt<'f1>(&'f1 self) -> LangfuseClientCreatePromptBuilder<'f1>
pub fn create_prompt<'f1>(&'f1 self) -> LangfuseClientCreatePromptBuilder<'f1>
Create a new prompt or a new version of an existing prompt
Sourcepub fn create_chat_prompt<'f1>(
&'f1 self,
) -> LangfuseClientCreateChatPromptBuilder<'f1>
pub fn create_chat_prompt<'f1>( &'f1 self, ) -> LangfuseClientCreateChatPromptBuilder<'f1>
Create a chat prompt with messages
Sourcepub fn update_prompt_version<'f1>(
&'f1 self,
) -> LangfuseClientUpdatePromptVersionBuilder<'f1>
pub fn update_prompt_version<'f1>( &'f1 self, ) -> LangfuseClientUpdatePromptVersionBuilder<'f1>
Update labels for a specific prompt version
Sourcepub fn list_prompts<'f1>(&'f1 self) -> LangfuseClientListPromptsBuilder<'f1>
pub fn list_prompts<'f1>(&'f1 self) -> LangfuseClientListPromptsBuilder<'f1>
List prompts with filters
Trait Implementations§
Source§impl Clone for LangfuseClient
impl Clone for LangfuseClient
Source§fn clone(&self) -> LangfuseClient
fn clone(&self) -> LangfuseClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more