@langfuse/core 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,5 +1,8 @@
1
- Copyright (c) 2023 Finto Technologies GmbH
1
+ MIT License
2
2
 
3
+ This repository is licensed under the MIT License. Portions of this codebase are derived from posthog/posthog-js-lite by PostHog, which is also licensed under the MIT License.
4
+
5
+ Copyright (c) 2023-2026 Langfuse GmbH
3
6
  Copyright (c) 2022 PostHog (part of Hiberly Inc)
4
7
 
5
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
package/dist/index.cjs CHANGED
@@ -52,6 +52,7 @@ __export(index_exports, {
52
52
  ObservationType: () => ObservationType,
53
53
  PricingTierOperator: () => PricingTierOperator,
54
54
  PromptType: () => PromptType,
55
+ ScoreConfigDataType: () => ScoreConfigDataType,
55
56
  ScoreDataType: () => ScoreDataType,
56
57
  ScoreSource: () => ScoreSource,
57
58
  ServiceUnavailableError: () => ServiceUnavailableError,
@@ -81,8 +82,10 @@ __export(index_exports, {
81
82
  logger: () => LoggerSingleton,
82
83
  media: () => media_exports,
83
84
  metrics: () => metrics_exports,
85
+ metricsV2: () => metricsV2_exports,
84
86
  models: () => models_exports,
85
87
  observations: () => observations_exports,
88
+ observationsV2: () => observationsV2_exports,
86
89
  opentelemetry: () => opentelemetry_exports,
87
90
  organizations: () => organizations_exports,
88
91
  projects: () => projects_exports,
@@ -297,6 +300,23 @@ var Logger = class {
297
300
  getLevel() {
298
301
  return this.config.level;
299
302
  }
303
+ /**
304
+ * Checks if a given log level is enabled.
305
+ * Use this to guard expensive operations (like JSON.stringify) before debug logging.
306
+ *
307
+ * @param level - The log level to check
308
+ * @returns True if the level is enabled, false otherwise
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * if (logger.isLevelEnabled(LogLevel.DEBUG)) {
313
+ * logger.debug('Expensive data:', JSON.stringify(largeObject));
314
+ * }
315
+ * ```
316
+ */
317
+ isLevelEnabled(level) {
318
+ return this.shouldLog(level);
319
+ }
300
320
  };
301
321
  var _a;
302
322
  var _LoggerSingleton = class _LoggerSingleton {
@@ -351,7 +371,7 @@ var resetGlobalLogger = () => {
351
371
  // package.json
352
372
  var package_default = {
353
373
  name: "@langfuse/core",
354
- version: "4.4.10",
374
+ version: "4.5.1",
355
375
  description: "Core functions and utilities for Langfuse packages",
356
376
  type: "module",
357
377
  sideEffects: false,
@@ -508,6 +528,7 @@ __export(commons_exports, {
508
528
  NotFoundError: () => NotFoundError,
509
529
  ObservationLevel: () => ObservationLevel,
510
530
  PricingTierOperator: () => PricingTierOperator,
531
+ ScoreConfigDataType: () => ScoreConfigDataType,
511
532
  ScoreDataType: () => ScoreDataType,
512
533
  ScoreSource: () => ScoreSource,
513
534
  UnauthorizedError: () => UnauthorizedError
@@ -562,11 +583,19 @@ var ScoreSource = {
562
583
  Eval: "EVAL"
563
584
  };
564
585
 
586
+ // src/api/api/resources/commons/types/ScoreConfigDataType.ts
587
+ var ScoreConfigDataType = {
588
+ Numeric: "NUMERIC",
589
+ Boolean: "BOOLEAN",
590
+ Categorical: "CATEGORICAL"
591
+ };
592
+
565
593
  // src/api/api/resources/commons/types/ScoreDataType.ts
566
594
  var ScoreDataType = {
567
595
  Numeric: "NUMERIC",
568
596
  Boolean: "BOOLEAN",
569
- Categorical: "CATEGORICAL"
597
+ Categorical: "CATEGORICAL",
598
+ Correction: "CORRECTION"
570
599
  };
571
600
 
572
601
  // src/api/core/json.ts
@@ -808,12 +837,18 @@ var MediaContentType = {
808
837
  ApplicationX7ZCompressed: "application/x-7z-compressed"
809
838
  };
810
839
 
840
+ // src/api/api/resources/metricsV2/index.ts
841
+ var metricsV2_exports = {};
842
+
811
843
  // src/api/api/resources/metrics/index.ts
812
844
  var metrics_exports = {};
813
845
 
814
846
  // src/api/api/resources/models/index.ts
815
847
  var models_exports = {};
816
848
 
849
+ // src/api/api/resources/observationsV2/index.ts
850
+ var observationsV2_exports = {};
851
+
817
852
  // src/api/api/resources/observations/index.ts
818
853
  var observations_exports = {};
819
854
 
@@ -3642,7 +3677,8 @@ var DatasetItems = class {
3642
3677
  }
3643
3678
  }
3644
3679
  /**
3645
- * Get dataset items
3680
+ * Get dataset items. Optionally specify a version to get the items as they existed at that point in time.
3681
+ * Note: If version parameter is provided, datasetName must also be provided.
3646
3682
  *
3647
3683
  * @param {LangfuseAPI.GetDatasetItemsRequest} request
3648
3684
  * @param {DatasetItems.RequestOptions} requestOptions - Request-specific configuration.
@@ -3663,7 +3699,14 @@ var DatasetItems = class {
3663
3699
  }
3664
3700
  async __list(request = {}, requestOptions) {
3665
3701
  var _a2, _b, _c, _d, _e, _f, _g, _h;
3666
- const { datasetName, sourceTraceId, sourceObservationId, page, limit } = request;
3702
+ const {
3703
+ datasetName,
3704
+ sourceTraceId,
3705
+ sourceObservationId,
3706
+ version,
3707
+ page,
3708
+ limit
3709
+ } = request;
3667
3710
  const _queryParams = {};
3668
3711
  if (datasetName != null) {
3669
3712
  _queryParams["datasetName"] = datasetName;
@@ -3674,6 +3717,9 @@ var DatasetItems = class {
3674
3717
  if (sourceObservationId != null) {
3675
3718
  _queryParams["sourceObservationId"] = sourceObservationId;
3676
3719
  }
3720
+ if (version != null) {
3721
+ _queryParams["version"] = version;
3722
+ }
3677
3723
  if (page != null) {
3678
3724
  _queryParams["page"] = page.toString();
3679
3725
  }
@@ -3901,7 +3947,8 @@ var DatasetRunItems = class {
3901
3947
  * metadata: undefined,
3902
3948
  * datasetItemId: "datasetItemId",
3903
3949
  * observationId: undefined,
3904
- * traceId: undefined
3950
+ * traceId: undefined,
3951
+ * datasetVersion: undefined
3905
3952
  * })
3906
3953
  */
3907
3954
  create(request, requestOptions) {
@@ -5686,6 +5733,232 @@ var Media = class {
5686
5733
  }
5687
5734
  };
5688
5735
 
5736
+ // src/api/api/resources/metricsV2/client/Client.ts
5737
+ var MetricsV2 = class {
5738
+ constructor(_options) {
5739
+ this._options = _options;
5740
+ }
5741
+ /**
5742
+ * Get metrics from the Langfuse project using a query object. V2 endpoint with optimized performance.
5743
+ *
5744
+ * ## V2 Differences
5745
+ * - Supports `observations`, `scores-numeric`, and `scores-categorical` views only (traces view not supported)
5746
+ * - Direct access to tags and release fields on observations
5747
+ * - Backwards-compatible: traceName, traceRelease, traceVersion dimensions are still available on observations view
5748
+ * - High cardinality dimensions are not supported and will return a 400 error (see below)
5749
+ *
5750
+ * For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
5751
+ *
5752
+ * ## Available Views
5753
+ *
5754
+ * ### observations
5755
+ * Query observation-level data (spans, generations, events).
5756
+ *
5757
+ * **Dimensions:**
5758
+ * - `environment` - Deployment environment (e.g., production, staging)
5759
+ * - `type` - Type of observation (SPAN, GENERATION, EVENT)
5760
+ * - `name` - Name of the observation
5761
+ * - `level` - Logging level of the observation
5762
+ * - `version` - Version of the observation
5763
+ * - `tags` - User-defined tags
5764
+ * - `release` - Release version
5765
+ * - `traceName` - Name of the parent trace (backwards-compatible)
5766
+ * - `traceRelease` - Release version of the parent trace (backwards-compatible, maps to release)
5767
+ * - `traceVersion` - Version of the parent trace (backwards-compatible, maps to version)
5768
+ * - `providedModelName` - Name of the model used
5769
+ * - `promptName` - Name of the prompt used
5770
+ * - `promptVersion` - Version of the prompt used
5771
+ * - `startTimeMonth` - Month of start_time in YYYY-MM format
5772
+ *
5773
+ * **Measures:**
5774
+ * - `count` - Total number of observations
5775
+ * - `latency` - Observation latency (milliseconds)
5776
+ * - `streamingLatency` - Generation latency from completion start to end (milliseconds)
5777
+ * - `inputTokens` - Sum of input tokens consumed
5778
+ * - `outputTokens` - Sum of output tokens produced
5779
+ * - `totalTokens` - Sum of all tokens consumed
5780
+ * - `outputTokensPerSecond` - Output tokens per second
5781
+ * - `tokensPerSecond` - Total tokens per second
5782
+ * - `inputCost` - Input cost (USD)
5783
+ * - `outputCost` - Output cost (USD)
5784
+ * - `totalCost` - Total cost (USD)
5785
+ * - `timeToFirstToken` - Time to first token (milliseconds)
5786
+ * - `countScores` - Number of scores attached to the observation
5787
+ *
5788
+ * ### scores-numeric
5789
+ * Query numeric and boolean score data.
5790
+ *
5791
+ * **Dimensions:**
5792
+ * - `environment` - Deployment environment
5793
+ * - `name` - Name of the score (e.g., accuracy, toxicity)
5794
+ * - `source` - Origin of the score (API, ANNOTATION, EVAL)
5795
+ * - `dataType` - Data type (NUMERIC, BOOLEAN)
5796
+ * - `configId` - Identifier of the score config
5797
+ * - `timestampMonth` - Month in YYYY-MM format
5798
+ * - `timestampDay` - Day in YYYY-MM-DD format
5799
+ * - `value` - Numeric value of the score
5800
+ * - `traceName` - Name of the parent trace
5801
+ * - `tags` - Tags
5802
+ * - `traceRelease` - Release version
5803
+ * - `traceVersion` - Version
5804
+ * - `observationName` - Name of the associated observation
5805
+ * - `observationModelName` - Model name of the associated observation
5806
+ * - `observationPromptName` - Prompt name of the associated observation
5807
+ * - `observationPromptVersion` - Prompt version of the associated observation
5808
+ *
5809
+ * **Measures:**
5810
+ * - `count` - Total number of scores
5811
+ * - `value` - Score value (for aggregations)
5812
+ *
5813
+ * ### scores-categorical
5814
+ * Query categorical score data. Same dimensions as scores-numeric except uses `stringValue` instead of `value`.
5815
+ *
5816
+ * **Measures:**
5817
+ * - `count` - Total number of scores
5818
+ *
5819
+ * ## High Cardinality Dimensions
5820
+ * The following dimensions cannot be used as grouping dimensions in v2 metrics API as they can cause performance issues.
5821
+ * Use them in filters instead.
5822
+ *
5823
+ * **observations view:**
5824
+ * - `id` - Use traceId filter to narrow down results
5825
+ * - `traceId` - Use traceId filter instead
5826
+ * - `userId` - Use userId filter instead
5827
+ * - `sessionId` - Use sessionId filter instead
5828
+ * - `parentObservationId` - Use parentObservationId filter instead
5829
+ *
5830
+ * **scores-numeric / scores-categorical views:**
5831
+ * - `id` - Use specific filters to narrow down results
5832
+ * - `traceId` - Use traceId filter instead
5833
+ * - `userId` - Use userId filter instead
5834
+ * - `sessionId` - Use sessionId filter instead
5835
+ * - `observationId` - Use observationId filter instead
5836
+ *
5837
+ * ## Aggregations
5838
+ * Available aggregation functions: `sum`, `avg`, `count`, `max`, `min`, `p50`, `p75`, `p90`, `p95`, `p99`, `histogram`
5839
+ *
5840
+ * ## Time Granularities
5841
+ * Available granularities for timeDimension: `auto`, `minute`, `hour`, `day`, `week`, `month`
5842
+ * - `auto` bins the data into approximately 50 buckets based on the time range
5843
+ *
5844
+ * @param {LangfuseAPI.GetMetricsV2Request} request
5845
+ * @param {MetricsV2.RequestOptions} requestOptions - Request-specific configuration.
5846
+ *
5847
+ * @throws {@link LangfuseAPI.Error}
5848
+ * @throws {@link LangfuseAPI.UnauthorizedError}
5849
+ * @throws {@link LangfuseAPI.AccessDeniedError}
5850
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
5851
+ * @throws {@link LangfuseAPI.NotFoundError}
5852
+ *
5853
+ * @example
5854
+ * await client.metricsV2.metrics({
5855
+ * query: "query"
5856
+ * })
5857
+ */
5858
+ metrics(request, requestOptions) {
5859
+ return HttpResponsePromise.fromPromise(
5860
+ this.__metrics(request, requestOptions)
5861
+ );
5862
+ }
5863
+ async __metrics(request, requestOptions) {
5864
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
5865
+ const { query } = request;
5866
+ const _queryParams = {};
5867
+ _queryParams["query"] = query;
5868
+ let _headers = mergeHeaders(
5869
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
5870
+ mergeOnlyDefinedHeaders({
5871
+ Authorization: await this._getAuthorizationHeader(),
5872
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
5873
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
5874
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
5875
+ }),
5876
+ requestOptions == null ? void 0 : requestOptions.headers
5877
+ );
5878
+ const _response = await fetcher({
5879
+ url: url_exports.join(
5880
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
5881
+ "/api/public/v2/metrics"
5882
+ ),
5883
+ method: "GET",
5884
+ headers: _headers,
5885
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
5886
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
5887
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
5888
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
5889
+ });
5890
+ if (_response.ok) {
5891
+ return {
5892
+ data: _response.body,
5893
+ rawResponse: _response.rawResponse
5894
+ };
5895
+ }
5896
+ if (_response.error.reason === "status-code") {
5897
+ switch (_response.error.statusCode) {
5898
+ case 400:
5899
+ throw new Error2(
5900
+ _response.error.body,
5901
+ _response.rawResponse
5902
+ );
5903
+ case 401:
5904
+ throw new UnauthorizedError(
5905
+ _response.error.body,
5906
+ _response.rawResponse
5907
+ );
5908
+ case 403:
5909
+ throw new AccessDeniedError(
5910
+ _response.error.body,
5911
+ _response.rawResponse
5912
+ );
5913
+ case 405:
5914
+ throw new MethodNotAllowedError(
5915
+ _response.error.body,
5916
+ _response.rawResponse
5917
+ );
5918
+ case 404:
5919
+ throw new NotFoundError(
5920
+ _response.error.body,
5921
+ _response.rawResponse
5922
+ );
5923
+ default:
5924
+ throw new LangfuseAPIError({
5925
+ statusCode: _response.error.statusCode,
5926
+ body: _response.error.body,
5927
+ rawResponse: _response.rawResponse
5928
+ });
5929
+ }
5930
+ }
5931
+ switch (_response.error.reason) {
5932
+ case "non-json":
5933
+ throw new LangfuseAPIError({
5934
+ statusCode: _response.error.statusCode,
5935
+ body: _response.error.rawBody,
5936
+ rawResponse: _response.rawResponse
5937
+ });
5938
+ case "timeout":
5939
+ throw new LangfuseAPITimeoutError(
5940
+ "Timeout exceeded when calling GET /api/public/v2/metrics."
5941
+ );
5942
+ case "unknown":
5943
+ throw new LangfuseAPIError({
5944
+ message: _response.error.errorMessage,
5945
+ rawResponse: _response.rawResponse
5946
+ });
5947
+ }
5948
+ }
5949
+ async _getAuthorizationHeader() {
5950
+ const username = await Supplier.get(this._options.username);
5951
+ const password = await Supplier.get(this._options.password);
5952
+ if (username != null && password != null) {
5953
+ return BasicAuth.toAuthorizationHeader({
5954
+ username,
5955
+ password
5956
+ });
5957
+ }
5958
+ return void 0;
5959
+ }
5960
+ };
5961
+
5689
5962
  // src/api/api/resources/metrics/client/Client.ts
5690
5963
  var Metrics = class {
5691
5964
  constructor(_options) {
@@ -5694,6 +5967,8 @@ var Metrics = class {
5694
5967
  /**
5695
5968
  * Get metrics from the Langfuse project using a query object.
5696
5969
  *
5970
+ * Consider using the [v2 metrics endpoint](/api-reference#tag/metricsv2/GET/api/public/v2/metrics) for better performance.
5971
+ *
5697
5972
  * For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
5698
5973
  *
5699
5974
  * @param {LangfuseAPI.GetMetricsRequest} request
@@ -6261,6 +6536,221 @@ var Models = class {
6261
6536
  }
6262
6537
  };
6263
6538
 
6539
+ // src/api/api/resources/observationsV2/client/Client.ts
6540
+ var ObservationsV2 = class {
6541
+ constructor(_options) {
6542
+ this._options = _options;
6543
+ }
6544
+ /**
6545
+ * Get a list of observations with cursor-based pagination and flexible field selection.
6546
+ *
6547
+ * ## Cursor-based Pagination
6548
+ * This endpoint uses cursor-based pagination for efficient traversal of large datasets.
6549
+ * The cursor is returned in the response metadata and should be passed in subsequent requests
6550
+ * to retrieve the next page of results.
6551
+ *
6552
+ * ## Field Selection
6553
+ * Use the `fields` parameter to control which observation fields are returned:
6554
+ * - `core` - Always included: id, traceId, startTime, endTime, projectId, parentObservationId, type
6555
+ * - `basic` - name, level, statusMessage, version, environment, bookmarked, public, userId, sessionId
6556
+ * - `time` - completionStartTime, createdAt, updatedAt
6557
+ * - `io` - input, output
6558
+ * - `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
6559
+ * - `model` - providedModelName, internalModelId, modelParameters
6560
+ * - `usage` - usageDetails, costDetails, totalCost
6561
+ * - `prompt` - promptId, promptName, promptVersion
6562
+ * - `metrics` - latency, timeToFirstToken
6563
+ *
6564
+ * If not specified, `core` and `basic` field groups are returned.
6565
+ *
6566
+ * ## Filters
6567
+ * Multiple filtering options are available via query parameters or the structured `filter` parameter.
6568
+ * When using the `filter` parameter, it takes precedence over individual query parameter filters.
6569
+ *
6570
+ * @param {LangfuseAPI.GetObservationsV2Request} request
6571
+ * @param {ObservationsV2.RequestOptions} requestOptions - Request-specific configuration.
6572
+ *
6573
+ * @throws {@link LangfuseAPI.Error}
6574
+ * @throws {@link LangfuseAPI.UnauthorizedError}
6575
+ * @throws {@link LangfuseAPI.AccessDeniedError}
6576
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
6577
+ * @throws {@link LangfuseAPI.NotFoundError}
6578
+ *
6579
+ * @example
6580
+ * await client.observationsV2.getMany()
6581
+ */
6582
+ getMany(request = {}, requestOptions) {
6583
+ return HttpResponsePromise.fromPromise(
6584
+ this.__getMany(request, requestOptions)
6585
+ );
6586
+ }
6587
+ async __getMany(request = {}, requestOptions) {
6588
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
6589
+ const {
6590
+ fields,
6591
+ expandMetadata,
6592
+ limit,
6593
+ cursor,
6594
+ parseIoAsJson,
6595
+ name,
6596
+ userId,
6597
+ type: type_,
6598
+ traceId,
6599
+ level,
6600
+ parentObservationId,
6601
+ environment,
6602
+ fromStartTime,
6603
+ toStartTime,
6604
+ version,
6605
+ filter
6606
+ } = request;
6607
+ const _queryParams = {};
6608
+ if (fields != null) {
6609
+ _queryParams["fields"] = fields;
6610
+ }
6611
+ if (expandMetadata != null) {
6612
+ _queryParams["expandMetadata"] = expandMetadata;
6613
+ }
6614
+ if (limit != null) {
6615
+ _queryParams["limit"] = limit.toString();
6616
+ }
6617
+ if (cursor != null) {
6618
+ _queryParams["cursor"] = cursor;
6619
+ }
6620
+ if (parseIoAsJson != null) {
6621
+ _queryParams["parseIoAsJson"] = parseIoAsJson.toString();
6622
+ }
6623
+ if (name != null) {
6624
+ _queryParams["name"] = name;
6625
+ }
6626
+ if (userId != null) {
6627
+ _queryParams["userId"] = userId;
6628
+ }
6629
+ if (type_ != null) {
6630
+ _queryParams["type"] = type_;
6631
+ }
6632
+ if (traceId != null) {
6633
+ _queryParams["traceId"] = traceId;
6634
+ }
6635
+ if (level != null) {
6636
+ _queryParams["level"] = level;
6637
+ }
6638
+ if (parentObservationId != null) {
6639
+ _queryParams["parentObservationId"] = parentObservationId;
6640
+ }
6641
+ if (environment != null) {
6642
+ if (Array.isArray(environment)) {
6643
+ _queryParams["environment"] = environment.map((item) => item);
6644
+ } else {
6645
+ _queryParams["environment"] = environment;
6646
+ }
6647
+ }
6648
+ if (fromStartTime != null) {
6649
+ _queryParams["fromStartTime"] = fromStartTime;
6650
+ }
6651
+ if (toStartTime != null) {
6652
+ _queryParams["toStartTime"] = toStartTime;
6653
+ }
6654
+ if (version != null) {
6655
+ _queryParams["version"] = version;
6656
+ }
6657
+ if (filter != null) {
6658
+ _queryParams["filter"] = filter;
6659
+ }
6660
+ let _headers = mergeHeaders(
6661
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
6662
+ mergeOnlyDefinedHeaders({
6663
+ Authorization: await this._getAuthorizationHeader(),
6664
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
6665
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
6666
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
6667
+ }),
6668
+ requestOptions == null ? void 0 : requestOptions.headers
6669
+ );
6670
+ const _response = await fetcher({
6671
+ url: url_exports.join(
6672
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
6673
+ "/api/public/v2/observations"
6674
+ ),
6675
+ method: "GET",
6676
+ headers: _headers,
6677
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
6678
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
6679
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
6680
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
6681
+ });
6682
+ if (_response.ok) {
6683
+ return {
6684
+ data: _response.body,
6685
+ rawResponse: _response.rawResponse
6686
+ };
6687
+ }
6688
+ if (_response.error.reason === "status-code") {
6689
+ switch (_response.error.statusCode) {
6690
+ case 400:
6691
+ throw new Error2(
6692
+ _response.error.body,
6693
+ _response.rawResponse
6694
+ );
6695
+ case 401:
6696
+ throw new UnauthorizedError(
6697
+ _response.error.body,
6698
+ _response.rawResponse
6699
+ );
6700
+ case 403:
6701
+ throw new AccessDeniedError(
6702
+ _response.error.body,
6703
+ _response.rawResponse
6704
+ );
6705
+ case 405:
6706
+ throw new MethodNotAllowedError(
6707
+ _response.error.body,
6708
+ _response.rawResponse
6709
+ );
6710
+ case 404:
6711
+ throw new NotFoundError(
6712
+ _response.error.body,
6713
+ _response.rawResponse
6714
+ );
6715
+ default:
6716
+ throw new LangfuseAPIError({
6717
+ statusCode: _response.error.statusCode,
6718
+ body: _response.error.body,
6719
+ rawResponse: _response.rawResponse
6720
+ });
6721
+ }
6722
+ }
6723
+ switch (_response.error.reason) {
6724
+ case "non-json":
6725
+ throw new LangfuseAPIError({
6726
+ statusCode: _response.error.statusCode,
6727
+ body: _response.error.rawBody,
6728
+ rawResponse: _response.rawResponse
6729
+ });
6730
+ case "timeout":
6731
+ throw new LangfuseAPITimeoutError(
6732
+ "Timeout exceeded when calling GET /api/public/v2/observations."
6733
+ );
6734
+ case "unknown":
6735
+ throw new LangfuseAPIError({
6736
+ message: _response.error.errorMessage,
6737
+ rawResponse: _response.rawResponse
6738
+ });
6739
+ }
6740
+ }
6741
+ async _getAuthorizationHeader() {
6742
+ const username = await Supplier.get(this._options.username);
6743
+ const password = await Supplier.get(this._options.password);
6744
+ if (username != null && password != null) {
6745
+ return BasicAuth.toAuthorizationHeader({
6746
+ username,
6747
+ password
6748
+ });
6749
+ }
6750
+ return void 0;
6751
+ }
6752
+ };
6753
+
6264
6754
  // src/api/api/resources/observations/client/Client.ts
6265
6755
  var Observations = class {
6266
6756
  constructor(_options) {
@@ -6370,7 +6860,9 @@ var Observations = class {
6370
6860
  }
6371
6861
  }
6372
6862
  /**
6373
- * Get a list of observations
6863
+ * Get a list of observations.
6864
+ *
6865
+ * Consider using the [v2 observations endpoint](/api-reference#tag/observationsv2/GET/api/public/v2/observations) for cursor-based pagination and field selection.
6374
6866
  *
6375
6867
  * @param {LangfuseAPI.GetObservationsRequest} request
6376
6868
  * @param {Observations.RequestOptions} requestOptions - Request-specific configuration.
@@ -7815,7 +8307,7 @@ var Projects = class {
7815
8307
  * await client.projects.update("projectId", {
7816
8308
  * name: "name",
7817
8309
  * metadata: undefined,
7818
- * retention: 1
8310
+ * retention: undefined
7819
8311
  * })
7820
8312
  */
7821
8313
  update(projectId, request, requestOptions) {
@@ -10222,7 +10714,8 @@ var ScoreV2 = class {
10222
10714
  traceId,
10223
10715
  queueId,
10224
10716
  dataType,
10225
- traceTags
10717
+ traceTags,
10718
+ fields
10226
10719
  } = request;
10227
10720
  const _queryParams = {};
10228
10721
  if (page != null) {
@@ -10287,6 +10780,9 @@ var ScoreV2 = class {
10287
10780
  _queryParams["traceTags"] = traceTags;
10288
10781
  }
10289
10782
  }
10783
+ if (fields != null) {
10784
+ _queryParams["fields"] = fields;
10785
+ }
10290
10786
  let _headers = mergeHeaders(
10291
10787
  (_a2 = this._options) == null ? void 0 : _a2.headers,
10292
10788
  mergeOnlyDefinedHeaders({
@@ -11526,6 +12022,10 @@ var LangfuseAPIClient = class {
11526
12022
  var _a2;
11527
12023
  return (_a2 = this._media) != null ? _a2 : this._media = new Media(this._options);
11528
12024
  }
12025
+ get metricsV2() {
12026
+ var _a2;
12027
+ return (_a2 = this._metricsV2) != null ? _a2 : this._metricsV2 = new MetricsV2(this._options);
12028
+ }
11529
12029
  get metrics() {
11530
12030
  var _a2;
11531
12031
  return (_a2 = this._metrics) != null ? _a2 : this._metrics = new Metrics(this._options);
@@ -11534,6 +12034,10 @@ var LangfuseAPIClient = class {
11534
12034
  var _a2;
11535
12035
  return (_a2 = this._models) != null ? _a2 : this._models = new Models(this._options);
11536
12036
  }
12037
+ get observationsV2() {
12038
+ var _a2;
12039
+ return (_a2 = this._observationsV2) != null ? _a2 : this._observationsV2 = new ObservationsV2(this._options);
12040
+ }
11537
12041
  get observations() {
11538
12042
  var _a2;
11539
12043
  return (_a2 = this._observations) != null ? _a2 : this._observations = new Observations(this._options);
@@ -12176,6 +12680,7 @@ function getSpanKeyFromBaggageKey(baggageKey) {
12176
12680
  ObservationType,
12177
12681
  PricingTierOperator,
12178
12682
  PromptType,
12683
+ ScoreConfigDataType,
12179
12684
  ScoreDataType,
12180
12685
  ScoreSource,
12181
12686
  ServiceUnavailableError,
@@ -12205,8 +12710,10 @@ function getSpanKeyFromBaggageKey(baggageKey) {
12205
12710
  logger,
12206
12711
  media,
12207
12712
  metrics,
12713
+ metricsV2,
12208
12714
  models,
12209
12715
  observations,
12716
+ observationsV2,
12210
12717
  opentelemetry,
12211
12718
  organizations,
12212
12719
  projects,