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
- OpenAPI spec: https://cloud.langfuse.com/generated/api/openapi.yml
Version:
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(baseurl: &str) -> Self
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.
Sourcepub fn new_with_client(baseurl: &str, client: Client) -> Self
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.
Sourcepub fn api_version(&self) -> &'static str
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
impl Client
Sourcepub fn annotation_queues_list_queues(&self) -> AnnotationQueuesListQueues<'_>
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 pagepage: page number, starts at 1
let response = client.annotation_queues_list_queues()
.limit(limit)
.page(page)
.send()
.await;Sourcepub fn annotation_queues_create_queue(&self) -> AnnotationQueuesCreateQueue<'_>
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;Sourcepub fn annotation_queues_get_queue(&self) -> AnnotationQueuesGetQueue<'_>
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;Sourcepub fn annotation_queues_create_queue_assignment(
&self,
) -> AnnotationQueuesCreateQueueAssignment<'_>
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 queuebody
let response = client.annotation_queues_create_queue_assignment()
.queue_id(queue_id)
.body(body)
.send()
.await;Sourcepub fn annotation_queues_delete_queue_assignment(
&self,
) -> AnnotationQueuesDeleteQueueAssignment<'_>
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 queuebody
let response = client.annotation_queues_delete_queue_assignment()
.queue_id(queue_id)
.body(body)
.send()
.await;Sourcepub fn annotation_queues_list_queue_items(
&self,
) -> AnnotationQueuesListQueueItems<'_>
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 queuelimit: limit of items per pagepage: page number, starts at 1status: Filter by status
let response = client.annotation_queues_list_queue_items()
.queue_id(queue_id)
.limit(limit)
.page(page)
.status(status)
.send()
.await;Sourcepub fn annotation_queues_create_queue_item(
&self,
) -> AnnotationQueuesCreateQueueItem<'_>
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 queuebody
let response = client.annotation_queues_create_queue_item()
.queue_id(queue_id)
.body(body)
.send()
.await;Sourcepub fn annotation_queues_get_queue_item(
&self,
) -> AnnotationQueuesGetQueueItem<'_>
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 queueitem_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;Sourcepub fn annotation_queues_delete_queue_item(
&self,
) -> AnnotationQueuesDeleteQueueItem<'_>
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 queueitem_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;Sourcepub fn annotation_queues_update_queue_item(
&self,
) -> AnnotationQueuesUpdateQueueItem<'_>
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 queueitem_id: The unique identifier of the annotation queue itembody
let response = client.annotation_queues_update_queue_item()
.queue_id(queue_id)
.item_id(item_id)
.body(body)
.send()
.await;Sourcepub fn comments_get(&self) -> CommentsGet<'_>
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 limitobject_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;Sourcepub fn comments_create(&self) -> CommentsCreate<'_>
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;Sourcepub fn comments_get_by_id(&self) -> CommentsGetById<'_>
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;Sourcepub fn dataset_items_list(&self) -> DatasetItemsList<'_>
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_namelimit: limit of items per pagepage: page number, starts at 1source_observation_idsource_trace_idversion: 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;Sourcepub fn dataset_items_create(&self) -> DatasetItemsCreate<'_>
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;Sourcepub fn dataset_items_get(&self) -> DatasetItemsGet<'_>
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;Sourcepub fn dataset_items_delete(&self) -> DatasetItemsDelete<'_>
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;Sourcepub fn dataset_run_items_list(&self) -> DatasetRunItemsList<'_>
pub fn dataset_run_items_list(&self) -> DatasetRunItemsList<'_>
List dataset run items
Sends a GET request to /api/public/dataset-run-items
Arguments:
dataset_idlimit: limit of items per pagepage: page number, starts at 1run_name
let response = client.dataset_run_items_list()
.dataset_id(dataset_id)
.limit(limit)
.page(page)
.run_name(run_name)
.send()
.await;Sourcepub fn dataset_run_items_create(&self) -> DatasetRunItemsCreate<'_>
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;Sourcepub fn datasets_get_runs(&self) -> DatasetsGetRuns<'_>
pub fn datasets_get_runs(&self) -> DatasetsGetRuns<'_>
Get dataset runs
Sends a GET request to /api/public/datasets/{datasetName}/runs
Arguments:
dataset_namelimit: limit of items per pagepage: page number, starts at 1
let response = client.datasets_get_runs()
.dataset_name(dataset_name)
.limit(limit)
.page(page)
.send()
.await;Sourcepub fn datasets_get_run(&self) -> DatasetsGetRun<'_>
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;Sourcepub fn datasets_delete_run(&self) -> DatasetsDeleteRun<'_>
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;Sourcepub fn health_health(&self) -> HealthHealth<'_>
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;Sourcepub fn ingestion_batch(&self) -> IngestionBatch<'_>
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;Sourcepub fn blob_storage_integrations_get_blob_storage_integrations(
&self,
) -> BlobStorageIntegrationsGetBlobStorageIntegrations<'_>
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;Sourcepub fn blob_storage_integrations_upsert_blob_storage_integration(
&self,
) -> BlobStorageIntegrationsUpsertBlobStorageIntegration<'_>
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;Sourcepub fn blob_storage_integrations_delete_blob_storage_integration(
&self,
) -> BlobStorageIntegrationsDeleteBlobStorageIntegration<'_>
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;Sourcepub fn llm_connections_list(&self) -> LlmConnectionsList<'_>
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 pagepage: page number, starts at 1
let response = client.llm_connections_list()
.limit(limit)
.page(page)
.send()
.await;Sourcepub fn llm_connections_upsert(&self) -> LlmConnectionsUpsert<'_>
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;Sourcepub fn media_get_upload_url(&self) -> MediaGetUploadUrl<'_>
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;Sourcepub fn media_get(&self) -> MediaGet<'_>
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;Sourcepub fn media_patch(&self) -> MediaPatch<'_>
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 recordbody
let response = client.media_patch()
.media_id(media_id)
.body(body)
.send()
.await;Sourcepub fn metrics_metrics(&self) -> MetricsMetrics<'_>
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;Sourcepub fn models_list(&self) -> ModelsList<'_>
pub fn models_list(&self) -> ModelsList<'_>
Get all models
Sends a GET request to /api/public/models
Arguments:
limit: limit of items per pagepage: page number, starts at 1
let response = client.models_list()
.limit(limit)
.page(page)
.send()
.await;Sourcepub fn models_create(&self) -> ModelsCreate<'_>
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;Sourcepub fn models_get(&self) -> ModelsGet<'_>
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;Sourcepub fn models_delete(&self) -> ModelsDelete<'_>
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;Sourcepub fn observations_get_many(&self) -> ObservationsGetMany<'_>
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 IDtype(string) - Observation type (SPAN, GENERATION, EVENT)name(string) - Observation nametraceId(string) - Associated trace IDstartTime(datetime) - Observation start timeendTime(datetime) - Observation end timeenvironment(string) - Environment taglevel(string) - Log level (DEBUG, DEFAULT, WARNING, ERROR)statusMessage(string) - Status messageversion(string) - Version tag
§Performance Metrics
latency(number) - Latency in seconds (calculated: end_time - start_time)timeToFirstToken(number) - Time to first token in secondstokensPerSecond(number) - Output tokens per second
§Token Usage
inputTokens(number) - Number of input tokensoutputTokens(number) - Number of output tokenstotalTokens(number) - Total tokens (alias:tokens)
§Cost Metrics
inputCost(number) - Input cost in USDoutputCost(number) - Output cost in USDtotalCost(number) - Total cost in USD
§Model Information
model(string) - Provided model namepromptName(string) - Associated prompt namepromptVersion(number) - Associated prompt version
§Structured Data
metadata(stringObject/numberObject/categoryOptions) - Metadata key-value pairs. Usekeyparameter to filter on specific metadata keys.
§Associated Trace Fields (requires join with traces table)
userId(string) - User ID from associated tracetraceName(string) - Name from associated tracetraceEnvironment(string) - Environment from associated tracetraceTags(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.namepage: Page number, starts at 1.parent_observation_idto_start_time: Retrieve only observations with a start_time before this datetime (ISO 8601).trace_idtype_user_idversion: 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;Sourcepub fn observations_get(&self) -> ObservationsGet<'_>
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;Sourcepub fn organizations_get_organization_api_keys(
&self,
) -> OrganizationsGetOrganizationApiKeys<'_>
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;Sourcepub fn organizations_get_organization_memberships(
&self,
) -> OrganizationsGetOrganizationMemberships<'_>
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;Sourcepub fn organizations_update_organization_membership(
&self,
) -> OrganizationsUpdateOrganizationMembership<'_>
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;Sourcepub fn organizations_delete_organization_membership(
&self,
) -> OrganizationsDeleteOrganizationMembership<'_>
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;Sourcepub fn organizations_get_organization_projects(
&self,
) -> OrganizationsGetOrganizationProjects<'_>
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;Sourcepub fn opentelemetry_export_traces(&self) -> OpentelemetryExportTraces<'_>
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: gzipheader
Specification Compliance:
- Conforms to OTLP/HTTP Trace Export
- Implements
ExportTraceServiceRequestmessage format
Documentation:
- Integration guide: https://langfuse.com/integrations/native/opentelemetry
- Data model: https://langfuse.com/docs/observability/data-model
Sends a POST request to /api/public/otel/v1/traces
let response = client.opentelemetry_export_traces()
.body(body)
.send()
.await;Sourcepub fn projects_get(&self) -> ProjectsGet<'_>
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;Sourcepub fn projects_create(&self) -> ProjectsCreate<'_>
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;Sourcepub fn projects_update(&self) -> ProjectsUpdate<'_>
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;Sourcepub fn projects_delete(&self) -> ProjectsDelete<'_>
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;Sourcepub fn projects_get_api_keys(&self) -> ProjectsGetApiKeys<'_>
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;Sourcepub fn projects_create_api_key(&self) -> ProjectsCreateApiKey<'_>
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;Sourcepub fn projects_delete_api_key(&self) -> ProjectsDeleteApiKey<'_>
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;Sourcepub fn organizations_get_project_memberships(
&self,
) -> OrganizationsGetProjectMemberships<'_>
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;Sourcepub fn organizations_update_project_membership(
&self,
) -> OrganizationsUpdateProjectMembership<'_>
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;Sourcepub fn organizations_delete_project_membership(
&self,
) -> OrganizationsDeleteProjectMembership<'_>
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;Sourcepub fn scim_get_resource_types(&self) -> ScimGetResourceTypes<'_>
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;Sourcepub fn scim_get_schemas(&self) -> ScimGetSchemas<'_>
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;Sourcepub fn scim_get_service_provider_config(
&self,
) -> ScimGetServiceProviderConfig<'_>
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;Sourcepub fn scim_list_users(&self) -> ScimListUsers<'_>
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;Sourcepub fn scim_create_user(&self) -> ScimCreateUser<'_>
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;Sourcepub fn scim_get_user(&self) -> ScimGetUser<'_>
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;Sourcepub fn scim_delete_user(&self) -> ScimDeleteUser<'_>
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;Sourcepub fn score_configs_get(&self) -> ScoreConfigsGet<'_>
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 limitpage: Page number, starts at 1.
let response = client.score_configs_get()
.limit(limit)
.page(page)
.send()
.await;Sourcepub fn score_configs_create(&self) -> ScoreConfigsCreate<'_>
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;Sourcepub fn score_configs_get_by_id(&self) -> ScoreConfigsGetById<'_>
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;Sourcepub fn score_configs_update(&self) -> ScoreConfigsUpdate<'_>
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 configbody
let response = client.score_configs_update()
.config_id(config_id)
.body(body)
.send()
.await;Sourcepub fn score_create(&self) -> ScoreCreate<'_>
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;Sourcepub fn score_delete(&self) -> ScoreDelete<'_>
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;Sourcepub fn sessions_list(&self) -> SessionsList<'_>
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 1to_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;Sourcepub fn sessions_get(&self) -> SessionsGet<'_>
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=<sessionId>
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;Sourcepub fn trace_list(&self) -> TraceList<'_>
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 IDname(string) - Trace nametimestamp(datetime) - Trace timestampuserId(string) - User IDsessionId(string) - Session IDenvironment(string) - Environment tagversion(string) - Version tagrelease(string) - Release tagtags(arrayOptions) - Array of tagsbookmarked(boolean) - Bookmark status
§Structured Data
metadata(stringObject/numberObject/categoryOptions) - Metadata key-value pairs. Usekeyparameter 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 observationsoutputTokens(number) - Total output tokens across all observationstotalTokens(number) - Total tokens (alias:tokens)inputCost(number) - Total input cost in USDoutputCost(number) - Total output cost in USDtotalCost(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 observationserrorCount(number) - Count of ERROR level observationsdefaultCount(number) - Count of DEFAULT level observationsdebugCount(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, ormetadatamay 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.nameorder_by: Format of the string [field].[asc/desc]. Fields: id, timestamp, name, userId, release, version, public, bookmarked, sessionId. Example: timestamp.ascpage: Page number, starts at 1release: Optional filter to only include traces with a certain release.session_idtags: 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_idversion: 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;Sourcepub fn trace_delete_multiple(&self) -> TraceDeleteMultiple<'_>
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;Sourcepub fn trace_get(&self) -> TraceGet<'_>
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;Sourcepub fn trace_delete(&self) -> TraceDelete<'_>
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;Sourcepub fn datasets_list(&self) -> DatasetsList<'_>
pub fn datasets_list(&self) -> DatasetsList<'_>
Get all datasets
Sends a GET request to /api/public/v2/datasets
Arguments:
limit: limit of items per pagepage: page number, starts at 1
let response = client.datasets_list()
.limit(limit)
.page(page)
.send()
.await;Sourcepub fn datasets_create(&self) -> DatasetsCreate<'_>
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;Sourcepub fn datasets_get(&self) -> DatasetsGet<'_>
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;Sourcepub fn metrics_v2_metrics(&self) -> MetricsV2Metrics<'_>
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, andscores-categoricalviews 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 observationlevel- Logging level of the observationversion- Version of the observationtags- User-defined tagsrelease- Release versiontraceName- 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 usedpromptName- Name of the prompt usedpromptVersion- Version of the prompt usedstartTimeMonth- Month of start_time in YYYY-MM format
Measures:
count- Total number of observationslatency- Observation latency (milliseconds)streamingLatency- Generation latency from completion start to end (milliseconds)inputTokens- Sum of input tokens consumedoutputTokens- Sum of output tokens producedtotalTokens- Sum of all tokens consumedoutputTokensPerSecond- Output tokens per secondtokensPerSecond- Total tokens per secondinputCost- 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 environmentname- 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 configtimestampMonth- Month in YYYY-MM formattimestampDay- Day in YYYY-MM-DD formatvalue- Numeric value of the scoretraceName- Name of the parent tracetags- TagstraceRelease- Release versiontraceVersion- VersionobservationName- Name of the associated observationobservationModelName- Model name of the associated observationobservationPromptName- Prompt name of the associated observationobservationPromptVersion- Prompt version of the associated observation
Measures:
count- Total number of scoresvalue- 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 resultstraceId- Use traceId filter insteaduserId- Use userId filter insteadsessionId- Use sessionId filter insteadparentObservationId- Use parentObservationId filter instead
scores-numeric / scores-categorical views:
id- Use specific filters to narrow down resultstraceId- Use traceId filter insteaduserId- Use userId filter insteadsessionId- Use sessionId filter insteadobservationId- 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
autobins 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;Sourcepub fn observations_v2_get_many(&self) -> ObservationsV2GetMany<'_>
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, typebasic- name, level, statusMessage, version, environment, bookmarked, public, userId, sessionIdtime- completionStartTime, createdAt, updatedAtio- input, outputmetadata- metadata (truncated to 200 chars by default, useexpandMetadatato get full values)model- providedModelName, internalModelId, modelParametersusage- usageDetails, costDetails, totalCostprompt- promptId, promptName, promptVersionmetrics- 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,coreandbasicfield 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 IDtype(string) - Observation type (SPAN, GENERATION, EVENT)name(string) - Observation nametraceId(string) - Associated trace IDstartTime(datetime) - Observation start timeendTime(datetime) - Observation end timeenvironment(string) - Environment taglevel(string) - Log level (DEBUG, DEFAULT, WARNING, ERROR)statusMessage(string) - Status messageversion(string) - Version taguserId(string) - User IDsessionId(string) - Session ID
§Trace-Related Fields
traceName(string) - Name of the parent tracetraceTags(arrayOptions) - Tags from the parent tracetags(arrayOptions) - Alias for traceTags
§Performance Metrics
latency(number) - Latency in seconds (calculated: end_time - start_time)timeToFirstToken(number) - Time to first token in secondstokensPerSecond(number) - Output tokens per second
§Token Usage
inputTokens(number) - Number of input tokensoutputTokens(number) - Number of output tokenstotalTokens(number) - Total tokens (alias:tokens)
§Cost Metrics
inputCost(number) - Input cost in USDoutputCost(number) - Output cost in USDtotalCost(number) - Total cost in USD
§Model Information
model(string) - Provided model name (alias:providedModelName)promptName(string) - Associated prompt namepromptVersion(number) - Associated prompt version
§Structured Data
metadata(stringObject/numberObject/categoryOptions) - Metadata key-value pairs. Usekeyparameter 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.nameparent_observation_idparse_io_as_json: Deprecated. Setting this totruewill return a 400 error. Input/output fields are always returned as raw strings. Remove this parameter or set it tofalse.to_start_time: Retrieve only observations with a start_time before this datetime (ISO 8601).trace_idtype_: Filter by observation type (e.g., “GENERATION”, “SPAN”, “EVENT”, “AGENT”, “TOOL”, “CHAIN”, “RETRIEVER”, “EVALUATOR”, “EMBEDDING”, “GUARDRAIL”)user_idversion: 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;Sourcepub fn prompts_list(&self) -> PromptsList<'_>
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)labellimit: limit of items per pagenamepage: page number, starts at 1tagto_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;Sourcepub fn prompts_create(&self) -> PromptsCreate<'_>
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;Sourcepub fn prompt_version_update(&self) -> PromptVersionUpdate<'_>
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 updatebody
let response = client.prompt_version_update()
.name(name)
.version(version)
.body(body)
.send()
.await;Sourcepub fn prompts_get(&self) -> PromptsGet<'_>
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;Sourcepub fn prompts_delete(&self) -> PromptsDelete<'_>
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 promptlabel: 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;Sourcepub fn score_v2_get(&self) -> ScoreV2Get<'_>
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;Sourcepub fn score_v2_get_by_id(&self) -> ScoreV2GetById<'_>
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;