Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Client for langfuse

§Authentication

Authenticate with the API using Basic Auth, get API keys in the project settings:

  • username: Langfuse Public Key
  • password: Langfuse Secret Key

§Exports

Version:

Implementations§

Source§

impl Client

Source

pub fn new(baseurl: &str) -> Self

Create a new client.

baseurl is the base URL provided to the internal reqwest::Client, and should include a scheme and hostname, as well as port and a path stem if applicable.

Source

pub fn new_with_client(baseurl: &str, client: Client) -> Self

Construct a new client with an existing reqwest::Client, allowing more control over its configuration.

baseurl is the base URL provided to the internal reqwest::Client, and should include a scheme and hostname, as well as port and a path stem if applicable.

Source

pub fn baseurl(&self) -> &String

Get the base URL to which requests are made.

Source

pub fn client(&self) -> &Client

Get the internal reqwest::Client used to make requests.

Source

pub fn api_version(&self) -> &'static str

Get the version of this API.

This string is pulled directly from the source OpenAPI document and may be in any format the API selects.

Source§

impl Client

Source

pub fn annotation_queues_list_queues(&self) -> AnnotationQueuesListQueues<'_>

Get all annotation queues

Sends a GET request to /api/public/annotation-queues

Arguments:

  • limit: limit of items per page
  • page: page number, starts at 1
let response = client.annotation_queues_list_queues()
    .limit(limit)
    .page(page)
    .send()
    .await;
Source

pub fn annotation_queues_create_queue(&self) -> AnnotationQueuesCreateQueue<'_>

Create an annotation queue

Sends a POST request to /api/public/annotation-queues

let response = client.annotation_queues_create_queue()
    .body(body)
    .send()
    .await;
Source

pub fn annotation_queues_get_queue(&self) -> AnnotationQueuesGetQueue<'_>

Get an annotation queue by ID

Sends a GET request to /api/public/annotation-queues/{queueId}

Arguments:

  • queue_id: The unique identifier of the annotation queue
let response = client.annotation_queues_get_queue()
    .queue_id(queue_id)
    .send()
    .await;
Source

pub fn annotation_queues_create_queue_assignment( &self, ) -> AnnotationQueuesCreateQueueAssignment<'_>

Create an assignment for a user to an annotation queue

Sends a POST request to /api/public/annotation-queues/{queueId}/assignments

Arguments:

  • queue_id: The unique identifier of the annotation queue
  • body
let response = client.annotation_queues_create_queue_assignment()
    .queue_id(queue_id)
    .body(body)
    .send()
    .await;
Source

pub fn annotation_queues_delete_queue_assignment( &self, ) -> AnnotationQueuesDeleteQueueAssignment<'_>

Delete an assignment for a user to an annotation queue

Sends a DELETE request to /api/public/annotation-queues/{queueId}/assignments

Arguments:

  • queue_id: The unique identifier of the annotation queue
  • body
let response = client.annotation_queues_delete_queue_assignment()
    .queue_id(queue_id)
    .body(body)
    .send()
    .await;
Source

pub fn annotation_queues_list_queue_items( &self, ) -> AnnotationQueuesListQueueItems<'_>

Get items for a specific annotation queue

Sends a GET request to /api/public/annotation-queues/{queueId}/items

Arguments:

  • queue_id: The unique identifier of the annotation queue
  • limit: limit of items per page
  • page: page number, starts at 1
  • status: Filter by status
let response = client.annotation_queues_list_queue_items()
    .queue_id(queue_id)
    .limit(limit)
    .page(page)
    .status(status)
    .send()
    .await;
Source

pub fn annotation_queues_create_queue_item( &self, ) -> AnnotationQueuesCreateQueueItem<'_>

Add an item to an annotation queue

Sends a POST request to /api/public/annotation-queues/{queueId}/items

Arguments:

  • queue_id: The unique identifier of the annotation queue
  • body
let response = client.annotation_queues_create_queue_item()
    .queue_id(queue_id)
    .body(body)
    .send()
    .await;
Source

pub fn annotation_queues_get_queue_item( &self, ) -> AnnotationQueuesGetQueueItem<'_>

Get a specific item from an annotation queue

Sends a GET request to /api/public/annotation-queues/{queueId}/items/{itemId}

Arguments:

  • queue_id: The unique identifier of the annotation queue
  • item_id: The unique identifier of the annotation queue item
let response = client.annotation_queues_get_queue_item()
    .queue_id(queue_id)
    .item_id(item_id)
    .send()
    .await;
Source

pub fn annotation_queues_delete_queue_item( &self, ) -> AnnotationQueuesDeleteQueueItem<'_>

Remove an item from an annotation queue

Sends a DELETE request to /api/public/annotation-queues/{queueId}/items/{itemId}

Arguments:

  • queue_id: The unique identifier of the annotation queue
  • item_id: The unique identifier of the annotation queue item
let response = client.annotation_queues_delete_queue_item()
    .queue_id(queue_id)
    .item_id(item_id)
    .send()
    .await;
Source

pub fn annotation_queues_update_queue_item( &self, ) -> AnnotationQueuesUpdateQueueItem<'_>

Update an annotation queue item

Sends a PATCH request to /api/public/annotation-queues/{queueId}/items/{itemId}

Arguments:

  • queue_id: The unique identifier of the annotation queue
  • item_id: The unique identifier of the annotation queue item
  • body
let response = client.annotation_queues_update_queue_item()
    .queue_id(queue_id)
    .item_id(item_id)
    .body(body)
    .send()
    .await;
Source

pub fn comments_get(&self) -> CommentsGet<'_>

Get all comments

Sends a GET request to /api/public/comments

Arguments:

  • author_user_id: Filter comments by author user id.
  • limit: Limit of items per page. If you encounter api issues due to too large page sizes, try to reduce the limit
  • object_id: Filter comments by object id. If objectType is not provided, an error will be thrown.
  • object_type: Filter comments by object type (trace, observation, session, prompt).
  • page: Page number, starts at 1.
let response = client.comments_get()
    .author_user_id(author_user_id)
    .limit(limit)
    .object_id(object_id)
    .object_type(object_type)
    .page(page)
    .send()
    .await;
Source

pub fn comments_create(&self) -> CommentsCreate<'_>

Create a comment. Comments may be attached to different object types (trace, observation, session, prompt).

Sends a POST request to /api/public/comments

let response = client.comments_create()
    .body(body)
    .send()
    .await;
Source

pub fn comments_get_by_id(&self) -> CommentsGetById<'_>

Get a comment by id

Sends a GET request to /api/public/comments/{commentId}

Arguments:

  • comment_id: The unique langfuse identifier of a comment
let response = client.comments_get_by_id()
    .comment_id(comment_id)
    .send()
    .await;
Source

pub fn dataset_items_list(&self) -> DatasetItemsList<'_>

Get dataset items. Optionally specify a version to get the items as they existed at that point in time. Note: If version parameter is provided, datasetName must also be provided.

Sends a GET request to /api/public/dataset-items

Arguments:

  • dataset_name
  • limit: limit of items per page
  • page: page number, starts at 1
  • source_observation_id
  • source_trace_id
  • version: ISO 8601 timestamp (RFC 3339, Section 5.6) in UTC (e.g., “2026-01-21T14:35:42Z”). If provided, returns state of dataset at this timestamp. If not provided, returns the latest version. Requires datasetName to be specified.
let response = client.dataset_items_list()
    .dataset_name(dataset_name)
    .limit(limit)
    .page(page)
    .source_observation_id(source_observation_id)
    .source_trace_id(source_trace_id)
    .version(version)
    .send()
    .await;
Source

pub fn dataset_items_create(&self) -> DatasetItemsCreate<'_>

Create a dataset item

Sends a POST request to /api/public/dataset-items

let response = client.dataset_items_create()
    .body(body)
    .send()
    .await;
Source

pub fn dataset_items_get(&self) -> DatasetItemsGet<'_>

Get a dataset item

Sends a GET request to /api/public/dataset-items/{id}

let response = client.dataset_items_get()
    .id(id)
    .send()
    .await;
Source

pub fn dataset_items_delete(&self) -> DatasetItemsDelete<'_>

Delete a dataset item and all its run items. This action is irreversible.

Sends a DELETE request to /api/public/dataset-items/{id}

let response = client.dataset_items_delete()
    .id(id)
    .send()
    .await;
Source

pub fn dataset_run_items_list(&self) -> DatasetRunItemsList<'_>

List dataset run items

Sends a GET request to /api/public/dataset-run-items

Arguments:

  • dataset_id
  • limit: limit of items per page
  • page: page number, starts at 1
  • run_name
let response = client.dataset_run_items_list()
    .dataset_id(dataset_id)
    .limit(limit)
    .page(page)
    .run_name(run_name)
    .send()
    .await;
Source

pub fn dataset_run_items_create(&self) -> DatasetRunItemsCreate<'_>

Create a dataset run item

Sends a POST request to /api/public/dataset-run-items

let response = client.dataset_run_items_create()
    .body(body)
    .send()
    .await;
Source

pub fn datasets_get_runs(&self) -> DatasetsGetRuns<'_>

Get dataset runs

Sends a GET request to /api/public/datasets/{datasetName}/runs

Arguments:

  • dataset_name
  • limit: limit of items per page
  • page: page number, starts at 1
let response = client.datasets_get_runs()
    .dataset_name(dataset_name)
    .limit(limit)
    .page(page)
    .send()
    .await;
Source

pub fn datasets_get_run(&self) -> DatasetsGetRun<'_>

Get a dataset run and its items

Sends a GET request to /api/public/datasets/{datasetName}/runs/{runName}

let response = client.datasets_get_run()
    .dataset_name(dataset_name)
    .run_name(run_name)
    .send()
    .await;
Source

pub fn datasets_delete_run(&self) -> DatasetsDeleteRun<'_>

Delete a dataset run and all its run items. This action is irreversible.

Sends a DELETE request to /api/public/datasets/{datasetName}/runs/{runName}

let response = client.datasets_delete_run()
    .dataset_name(dataset_name)
    .run_name(run_name)
    .send()
    .await;
Source

pub fn health_health(&self) -> HealthHealth<'_>

Check health of API and database

Sends a GET request to /api/public/health

let response = client.health_health()
    .send()
    .await;
Source

pub fn ingestion_batch(&self) -> IngestionBatch<'_>

Legacy endpoint for batch ingestion for Langfuse Observability.

-> Please use the OpenTelemetry endpoint (/api/public/otel/v1/traces). Learn more: https://langfuse.com/integrations/native/opentelemetry

Within each batch, there can be multiple events. Each event has a type, an id, a timestamp, metadata and a body. Internally, we refer to this as the “event envelope” as it tells us something about the event but not the trace. We use the event id within this envelope to deduplicate messages to avoid processing the same event twice, i.e. the event id should be unique per request. The event.body.id is the ID of the actual trace and will be used for updates and will be visible within the Langfuse App. I.e. if you want to update a trace, you’d use the same body id, but separate event IDs.

Notes:

  • Introduction to data model: https://langfuse.com/docs/observability/data-model
  • Batch sizes are limited to 3.5 MB in total. You need to adjust the number of events per batch accordingly.
  • The API does not return a 4xx status code for input errors. Instead, it responds with a 207 status code, which includes a list of the encountered errors.

Sends a POST request to /api/public/ingestion

let response = client.ingestion_batch()
    .body(body)
    .send()
    .await;
Source

pub fn blob_storage_integrations_get_blob_storage_integrations( &self, ) -> BlobStorageIntegrationsGetBlobStorageIntegrations<'_>

Get all blob storage integrations for the organization (requires organization-scoped API key)

Sends a GET request to /api/public/integrations/blob-storage

let response = client.blob_storage_integrations_get_blob_storage_integrations()
    .send()
    .await;
Source

pub fn blob_storage_integrations_upsert_blob_storage_integration( &self, ) -> BlobStorageIntegrationsUpsertBlobStorageIntegration<'_>

Create or update a blob storage integration for a specific project (requires organization-scoped API key). The configuration is validated by performing a test upload to the bucket.

Sends a PUT request to /api/public/integrations/blob-storage

let response = client.blob_storage_integrations_upsert_blob_storage_integration()
    .body(body)
    .send()
    .await;
Source

pub fn blob_storage_integrations_delete_blob_storage_integration( &self, ) -> BlobStorageIntegrationsDeleteBlobStorageIntegration<'_>

Delete a blob storage integration by ID (requires organization-scoped API key)

Sends a DELETE request to /api/public/integrations/blob-storage/{id}

let response = client.blob_storage_integrations_delete_blob_storage_integration()
    .id(id)
    .send()
    .await;
Source

pub fn llm_connections_list(&self) -> LlmConnectionsList<'_>

Get all LLM connections in a project

Sends a GET request to /api/public/llm-connections

Arguments:

  • limit: limit of items per page
  • page: page number, starts at 1
let response = client.llm_connections_list()
    .limit(limit)
    .page(page)
    .send()
    .await;
Source

pub fn llm_connections_upsert(&self) -> LlmConnectionsUpsert<'_>

Create or update an LLM connection. The connection is upserted on provider.

Sends a PUT request to /api/public/llm-connections

let response = client.llm_connections_upsert()
    .body(body)
    .send()
    .await;
Source

pub fn media_get_upload_url(&self) -> MediaGetUploadUrl<'_>

Get a presigned upload URL for a media record

Sends a POST request to /api/public/media

let response = client.media_get_upload_url()
    .body(body)
    .send()
    .await;
Source

pub fn media_get(&self) -> MediaGet<'_>

Get a media record

Sends a GET request to /api/public/media/{mediaId}

Arguments:

  • media_id: The unique langfuse identifier of a media record
let response = client.media_get()
    .media_id(media_id)
    .send()
    .await;
Source

pub fn media_patch(&self) -> MediaPatch<'_>

Patch a media record

Sends a PATCH request to /api/public/media/{mediaId}

Arguments:

  • media_id: The unique langfuse identifier of a media record
  • body
let response = client.media_patch()
    .media_id(media_id)
    .body(body)
    .send()
    .await;
Source

pub fn metrics_metrics(&self) -> MetricsMetrics<'_>

Get metrics from the Langfuse project using a query object.

Consider using the v2 metrics endpoint for better performance.

For more details, see the Metrics API documentation.

Sends a GET request to /api/public/metrics

Arguments:

  • query: JSON string containing the query parameters with the following structure:
{
  "view": string,           // Required. One of "traces", "observations", "scores-numeric", "scores-categorical"
  "dimensions": \[           // Optional. Default: [\]
    {
      "field": string       // Field to group by, e.g. "name", "userId", "sessionId"
    }
  ],
  "metrics": \[              // Required. At least one metric must be provided
    {
      "measure": string,    // What to measure, e.g. "count", "latency", "value"
      "aggregation": string // How to aggregate, e.g. "count", "sum", "avg", "p95", "histogram"
    }
  \],
  "filters": \[              // Optional. Default: [\]
    {
      "column": string,     // Column to filter on
      "operator": string,   // Operator, e.g. "=", ">", "<", "contains"
      "value": any,         // Value to compare against
      "type": string,       // Data type, e.g. "string", "number", "stringObject"
      "key": string         // Required only when filtering on metadata
    }
  ],
  "timeDimension": {        // Optional. Default: null. If provided, results will be grouped by time
    "granularity": string   // One of "minute", "hour", "day", "week", "month", "auto"
  },
  "fromTimestamp": string,  // Required. ISO datetime string for start of time range
  "toTimestamp": string,    // Required. ISO datetime string for end of time range
  "orderBy": \[              // Optional. Default: null
    {
      "field": string,      // Field to order by
      "direction": string   // "asc" or "desc"
    }
  \],
  "config": {               // Optional. Query-specific configuration
    "bins": number,         // Optional. Number of bins for histogram (1-100), default: 10
    "row_limit": number     // Optional. Row limit for results (1-1000)
  }
}
let response = client.metrics_metrics()
    .query(query)
    .send()
    .await;
Source

pub fn models_list(&self) -> ModelsList<'_>

Get all models

Sends a GET request to /api/public/models

Arguments:

  • limit: limit of items per page
  • page: page number, starts at 1
let response = client.models_list()
    .limit(limit)
    .page(page)
    .send()
    .await;
Source

pub fn models_create(&self) -> ModelsCreate<'_>

Create a model

Sends a POST request to /api/public/models

let response = client.models_create()
    .body(body)
    .send()
    .await;
Source

pub fn models_get(&self) -> ModelsGet<'_>

Get a model

Sends a GET request to /api/public/models/{id}

let response = client.models_get()
    .id(id)
    .send()
    .await;
Source

pub fn models_delete(&self) -> ModelsDelete<'_>

Delete a model. Cannot delete models managed by Langfuse. You can create your own definition with the same modelName to override the definition though.

Sends a DELETE request to /api/public/models/{id}

let response = client.models_delete()
    .id(id)
    .send()
    .await;
Source

pub fn observations_get_many(&self) -> ObservationsGetMany<'_>

Get a list of observations.

Consider using the v2 observations endpoint for cursor-based pagination and field selection.

Sends a GET request to /api/public/observations

Arguments:

  • environment: Optional filter for observations where the environment is one of the provided values.
  • filter: JSON string containing an array of filter conditions. When provided, this takes precedence over query parameter filters (userId, name, type, level, environment, fromStartTime, …).
§Filter Structure

Each filter condition has the following structure:

\[
  {
    "type": string,           // Required. One of: "datetime", "string", "number", "stringOptions", "categoryOptions", "arrayOptions", "stringObject", "numberObject", "boolean", "null"
    "column": string,         // Required. Column to filter on (see available columns below)
    "operator": string,       // Required. Operator based on type:
                              // - datetime: ">", "<", ">=", "<="
                              // - string: "=", "contains", "does not contain", "starts with", "ends with"
                              // - stringOptions: "any of", "none of"
                              // - categoryOptions: "any of", "none of"
                              // - arrayOptions: "any of", "none of", "all of"
                              // - number: "=", ">", "<", ">=", "<="
                              // - stringObject: "=", "contains", "does not contain", "starts with", "ends with"
                              // - numberObject: "=", ">", "<", ">=", "<="
                              // - boolean: "=", "<>"
                              // - null: "is null", "is not null"
    "value": any,             // Required (except for null type). Value to compare against. Type depends on filter type
    "key": string             // Required only for stringObject, numberObject, and categoryOptions types when filtering on nested fields like metadata
  }
\]
§Available Columns
§Core Observation Fields
  • id (string) - Observation ID
  • type (string) - Observation type (SPAN, GENERATION, EVENT)
  • name (string) - Observation name
  • traceId (string) - Associated trace ID
  • startTime (datetime) - Observation start time
  • endTime (datetime) - Observation end time
  • environment (string) - Environment tag
  • level (string) - Log level (DEBUG, DEFAULT, WARNING, ERROR)
  • statusMessage (string) - Status message
  • version (string) - Version tag
§Performance Metrics
  • latency (number) - Latency in seconds (calculated: end_time - start_time)
  • timeToFirstToken (number) - Time to first token in seconds
  • tokensPerSecond (number) - Output tokens per second
§Token Usage
  • inputTokens (number) - Number of input tokens
  • outputTokens (number) - Number of output tokens
  • totalTokens (number) - Total tokens (alias: tokens)
§Cost Metrics
  • inputCost (number) - Input cost in USD
  • outputCost (number) - Output cost in USD
  • totalCost (number) - Total cost in USD
§Model Information
  • model (string) - Provided model name
  • promptName (string) - Associated prompt name
  • promptVersion (number) - Associated prompt version
§Structured Data
  • metadata (stringObject/numberObject/categoryOptions) - Metadata key-value pairs. Use key parameter to filter on specific metadata keys.
§Associated Trace Fields (requires join with traces table)
  • userId (string) - User ID from associated trace
  • traceName (string) - Name from associated trace
  • traceEnvironment (string) - Environment from associated trace
  • traceTags (arrayOptions) - Tags from associated trace
§Filter Examples
\[
  {
    "type": "string",
    "column": "type",
    "operator": "=",
    "value": "GENERATION"
  },
  {
    "type": "number",
    "column": "latency",
    "operator": ">=",
    "value": 2.5
  },
  {
    "type": "stringObject",
    "column": "metadata",
    "key": "environment",
    "operator": "=",
    "value": "production"
  }
\]
  • from_start_time: Retrieve only observations with a start_time on or after this datetime (ISO 8601).
  • level: Optional filter for observations with a specific level (e.g. “DEBUG”, “DEFAULT”, “WARNING”, “ERROR”).
  • limit: Limit of items per page. If you encounter api issues due to too large page sizes, try to reduce the limit.
  • name
  • page: Page number, starts at 1.
  • parent_observation_id
  • to_start_time: Retrieve only observations with a start_time before this datetime (ISO 8601).
  • trace_id
  • type_
  • user_id
  • version: Optional filter to only include observations with a certain version.
let response = client.observations_get_many()
    .environment(environment)
    .filter(filter)
    .from_start_time(from_start_time)
    .level(level)
    .limit(limit)
    .name(name)
    .page(page)
    .parent_observation_id(parent_observation_id)
    .to_start_time(to_start_time)
    .trace_id(trace_id)
    .type_(type_)
    .user_id(user_id)
    .version(version)
    .send()
    .await;
Source

pub fn observations_get(&self) -> ObservationsGet<'_>

Get a observation

Sends a GET request to /api/public/observations/{observationId}

Arguments:

  • observation_id: The unique langfuse identifier of an observation, can be an event, span or generation
let response = client.observations_get()
    .observation_id(observation_id)
    .send()
    .await;
Source

pub fn organizations_get_organization_api_keys( &self, ) -> OrganizationsGetOrganizationApiKeys<'_>

Get all API keys for the organization associated with the API key (requires organization-scoped API key)

Sends a GET request to /api/public/organizations/apiKeys

let response = client.organizations_get_organization_api_keys()
    .send()
    .await;
Source

pub fn organizations_get_organization_memberships( &self, ) -> OrganizationsGetOrganizationMemberships<'_>

Get all memberships for the organization associated with the API key (requires organization-scoped API key)

Sends a GET request to /api/public/organizations/memberships

let response = client.organizations_get_organization_memberships()
    .send()
    .await;
Source

pub fn organizations_update_organization_membership( &self, ) -> OrganizationsUpdateOrganizationMembership<'_>

Create or update a membership for the organization associated with the API key (requires organization-scoped API key)

Sends a PUT request to /api/public/organizations/memberships

let response = client.organizations_update_organization_membership()
    .body(body)
    .send()
    .await;
Source

pub fn organizations_delete_organization_membership( &self, ) -> OrganizationsDeleteOrganizationMembership<'_>

Delete a membership from the organization associated with the API key (requires organization-scoped API key)

Sends a DELETE request to /api/public/organizations/memberships

let response = client.organizations_delete_organization_membership()
    .body(body)
    .send()
    .await;
Source

pub fn organizations_get_organization_projects( &self, ) -> OrganizationsGetOrganizationProjects<'_>

Get all projects for the organization associated with the API key (requires organization-scoped API key)

Sends a GET request to /api/public/organizations/projects

let response = client.organizations_get_organization_projects()
    .send()
    .await;
Source

pub fn opentelemetry_export_traces(&self) -> OpentelemetryExportTraces<'_>

OpenTelemetry Traces Ingestion Endpoint

This endpoint implements the OTLP/HTTP specification for trace ingestion, providing native OpenTelemetry integration for Langfuse Observability.

Supported Formats:

  • Binary Protobuf: Content-Type: application/x-protobuf
  • JSON Protobuf: Content-Type: application/json
  • Supports gzip compression via Content-Encoding: gzip header

Specification Compliance:

Documentation:

Sends a POST request to /api/public/otel/v1/traces

let response = client.opentelemetry_export_traces()
    .body(body)
    .send()
    .await;
Source

pub fn projects_get(&self) -> ProjectsGet<'_>

Get Project associated with API key (requires project-scoped API key). You can use GET /api/public/organizations/projects to get all projects with an organization-scoped key.

Sends a GET request to /api/public/projects

let response = client.projects_get()
    .send()
    .await;
Source

pub fn projects_create(&self) -> ProjectsCreate<'_>

Create a new project (requires organization-scoped API key)

Sends a POST request to /api/public/projects

let response = client.projects_create()
    .body(body)
    .send()
    .await;
Source

pub fn projects_update(&self) -> ProjectsUpdate<'_>

Update a project by ID (requires organization-scoped API key).

Sends a PUT request to /api/public/projects/{projectId}

let response = client.projects_update()
    .project_id(project_id)
    .body(body)
    .send()
    .await;
Source

pub fn projects_delete(&self) -> ProjectsDelete<'_>

Delete a project by ID (requires organization-scoped API key). Project deletion is processed asynchronously.

Sends a DELETE request to /api/public/projects/{projectId}

let response = client.projects_delete()
    .project_id(project_id)
    .send()
    .await;
Source

pub fn projects_get_api_keys(&self) -> ProjectsGetApiKeys<'_>

Get all API keys for a project (requires organization-scoped API key)

Sends a GET request to /api/public/projects/{projectId}/apiKeys

let response = client.projects_get_api_keys()
    .project_id(project_id)
    .send()
    .await;
Source

pub fn projects_create_api_key(&self) -> ProjectsCreateApiKey<'_>

Create a new API key for a project (requires organization-scoped API key)

Sends a POST request to /api/public/projects/{projectId}/apiKeys

let response = client.projects_create_api_key()
    .project_id(project_id)
    .body(body)
    .send()
    .await;
Source

pub fn projects_delete_api_key(&self) -> ProjectsDeleteApiKey<'_>

Delete an API key for a project (requires organization-scoped API key)

Sends a DELETE request to /api/public/projects/{projectId}/apiKeys/{apiKeyId}

let response = client.projects_delete_api_key()
    .project_id(project_id)
    .api_key_id(api_key_id)
    .send()
    .await;
Source

pub fn organizations_get_project_memberships( &self, ) -> OrganizationsGetProjectMemberships<'_>

Get all memberships for a specific project (requires organization-scoped API key)

Sends a GET request to /api/public/projects/{projectId}/memberships

let response = client.organizations_get_project_memberships()
    .project_id(project_id)
    .send()
    .await;
Source

pub fn organizations_update_project_membership( &self, ) -> OrganizationsUpdateProjectMembership<'_>

Create or update a membership for a specific project (requires organization-scoped API key). The user must already be a member of the organization.

Sends a PUT request to /api/public/projects/{projectId}/memberships

let response = client.organizations_update_project_membership()
    .project_id(project_id)
    .body(body)
    .send()
    .await;
Source

pub fn organizations_delete_project_membership( &self, ) -> OrganizationsDeleteProjectMembership<'_>

Delete a membership from a specific project (requires organization-scoped API key). The user must be a member of the organization.

Sends a DELETE request to /api/public/projects/{projectId}/memberships

let response = client.organizations_delete_project_membership()
    .project_id(project_id)
    .body(body)
    .send()
    .await;
Source

pub fn scim_get_resource_types(&self) -> ScimGetResourceTypes<'_>

Get SCIM Resource Types (requires organization-scoped API key)

Sends a GET request to /api/public/scim/ResourceTypes

let response = client.scim_get_resource_types()
    .send()
    .await;
Source

pub fn scim_get_schemas(&self) -> ScimGetSchemas<'_>

Get SCIM Schemas (requires organization-scoped API key)

Sends a GET request to /api/public/scim/Schemas

let response = client.scim_get_schemas()
    .send()
    .await;
Source

pub fn scim_get_service_provider_config( &self, ) -> ScimGetServiceProviderConfig<'_>

Get SCIM Service Provider Configuration (requires organization-scoped API key)

Sends a GET request to /api/public/scim/ServiceProviderConfig

let response = client.scim_get_service_provider_config()
    .send()
    .await;
Source

pub fn scim_list_users(&self) -> ScimListUsers<'_>

List users in the organization (requires organization-scoped API key)

Sends a GET request to /api/public/scim/Users

Arguments:

  • count: Maximum number of results to return (default 100)
  • filter: Filter expression (e.g. userName eq “value”)
  • start_index: 1-based index of the first result to return (default 1)
let response = client.scim_list_users()
    .count(count)
    .filter(filter)
    .start_index(start_index)
    .send()
    .await;
Source

pub fn scim_create_user(&self) -> ScimCreateUser<'_>

Create a new user in the organization (requires organization-scoped API key)

Sends a POST request to /api/public/scim/Users

let response = client.scim_create_user()
    .body(body)
    .send()
    .await;
Source

pub fn scim_get_user(&self) -> ScimGetUser<'_>

Get a specific user by ID (requires organization-scoped API key)

Sends a GET request to /api/public/scim/Users/{userId}

let response = client.scim_get_user()
    .user_id(user_id)
    .send()
    .await;
Source

pub fn scim_delete_user(&self) -> ScimDeleteUser<'_>

Remove a user from the organization (requires organization-scoped API key). Note that this only removes the user from the organization but does not delete the user entity itself.

Sends a DELETE request to /api/public/scim/Users/{userId}

let response = client.scim_delete_user()
    .user_id(user_id)
    .send()
    .await;
Source

pub fn score_configs_get(&self) -> ScoreConfigsGet<'_>

Get all score configs

Sends a GET request to /api/public/score-configs

Arguments:

  • limit: Limit of items per page. If you encounter api issues due to too large page sizes, try to reduce the limit
  • page: Page number, starts at 1.
let response = client.score_configs_get()
    .limit(limit)
    .page(page)
    .send()
    .await;
Source

pub fn score_configs_create(&self) -> ScoreConfigsCreate<'_>

Create a score configuration (config). Score configs are used to define the structure of scores

Sends a POST request to /api/public/score-configs

let response = client.score_configs_create()
    .body(body)
    .send()
    .await;
Source

pub fn score_configs_get_by_id(&self) -> ScoreConfigsGetById<'_>

Get a score config

Sends a GET request to /api/public/score-configs/{configId}

Arguments:

  • config_id: The unique langfuse identifier of a score config
let response = client.score_configs_get_by_id()
    .config_id(config_id)
    .send()
    .await;
Source

pub fn score_configs_update(&self) -> ScoreConfigsUpdate<'_>

Update a score config

Sends a PATCH request to /api/public/score-configs/{configId}

Arguments:

  • config_id: The unique langfuse identifier of a score config
  • body
let response = client.score_configs_update()
    .config_id(config_id)
    .body(body)
    .send()
    .await;
Source

pub fn score_create(&self) -> ScoreCreate<'_>

Create a score (supports both trace and session scores)

Sends a POST request to /api/public/scores

let response = client.score_create()
    .body(body)
    .send()
    .await;
Source

pub fn score_delete(&self) -> ScoreDelete<'_>

Delete a score (supports both trace and session scores)

Sends a DELETE request to /api/public/scores/{scoreId}

Arguments:

  • score_id: The unique langfuse identifier of a score
let response = client.score_delete()
    .score_id(score_id)
    .send()
    .await;
Source

pub fn sessions_list(&self) -> SessionsList<'_>

Get sessions

Sends a GET request to /api/public/sessions

Arguments:

  • environment: Optional filter for sessions where the environment is one of the provided values.
  • from_timestamp: Optional filter to only include sessions created on or after a certain datetime (ISO 8601)
  • limit: Limit of items per page. If you encounter api issues due to too large page sizes, try to reduce the limit.
  • page: Page number, starts at 1
  • to_timestamp: Optional filter to only include sessions created before a certain datetime (ISO 8601)
let response = client.sessions_list()
    .environment(environment)
    .from_timestamp(from_timestamp)
    .limit(limit)
    .page(page)
    .to_timestamp(to_timestamp)
    .send()
    .await;
Source

pub fn sessions_get(&self) -> SessionsGet<'_>

Get a session. Please note that traces on this endpoint are not paginated, if you plan to fetch large sessions, consider GET /api/public/traces?sessionId=&lt;sessionId&gt;

Sends a GET request to /api/public/sessions/{sessionId}

Arguments:

  • session_id: The unique id of a session
let response = client.sessions_get()
    .session_id(session_id)
    .send()
    .await;
Source

pub fn trace_list(&self) -> TraceList<'_>

Get list of traces

Sends a GET request to /api/public/traces

Arguments:

  • environment: Optional filter for traces where the environment is one of the provided values.
  • fields: Comma-separated list of fields to include in the response. Available field groups: ‘core’ (always included), ‘io’ (input, output, metadata), ‘scores’, ‘observations’, ‘metrics’. If not specified, all fields are returned. Example: ‘core,scores,metrics’. Note: Excluded ‘observations’ or ‘scores’ fields return empty arrays; excluded ‘metrics’ returns -1 for ‘totalCost’ and ‘latency’.
  • filter: JSON string containing an array of filter conditions. When provided, this takes precedence over query parameter filters (userId, name, sessionId, tags, version, release, environment, fromTimestamp, toTimestamp).
§Filter Structure

Each filter condition has the following structure:

\[
  {
    "type": string,           // Required. One of: "datetime", "string", "number", "stringOptions", "categoryOptions", "arrayOptions", "stringObject", "numberObject", "boolean", "null"
    "column": string,         // Required. Column to filter on (see available columns below)
    "operator": string,       // Required. Operator based on type:
                              // - datetime: ">", "<", ">=", "<="
                              // - string: "=", "contains", "does not contain", "starts with", "ends with"
                              // - stringOptions: "any of", "none of"
                              // - categoryOptions: "any of", "none of"
                              // - arrayOptions: "any of", "none of", "all of"
                              // - number: "=", ">", "<", ">=", "<="
                              // - stringObject: "=", "contains", "does not contain", "starts with", "ends with"
                              // - numberObject: "=", ">", "<", ">=", "<="
                              // - boolean: "=", "<>"
                              // - null: "is null", "is not null"
    "value": any,             // Required (except for null type). Value to compare against. Type depends on filter type
    "key": string             // Required only for stringObject, numberObject, and categoryOptions types when filtering on nested fields like metadata
  }
\]
§Available Columns
§Core Trace Fields
  • id (string) - Trace ID
  • name (string) - Trace name
  • timestamp (datetime) - Trace timestamp
  • userId (string) - User ID
  • sessionId (string) - Session ID
  • environment (string) - Environment tag
  • version (string) - Version tag
  • release (string) - Release tag
  • tags (arrayOptions) - Array of tags
  • bookmarked (boolean) - Bookmark status
§Structured Data
  • metadata (stringObject/numberObject/categoryOptions) - Metadata key-value pairs. Use key parameter to filter on specific metadata keys.
§Aggregated Metrics (from observations)

These metrics are aggregated from all observations within the trace:

  • latency (number) - Latency in seconds (time from first observation start to last observation end)
  • inputTokens (number) - Total input tokens across all observations
  • outputTokens (number) - Total output tokens across all observations
  • totalTokens (number) - Total tokens (alias: tokens)
  • inputCost (number) - Total input cost in USD
  • outputCost (number) - Total output cost in USD
  • totalCost (number) - Total cost in USD
§Observation Level Aggregations

These fields aggregate observation levels within the trace:

  • level (string) - Highest severity level (ERROR > WARNING > DEFAULT > DEBUG)
  • warningCount (number) - Count of WARNING level observations
  • errorCount (number) - Count of ERROR level observations
  • defaultCount (number) - Count of DEFAULT level observations
  • debugCount (number) - Count of DEBUG level observations
§Scores (requires join with scores table)
  • scores_avg (number) - Average of numeric scores (alias: scores)
  • score_categories (categoryOptions) - Categorical score values
§Filter Examples
\[
  {
    "type": "datetime",
    "column": "timestamp",
    "operator": ">=",
    "value": "2024-01-01T00:00:00Z"
  },
  {
    "type": "string",
    "column": "userId",
    "operator": "=",
    "value": "user-123"
  },
  {
    "type": "number",
    "column": "totalCost",
    "operator": ">=",
    "value": 0.01
  },
  {
    "type": "arrayOptions",
    "column": "tags",
    "operator": "all of",
    "value": ["production", "critical"\]
  },
  {
    "type": "stringObject",
    "column": "metadata",
    "key": "customer_tier",
    "operator": "=",
    "value": "enterprise"
  }
]
§Performance Notes
  • Filtering on userId, sessionId, or metadata may enable skip indexes for better query performance
  • Score filters require a join with the scores table and may impact query performance
  • from_timestamp: Optional filter to only include traces with a trace.timestamp on or after a certain datetime (ISO 8601)
  • limit: Limit of items per page. If you encounter api issues due to too large page sizes, try to reduce the limit.
  • name
  • order_by: Format of the string [field].[asc/desc]. Fields: id, timestamp, name, userId, release, version, public, bookmarked, sessionId. Example: timestamp.asc
  • page: Page number, starts at 1
  • release: Optional filter to only include traces with a certain release.
  • session_id
  • tags: Only traces that include all of these tags will be returned.
  • to_timestamp: Optional filter to only include traces with a trace.timestamp before a certain datetime (ISO 8601)
  • user_id
  • version: Optional filter to only include traces with a certain version.
let response = client.trace_list()
    .environment(environment)
    .fields(fields)
    .filter(filter)
    .from_timestamp(from_timestamp)
    .limit(limit)
    .name(name)
    .order_by(order_by)
    .page(page)
    .release(release)
    .session_id(session_id)
    .tags(tags)
    .to_timestamp(to_timestamp)
    .user_id(user_id)
    .version(version)
    .send()
    .await;
Source

pub fn trace_delete_multiple(&self) -> TraceDeleteMultiple<'_>

Delete multiple traces

Sends a DELETE request to /api/public/traces

let response = client.trace_delete_multiple()
    .body(body)
    .send()
    .await;
Source

pub fn trace_get(&self) -> TraceGet<'_>

Get a specific trace

Sends a GET request to /api/public/traces/{traceId}

Arguments:

  • trace_id: The unique langfuse identifier of a trace
let response = client.trace_get()
    .trace_id(trace_id)
    .send()
    .await;
Source

pub fn trace_delete(&self) -> TraceDelete<'_>

Delete a specific trace

Sends a DELETE request to /api/public/traces/{traceId}

Arguments:

  • trace_id: The unique langfuse identifier of the trace to delete
let response = client.trace_delete()
    .trace_id(trace_id)
    .send()
    .await;
Source

pub fn datasets_list(&self) -> DatasetsList<'_>

Get all datasets

Sends a GET request to /api/public/v2/datasets

Arguments:

  • limit: limit of items per page
  • page: page number, starts at 1
let response = client.datasets_list()
    .limit(limit)
    .page(page)
    .send()
    .await;
Source

pub fn datasets_create(&self) -> DatasetsCreate<'_>

Create a dataset

Sends a POST request to /api/public/v2/datasets

let response = client.datasets_create()
    .body(body)
    .send()
    .await;
Source

pub fn datasets_get(&self) -> DatasetsGet<'_>

Get a dataset

Sends a GET request to /api/public/v2/datasets/{datasetName}

let response = client.datasets_get()
    .dataset_name(dataset_name)
    .send()
    .await;
Source

pub fn metrics_v2_metrics(&self) -> MetricsV2Metrics<'_>

Get metrics from the Langfuse project using a query object. V2 endpoint with optimized performance.

§V2 Differences
  • Supports observations, scores-numeric, and scores-categorical views only (traces view not supported)
  • Direct access to tags and release fields on observations
  • Backwards-compatible: traceName, traceRelease, traceVersion dimensions are still available on observations view
  • High cardinality dimensions are not supported and will return a 400 error (see below)

For more details, see the Metrics API documentation.

§Available Views
§observations

Query observation-level data (spans, generations, events).

Dimensions:

  • environment - Deployment environment (e.g., production, staging)
  • type - Type of observation (SPAN, GENERATION, EVENT)
  • name - Name of the observation
  • level - Logging level of the observation
  • version - Version of the observation
  • tags - User-defined tags
  • release - Release version
  • traceName - Name of the parent trace (backwards-compatible)
  • traceRelease - Release version of the parent trace (backwards-compatible, maps to release)
  • traceVersion - Version of the parent trace (backwards-compatible, maps to version)
  • providedModelName - Name of the model used
  • promptName - Name of the prompt used
  • promptVersion - Version of the prompt used
  • startTimeMonth - Month of start_time in YYYY-MM format

Measures:

  • count - Total number of observations
  • latency - Observation latency (milliseconds)
  • streamingLatency - Generation latency from completion start to end (milliseconds)
  • inputTokens - Sum of input tokens consumed
  • outputTokens - Sum of output tokens produced
  • totalTokens - Sum of all tokens consumed
  • outputTokensPerSecond - Output tokens per second
  • tokensPerSecond - Total tokens per second
  • inputCost - Input cost (USD)
  • outputCost - Output cost (USD)
  • totalCost - Total cost (USD)
  • timeToFirstToken - Time to first token (milliseconds)
  • countScores - Number of scores attached to the observation
§scores-numeric

Query numeric and boolean score data.

Dimensions:

  • environment - Deployment environment
  • name - Name of the score (e.g., accuracy, toxicity)
  • source - Origin of the score (API, ANNOTATION, EVAL)
  • dataType - Data type (NUMERIC, BOOLEAN)
  • configId - Identifier of the score config
  • timestampMonth - Month in YYYY-MM format
  • timestampDay - Day in YYYY-MM-DD format
  • value - Numeric value of the score
  • traceName - Name of the parent trace
  • tags - Tags
  • traceRelease - Release version
  • traceVersion - Version
  • observationName - Name of the associated observation
  • observationModelName - Model name of the associated observation
  • observationPromptName - Prompt name of the associated observation
  • observationPromptVersion - Prompt version of the associated observation

Measures:

  • count - Total number of scores
  • value - Score value (for aggregations)
§scores-categorical

Query categorical score data. Same dimensions as scores-numeric except uses stringValue instead of value.

Measures:

  • count - Total number of scores
§High Cardinality Dimensions

The following dimensions cannot be used as grouping dimensions in v2 metrics API as they can cause performance issues. Use them in filters instead.

observations view:

  • id - Use traceId filter to narrow down results
  • traceId - Use traceId filter instead
  • userId - Use userId filter instead
  • sessionId - Use sessionId filter instead
  • parentObservationId - Use parentObservationId filter instead

scores-numeric / scores-categorical views:

  • id - Use specific filters to narrow down results
  • traceId - Use traceId filter instead
  • userId - Use userId filter instead
  • sessionId - Use sessionId filter instead
  • observationId - Use observationId filter instead
§Aggregations

Available aggregation functions: sum, avg, count, max, min, p50, p75, p90, p95, p99, histogram

§Time Granularities

Available granularities for timeDimension: auto, minute, hour, day, week, month

  • auto bins the data into approximately 50 buckets based on the time range

Sends a GET request to /api/public/v2/metrics

Arguments:

  • query: JSON string containing the query parameters with the following structure:
{
  "view": string,           // Required. One of "observations", "scores-numeric", "scores-categorical"
  "dimensions": \[           // Optional. Default: [\]
    {
      "field": string       // Field to group by (see available dimensions above)
    }
  ],
  "metrics": \[              // Required. At least one metric must be provided
    {
      "measure": string,    // What to measure (see available measures above)
      "aggregation": string // How to aggregate: "sum", "avg", "count", "max", "min", "p50", "p75", "p90", "p95", "p99", "histogram"
    }
  \],
  "filters": \[              // Optional. Default: [\]
    {
      "column": string,     // Column to filter on (any dimension field)
      "operator": string,   // Operator based on type:
                            // - datetime: ">", "<", ">=", "<="
                            // - string: "=", "contains", "does not contain", "starts with", "ends with"
                            // - stringOptions: "any of", "none of"
                            // - arrayOptions: "any of", "none of", "all of"
                            // - number: "=", ">", "<", ">=", "<="
                            // - stringObject/numberObject: same as string/number with required "key"
                            // - boolean: "=", "<>"
                            // - null: "is null", "is not null"
      "value": any,         // Value to compare against
      "type": string,       // Data type: "datetime", "string", "number", "stringOptions", "categoryOptions", "arrayOptions", "stringObject", "numberObject", "boolean", "null"
      "key": string         // Required only for stringObject/numberObject types (e.g., metadata filtering)
    }
  ],
  "timeDimension": {        // Optional. Default: null. If provided, results will be grouped by time
    "granularity": string   // One of "auto", "minute", "hour", "day", "week", "month"
  },
  "fromTimestamp": string,  // Required. ISO datetime string for start of time range
  "toTimestamp": string,    // Required. ISO datetime string for end of time range (must be after fromTimestamp)
  "orderBy": \[              // Optional. Default: null
    {
      "field": string,      // Field to order by (dimension or metric alias)
      "direction": string   // "asc" or "desc"
    }
  \],
  "config": {               // Optional. Query-specific configuration
    "bins": number,         // Optional. Number of bins for histogram aggregation (1-100), default: 10
    "row_limit": number     // Optional. Maximum number of rows to return (1-1000), default: 100
  }
}
let response = client.metrics_v2_metrics()
    .query(query)
    .send()
    .await;
Source

pub fn observations_v2_get_many(&self) -> ObservationsV2GetMany<'_>

Get a list of observations with cursor-based pagination and flexible field selection.

§Cursor-based Pagination

This endpoint uses cursor-based pagination for efficient traversal of large datasets. The cursor is returned in the response metadata and should be passed in subsequent requests to retrieve the next page of results.

§Field Selection

Use the fields parameter to control which observation fields are returned:

  • core - Always included: id, traceId, startTime, endTime, projectId, parentObservationId, type
  • basic - name, level, statusMessage, version, environment, bookmarked, public, userId, sessionId
  • time - completionStartTime, createdAt, updatedAt
  • io - input, output
  • metadata - metadata (truncated to 200 chars by default, use expandMetadata to get full values)
  • model - providedModelName, internalModelId, modelParameters
  • usage - usageDetails, costDetails, totalCost
  • prompt - promptId, promptName, promptVersion
  • metrics - latency, timeToFirstToken

If not specified, core and basic field groups are returned.

§Filters

Multiple filtering options are available via query parameters or the structured filter parameter. When using the filter parameter, it takes precedence over individual query parameter filters.

Sends a GET request to /api/public/v2/observations

Arguments:

  • cursor: Base64-encoded cursor for pagination. Use the cursor from the previous response to get the next page.
  • environment: Optional filter for observations where the environment is one of the provided values.
  • expand_metadata: Comma-separated list of metadata keys to return non-truncated. By default, metadata values over 200 characters are truncated. Use this parameter to retrieve full values for specific keys. Example: “key1,key2”
  • fields: Comma-separated list of field groups to include in the response. Available groups: core, basic, time, io, metadata, model, usage, prompt, metrics. If not specified, core and basic field groups are returned. Example: “basic,usage,model”
  • filter: JSON string containing an array of filter conditions. When provided, this takes precedence over query parameter filters (userId, name, type, level, environment, fromStartTime, …).
§Filter Structure

Each filter condition has the following structure:

\[
  {
    "type": string,           // Required. One of: "datetime", "string", "number", "stringOptions", "categoryOptions", "arrayOptions", "stringObject", "numberObject", "boolean", "null"
    "column": string,         // Required. Column to filter on (see available columns below)
    "operator": string,       // Required. Operator based on type:
                              // - datetime: ">", "<", ">=", "<="
                              // - string: "=", "contains", "does not contain", "starts with", "ends with"
                              // - stringOptions: "any of", "none of"
                              // - categoryOptions: "any of", "none of"
                              // - arrayOptions: "any of", "none of", "all of"
                              // - number: "=", ">", "<", ">=", "<="
                              // - stringObject: "=", "contains", "does not contain", "starts with", "ends with"
                              // - numberObject: "=", ">", "<", ">=", "<="
                              // - boolean: "=", "<>"
                              // - null: "is null", "is not null"
    "value": any,             // Required (except for null type). Value to compare against. Type depends on filter type
    "key": string             // Required only for stringObject, numberObject, and categoryOptions types when filtering on nested fields like metadata
  }
\]
§Available Columns
§Core Observation Fields
  • id (string) - Observation ID
  • type (string) - Observation type (SPAN, GENERATION, EVENT)
  • name (string) - Observation name
  • traceId (string) - Associated trace ID
  • startTime (datetime) - Observation start time
  • endTime (datetime) - Observation end time
  • environment (string) - Environment tag
  • level (string) - Log level (DEBUG, DEFAULT, WARNING, ERROR)
  • statusMessage (string) - Status message
  • version (string) - Version tag
  • userId (string) - User ID
  • sessionId (string) - Session ID
  • traceName (string) - Name of the parent trace
  • traceTags (arrayOptions) - Tags from the parent trace
  • tags (arrayOptions) - Alias for traceTags
§Performance Metrics
  • latency (number) - Latency in seconds (calculated: end_time - start_time)
  • timeToFirstToken (number) - Time to first token in seconds
  • tokensPerSecond (number) - Output tokens per second
§Token Usage
  • inputTokens (number) - Number of input tokens
  • outputTokens (number) - Number of output tokens
  • totalTokens (number) - Total tokens (alias: tokens)
§Cost Metrics
  • inputCost (number) - Input cost in USD
  • outputCost (number) - Output cost in USD
  • totalCost (number) - Total cost in USD
§Model Information
  • model (string) - Provided model name (alias: providedModelName)
  • promptName (string) - Associated prompt name
  • promptVersion (number) - Associated prompt version
§Structured Data
  • metadata (stringObject/numberObject/categoryOptions) - Metadata key-value pairs. Use key parameter to filter on specific metadata keys.
§Filter Examples
\[
  {
    "type": "string",
    "column": "type",
    "operator": "=",
    "value": "GENERATION"
  },
  {
    "type": "number",
    "column": "latency",
    "operator": ">=",
    "value": 2.5
  },
  {
    "type": "stringObject",
    "column": "metadata",
    "key": "environment",
    "operator": "=",
    "value": "production"
  }
\]
  • from_start_time: Retrieve only observations with a start_time on or after this datetime (ISO 8601).
  • level: Optional filter for observations with a specific level (e.g. “DEBUG”, “DEFAULT”, “WARNING”, “ERROR”).
  • limit: Number of items to return per page. Maximum 1000, default 50.
  • name
  • parent_observation_id
  • parse_io_as_json: Deprecated. Setting this to true will return a 400 error. Input/output fields are always returned as raw strings. Remove this parameter or set it to false.
  • to_start_time: Retrieve only observations with a start_time before this datetime (ISO 8601).
  • trace_id
  • type_: Filter by observation type (e.g., “GENERATION”, “SPAN”, “EVENT”, “AGENT”, “TOOL”, “CHAIN”, “RETRIEVER”, “EVALUATOR”, “EMBEDDING”, “GUARDRAIL”)
  • user_id
  • version: Optional filter to only include observations with a certain version.
let response = client.observations_v2_get_many()
    .cursor(cursor)
    .environment(environment)
    .expand_metadata(expand_metadata)
    .fields(fields)
    .filter(filter)
    .from_start_time(from_start_time)
    .level(level)
    .limit(limit)
    .name(name)
    .parent_observation_id(parent_observation_id)
    .parse_io_as_json(parse_io_as_json)
    .to_start_time(to_start_time)
    .trace_id(trace_id)
    .type_(type_)
    .user_id(user_id)
    .version(version)
    .send()
    .await;
Source

pub fn prompts_list(&self) -> PromptsList<'_>

Get a list of prompt names with versions and labels

Sends a GET request to /api/public/v2/prompts

Arguments:

  • from_updated_at: Optional filter to only include prompt versions created/updated on or after a certain datetime (ISO 8601)
  • label
  • limit: limit of items per page
  • name
  • page: page number, starts at 1
  • tag
  • to_updated_at: Optional filter to only include prompt versions created/updated before a certain datetime (ISO 8601)
let response = client.prompts_list()
    .from_updated_at(from_updated_at)
    .label(label)
    .limit(limit)
    .name(name)
    .page(page)
    .tag(tag)
    .to_updated_at(to_updated_at)
    .send()
    .await;
Source

pub fn prompts_create(&self) -> PromptsCreate<'_>

Create a new version for the prompt with the given name

Sends a POST request to /api/public/v2/prompts

let response = client.prompts_create()
    .body(body)
    .send()
    .await;
Source

pub fn prompt_version_update(&self) -> PromptVersionUpdate<'_>

Update labels for a specific prompt version

Sends a PATCH request to /api/public/v2/prompts/{name}/versions/{version}

Arguments:

  • name: The name of the prompt. If the prompt is in a folder (e.g., “folder/subfolder/prompt-name”), the folder path must be URL encoded.
  • version: Version of the prompt to update
  • body
let response = client.prompt_version_update()
    .name(name)
    .version(version)
    .body(body)
    .send()
    .await;
Source

pub fn prompts_get(&self) -> PromptsGet<'_>

Get a prompt

Sends a GET request to /api/public/v2/prompts/{promptName}

Arguments:

  • prompt_name: The name of the prompt. If the prompt is in a folder (e.g., “folder/subfolder/prompt-name”), the folder path must be URL encoded.
  • label: Label of the prompt to be retrieved. Defaults to “production” if no label or version is set.
  • version: Version of the prompt to be retrieved.
let response = client.prompts_get()
    .prompt_name(prompt_name)
    .label(label)
    .version(version)
    .send()
    .await;
Source

pub fn prompts_delete(&self) -> PromptsDelete<'_>

Delete prompt versions. If neither version nor label is specified, all versions of the prompt are deleted.

Sends a DELETE request to /api/public/v2/prompts/{promptName}

Arguments:

  • prompt_name: The name of the prompt
  • label: Optional label to filter deletion. If specified, deletes all prompt versions that have this label.
  • version: Optional version to filter deletion. If specified, deletes only this specific version of the prompt.
let response = client.prompts_delete()
    .prompt_name(prompt_name)
    .label(label)
    .version(version)
    .send()
    .await;
Source

pub fn score_v2_get(&self) -> ScoreV2Get<'_>

Get a list of scores (supports both trace and session scores)

Sends a GET request to /api/public/v2/scores

Arguments:

  • config_id: Retrieve only scores with a specific configId.
  • data_type: Retrieve only scores with a specific dataType.
  • dataset_run_id: Retrieve only scores with a specific datasetRunId.
  • environment: Optional filter for scores where the environment is one of the provided values.
  • fields: Comma-separated list of field groups to include in the response. Available field groups: ‘score’ (core score fields), ‘trace’ (trace properties: userId, tags, environment, sessionId). If not specified, both ‘score’ and ‘trace’ are returned by default. Example: ‘score’ to exclude trace data, ‘score,trace’ to include both. Note: When filtering by trace properties (using userId or traceTags parameters), the ‘trace’ field group must be included, otherwise a 400 error will be returned.
  • filter: A JSON stringified array of filter objects. Each object requires type, column, operator, and value. Supports filtering by score metadata using the stringObject type. Example: [{“type”:“stringObject”,“column”:“metadata”,“key”:“user_id”,“operator”:“=”,“value”:“abc123”}]. Supported types: stringObject (metadata key-value filtering), string, number, datetime, stringOptions, arrayOptions. Supported operators for stringObject: =, contains, does not contain, starts with, ends with.
  • from_timestamp: Optional filter to only include scores created on or after a certain datetime (ISO 8601)
  • limit: Limit of items per page. If you encounter api issues due to too large page sizes, try to reduce the limit.
  • name: Retrieve only scores with this name.
  • observation_id: Comma-separated list of observation IDs to filter scores by.
  • operator: Retrieve only scores with <operator> value.
  • page: Page number, starts at 1.
  • queue_id: Retrieve only scores with a specific annotation queueId.
  • score_ids: Comma-separated list of score IDs to limit the results to.
  • session_id: Retrieve only scores with a specific sessionId.
  • source: Retrieve only scores from a specific source.
  • to_timestamp: Optional filter to only include scores created before a certain datetime (ISO 8601)
  • trace_id: Retrieve only scores with a specific traceId.
  • trace_tags: Only scores linked to traces that include all of these tags will be returned.
  • user_id: Retrieve only scores with this userId associated to the trace.
  • value: Retrieve only scores with <operator> value.
let response = client.score_v2_get()
    .config_id(config_id)
    .data_type(data_type)
    .dataset_run_id(dataset_run_id)
    .environment(environment)
    .fields(fields)
    .filter(filter)
    .from_timestamp(from_timestamp)
    .limit(limit)
    .name(name)
    .observation_id(observation_id)
    .operator(operator)
    .page(page)
    .queue_id(queue_id)
    .score_ids(score_ids)
    .session_id(session_id)
    .source(source)
    .to_timestamp(to_timestamp)
    .trace_id(trace_id)
    .trace_tags(trace_tags)
    .user_id(user_id)
    .value(value)
    .send()
    .await;
Source

pub fn score_v2_get_by_id(&self) -> ScoreV2GetById<'_>

Get a score (supports both trace and session scores)

Sends a GET request to /api/public/v2/scores/{scoreId}

Arguments:

  • score_id: The unique langfuse identifier of a score
let response = client.score_v2_get_by_id()
    .score_id(score_id)
    .send()
    .await;

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more