Skip to main content

langfuse_client_base/apis/
dataset_run_items_api.rs

1/*
2 * server
3 *
4 * ## Real-time data  The only real-time path to get tracing data is to ingest via OpenTelemetry (`POST /api/public/otel/v1/traces`) and retrieve via Observations API v2 (`GET /api/public/v2/observations`) and Metrics API v2 (`GET /api/public/v2/metrics`). Other public API write and read endpoints can delay data by about 10 minutes. Direct OpenTelemetry exporters must send the `x-langfuse-ingestion-version: 4` header; current Python and JS SDKs already do. See the [Public API docs](https://langfuse.com/docs/api-and-data-platform/features/public-api) and [real-time ingestion](https://langfuse.com/integrations/native/opentelemetry.md#real-time-ingestion).  ## Authentication  Authenticate with the API using [Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication), 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 - Self-hosted deployments: interactive API reference at `/api/docs` and OpenAPI spec at `/api/openapi.yaml`
5 *
6 * The version of the OpenAPI document:
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for typed errors of method [`dataset_run_items_create`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum DatasetRunItemsCreateError {
20    Status400(serde_json::Value),
21    Status401(serde_json::Value),
22    Status403(serde_json::Value),
23    Status404(serde_json::Value),
24    Status405(serde_json::Value),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`dataset_run_items_list`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum DatasetRunItemsListError {
32    Status400(serde_json::Value),
33    Status401(serde_json::Value),
34    Status403(serde_json::Value),
35    Status404(serde_json::Value),
36    Status405(serde_json::Value),
37    UnknownValue(serde_json::Value),
38}
39
40/// **Deprecated:** On Langfuse Cloud, Langfuse v3 is deprecated and this endpoint will be removed on November 16, 2026. In Langfuse v4, create experiment data via the SDK experiment runner or the OpenTelemetry endpoint at POST /api/public/otel/v1/traces. Self-hosted deployments are unaffected by this date; the endpoint becomes unavailable when they upgrade to Langfuse v4. See the [Langfuse v3 to v4 upgrade guide](https://langfuse.com/self-hosting/upgrade/upgrade-guides/upgrade-v3-to-v4).  Create a dataset run item
41#[deprecated]
42#[bon::builder]
43pub async fn dataset_run_items_create(
44    configuration: &configuration::Configuration,
45    create_dataset_run_item_request: models::CreateDatasetRunItemRequest,
46) -> Result<models::DatasetRunItem, Error<DatasetRunItemsCreateError>> {
47    // add a prefix to parameters to efficiently prevent name collisions
48    let p_body_create_dataset_run_item_request = create_dataset_run_item_request;
49
50    let uri_str = format!("{}/api/public/dataset-run-items", configuration.base_path);
51    let mut req_builder = configuration
52        .client
53        .request(reqwest::Method::POST, &uri_str);
54
55    if let Some(ref user_agent) = configuration.user_agent {
56        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
57    }
58    if let Some(ref auth_conf) = configuration.basic_auth {
59        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
60    };
61    req_builder = req_builder.json(&p_body_create_dataset_run_item_request);
62
63    let req = req_builder.build()?;
64    let resp = configuration.client.execute(req).await?;
65
66    let status = resp.status();
67    let content_type = resp
68        .headers()
69        .get("content-type")
70        .and_then(|v| v.to_str().ok())
71        .unwrap_or("application/octet-stream");
72    let content_type = super::ContentType::from(content_type);
73
74    if !status.is_client_error() && !status.is_server_error() {
75        let content = resp.text().await?;
76        match content_type {
77            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
78            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DatasetRunItem`"))),
79            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DatasetRunItem`")))),
80        }
81    } else {
82        let content = resp.text().await?;
83        let entity: Option<DatasetRunItemsCreateError> = serde_json::from_str(&content).ok();
84        Err(Error::ResponseError(ResponseContent {
85            status,
86            content,
87            entity,
88        }))
89    }
90}
91
92/// **Deprecated:** On Langfuse Cloud, Langfuse v3 is deprecated and this endpoint will be removed on November 16, 2026. In Langfuse v4, dataset run items are replaced by experiment items; use `GET /api/public/experiment-items?fromStartTime=<from>&toStartTime=<to>` instead. Self-hosted deployments are unaffected by this date; the endpoint becomes unavailable when they upgrade to Langfuse v4. See the [Langfuse v3 to v4 upgrade guide](https://langfuse.com/self-hosting/upgrade/upgrade-guides/upgrade-v3-to-v4).  List dataset run items
93#[deprecated]
94#[bon::builder]
95pub async fn dataset_run_items_list(
96    configuration: &configuration::Configuration,
97    dataset_id: &str,
98    run_name: &str,
99    page: Option<i32>,
100    limit: Option<i32>,
101) -> Result<models::PaginatedDatasetRunItems, Error<DatasetRunItemsListError>> {
102    // add a prefix to parameters to efficiently prevent name collisions
103    let p_query_dataset_id = dataset_id;
104    let p_query_run_name = run_name;
105    let p_query_page = page;
106    let p_query_limit = limit;
107
108    let uri_str = format!("{}/api/public/dataset-run-items", configuration.base_path);
109    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
110
111    req_builder = req_builder.query(&[("datasetId", &p_query_dataset_id.to_string())]);
112    req_builder = req_builder.query(&[("runName", &p_query_run_name.to_string())]);
113    if let Some(ref param_value) = p_query_page {
114        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
115    }
116    if let Some(ref param_value) = p_query_limit {
117        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
118    }
119    if let Some(ref user_agent) = configuration.user_agent {
120        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
121    }
122    if let Some(ref auth_conf) = configuration.basic_auth {
123        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
124    };
125
126    let req = req_builder.build()?;
127    let resp = configuration.client.execute(req).await?;
128
129    let status = resp.status();
130    let content_type = resp
131        .headers()
132        .get("content-type")
133        .and_then(|v| v.to_str().ok())
134        .unwrap_or("application/octet-stream");
135    let content_type = super::ContentType::from(content_type);
136
137    if !status.is_client_error() && !status.is_server_error() {
138        let content = resp.text().await?;
139        match content_type {
140            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
141            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedDatasetRunItems`"))),
142            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaginatedDatasetRunItems`")))),
143        }
144    } else {
145        let content = resp.text().await?;
146        let entity: Option<DatasetRunItemsListError> = serde_json::from_str(&content).ok();
147        Err(Error::ResponseError(ResponseContent {
148            status,
149            content,
150            entity,
151        }))
152    }
153}