@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/dist/index.mjs CHANGED
@@ -199,6 +199,23 @@ var Logger = class {
199
199
  getLevel() {
200
200
  return this.config.level;
201
201
  }
202
+ /**
203
+ * Checks if a given log level is enabled.
204
+ * Use this to guard expensive operations (like JSON.stringify) before debug logging.
205
+ *
206
+ * @param level - The log level to check
207
+ * @returns True if the level is enabled, false otherwise
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * if (logger.isLevelEnabled(LogLevel.DEBUG)) {
212
+ * logger.debug('Expensive data:', JSON.stringify(largeObject));
213
+ * }
214
+ * ```
215
+ */
216
+ isLevelEnabled(level) {
217
+ return this.shouldLog(level);
218
+ }
202
219
  };
203
220
  var _a;
204
221
  var _LoggerSingleton = class _LoggerSingleton {
@@ -253,7 +270,7 @@ var resetGlobalLogger = () => {
253
270
  // package.json
254
271
  var package_default = {
255
272
  name: "@langfuse/core",
256
- version: "4.4.10",
273
+ version: "4.5.1",
257
274
  description: "Core functions and utilities for Langfuse packages",
258
275
  type: "module",
259
276
  sideEffects: false,
@@ -410,6 +427,7 @@ __export(commons_exports, {
410
427
  NotFoundError: () => NotFoundError,
411
428
  ObservationLevel: () => ObservationLevel,
412
429
  PricingTierOperator: () => PricingTierOperator,
430
+ ScoreConfigDataType: () => ScoreConfigDataType,
413
431
  ScoreDataType: () => ScoreDataType,
414
432
  ScoreSource: () => ScoreSource,
415
433
  UnauthorizedError: () => UnauthorizedError
@@ -464,11 +482,19 @@ var ScoreSource = {
464
482
  Eval: "EVAL"
465
483
  };
466
484
 
485
+ // src/api/api/resources/commons/types/ScoreConfigDataType.ts
486
+ var ScoreConfigDataType = {
487
+ Numeric: "NUMERIC",
488
+ Boolean: "BOOLEAN",
489
+ Categorical: "CATEGORICAL"
490
+ };
491
+
467
492
  // src/api/api/resources/commons/types/ScoreDataType.ts
468
493
  var ScoreDataType = {
469
494
  Numeric: "NUMERIC",
470
495
  Boolean: "BOOLEAN",
471
- Categorical: "CATEGORICAL"
496
+ Categorical: "CATEGORICAL",
497
+ Correction: "CORRECTION"
472
498
  };
473
499
 
474
500
  // src/api/core/json.ts
@@ -710,12 +736,18 @@ var MediaContentType = {
710
736
  ApplicationX7ZCompressed: "application/x-7z-compressed"
711
737
  };
712
738
 
739
+ // src/api/api/resources/metricsV2/index.ts
740
+ var metricsV2_exports = {};
741
+
713
742
  // src/api/api/resources/metrics/index.ts
714
743
  var metrics_exports = {};
715
744
 
716
745
  // src/api/api/resources/models/index.ts
717
746
  var models_exports = {};
718
747
 
748
+ // src/api/api/resources/observationsV2/index.ts
749
+ var observationsV2_exports = {};
750
+
719
751
  // src/api/api/resources/observations/index.ts
720
752
  var observations_exports = {};
721
753
 
@@ -3544,7 +3576,8 @@ var DatasetItems = class {
3544
3576
  }
3545
3577
  }
3546
3578
  /**
3547
- * Get dataset items
3579
+ * Get dataset items. Optionally specify a version to get the items as they existed at that point in time.
3580
+ * Note: If version parameter is provided, datasetName must also be provided.
3548
3581
  *
3549
3582
  * @param {LangfuseAPI.GetDatasetItemsRequest} request
3550
3583
  * @param {DatasetItems.RequestOptions} requestOptions - Request-specific configuration.
@@ -3565,7 +3598,14 @@ var DatasetItems = class {
3565
3598
  }
3566
3599
  async __list(request = {}, requestOptions) {
3567
3600
  var _a2, _b, _c, _d, _e, _f, _g, _h;
3568
- const { datasetName, sourceTraceId, sourceObservationId, page, limit } = request;
3601
+ const {
3602
+ datasetName,
3603
+ sourceTraceId,
3604
+ sourceObservationId,
3605
+ version,
3606
+ page,
3607
+ limit
3608
+ } = request;
3569
3609
  const _queryParams = {};
3570
3610
  if (datasetName != null) {
3571
3611
  _queryParams["datasetName"] = datasetName;
@@ -3576,6 +3616,9 @@ var DatasetItems = class {
3576
3616
  if (sourceObservationId != null) {
3577
3617
  _queryParams["sourceObservationId"] = sourceObservationId;
3578
3618
  }
3619
+ if (version != null) {
3620
+ _queryParams["version"] = version;
3621
+ }
3579
3622
  if (page != null) {
3580
3623
  _queryParams["page"] = page.toString();
3581
3624
  }
@@ -3803,7 +3846,8 @@ var DatasetRunItems = class {
3803
3846
  * metadata: undefined,
3804
3847
  * datasetItemId: "datasetItemId",
3805
3848
  * observationId: undefined,
3806
- * traceId: undefined
3849
+ * traceId: undefined,
3850
+ * datasetVersion: undefined
3807
3851
  * })
3808
3852
  */
3809
3853
  create(request, requestOptions) {
@@ -5588,6 +5632,232 @@ var Media = class {
5588
5632
  }
5589
5633
  };
5590
5634
 
5635
+ // src/api/api/resources/metricsV2/client/Client.ts
5636
+ var MetricsV2 = class {
5637
+ constructor(_options) {
5638
+ this._options = _options;
5639
+ }
5640
+ /**
5641
+ * Get metrics from the Langfuse project using a query object. V2 endpoint with optimized performance.
5642
+ *
5643
+ * ## V2 Differences
5644
+ * - Supports `observations`, `scores-numeric`, and `scores-categorical` views only (traces view not supported)
5645
+ * - Direct access to tags and release fields on observations
5646
+ * - Backwards-compatible: traceName, traceRelease, traceVersion dimensions are still available on observations view
5647
+ * - High cardinality dimensions are not supported and will return a 400 error (see below)
5648
+ *
5649
+ * For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
5650
+ *
5651
+ * ## Available Views
5652
+ *
5653
+ * ### observations
5654
+ * Query observation-level data (spans, generations, events).
5655
+ *
5656
+ * **Dimensions:**
5657
+ * - `environment` - Deployment environment (e.g., production, staging)
5658
+ * - `type` - Type of observation (SPAN, GENERATION, EVENT)
5659
+ * - `name` - Name of the observation
5660
+ * - `level` - Logging level of the observation
5661
+ * - `version` - Version of the observation
5662
+ * - `tags` - User-defined tags
5663
+ * - `release` - Release version
5664
+ * - `traceName` - Name of the parent trace (backwards-compatible)
5665
+ * - `traceRelease` - Release version of the parent trace (backwards-compatible, maps to release)
5666
+ * - `traceVersion` - Version of the parent trace (backwards-compatible, maps to version)
5667
+ * - `providedModelName` - Name of the model used
5668
+ * - `promptName` - Name of the prompt used
5669
+ * - `promptVersion` - Version of the prompt used
5670
+ * - `startTimeMonth` - Month of start_time in YYYY-MM format
5671
+ *
5672
+ * **Measures:**
5673
+ * - `count` - Total number of observations
5674
+ * - `latency` - Observation latency (milliseconds)
5675
+ * - `streamingLatency` - Generation latency from completion start to end (milliseconds)
5676
+ * - `inputTokens` - Sum of input tokens consumed
5677
+ * - `outputTokens` - Sum of output tokens produced
5678
+ * - `totalTokens` - Sum of all tokens consumed
5679
+ * - `outputTokensPerSecond` - Output tokens per second
5680
+ * - `tokensPerSecond` - Total tokens per second
5681
+ * - `inputCost` - Input cost (USD)
5682
+ * - `outputCost` - Output cost (USD)
5683
+ * - `totalCost` - Total cost (USD)
5684
+ * - `timeToFirstToken` - Time to first token (milliseconds)
5685
+ * - `countScores` - Number of scores attached to the observation
5686
+ *
5687
+ * ### scores-numeric
5688
+ * Query numeric and boolean score data.
5689
+ *
5690
+ * **Dimensions:**
5691
+ * - `environment` - Deployment environment
5692
+ * - `name` - Name of the score (e.g., accuracy, toxicity)
5693
+ * - `source` - Origin of the score (API, ANNOTATION, EVAL)
5694
+ * - `dataType` - Data type (NUMERIC, BOOLEAN)
5695
+ * - `configId` - Identifier of the score config
5696
+ * - `timestampMonth` - Month in YYYY-MM format
5697
+ * - `timestampDay` - Day in YYYY-MM-DD format
5698
+ * - `value` - Numeric value of the score
5699
+ * - `traceName` - Name of the parent trace
5700
+ * - `tags` - Tags
5701
+ * - `traceRelease` - Release version
5702
+ * - `traceVersion` - Version
5703
+ * - `observationName` - Name of the associated observation
5704
+ * - `observationModelName` - Model name of the associated observation
5705
+ * - `observationPromptName` - Prompt name of the associated observation
5706
+ * - `observationPromptVersion` - Prompt version of the associated observation
5707
+ *
5708
+ * **Measures:**
5709
+ * - `count` - Total number of scores
5710
+ * - `value` - Score value (for aggregations)
5711
+ *
5712
+ * ### scores-categorical
5713
+ * Query categorical score data. Same dimensions as scores-numeric except uses `stringValue` instead of `value`.
5714
+ *
5715
+ * **Measures:**
5716
+ * - `count` - Total number of scores
5717
+ *
5718
+ * ## High Cardinality Dimensions
5719
+ * The following dimensions cannot be used as grouping dimensions in v2 metrics API as they can cause performance issues.
5720
+ * Use them in filters instead.
5721
+ *
5722
+ * **observations view:**
5723
+ * - `id` - Use traceId filter to narrow down results
5724
+ * - `traceId` - Use traceId filter instead
5725
+ * - `userId` - Use userId filter instead
5726
+ * - `sessionId` - Use sessionId filter instead
5727
+ * - `parentObservationId` - Use parentObservationId filter instead
5728
+ *
5729
+ * **scores-numeric / scores-categorical views:**
5730
+ * - `id` - Use specific filters to narrow down results
5731
+ * - `traceId` - Use traceId filter instead
5732
+ * - `userId` - Use userId filter instead
5733
+ * - `sessionId` - Use sessionId filter instead
5734
+ * - `observationId` - Use observationId filter instead
5735
+ *
5736
+ * ## Aggregations
5737
+ * Available aggregation functions: `sum`, `avg`, `count`, `max`, `min`, `p50`, `p75`, `p90`, `p95`, `p99`, `histogram`
5738
+ *
5739
+ * ## Time Granularities
5740
+ * Available granularities for timeDimension: `auto`, `minute`, `hour`, `day`, `week`, `month`
5741
+ * - `auto` bins the data into approximately 50 buckets based on the time range
5742
+ *
5743
+ * @param {LangfuseAPI.GetMetricsV2Request} request
5744
+ * @param {MetricsV2.RequestOptions} requestOptions - Request-specific configuration.
5745
+ *
5746
+ * @throws {@link LangfuseAPI.Error}
5747
+ * @throws {@link LangfuseAPI.UnauthorizedError}
5748
+ * @throws {@link LangfuseAPI.AccessDeniedError}
5749
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
5750
+ * @throws {@link LangfuseAPI.NotFoundError}
5751
+ *
5752
+ * @example
5753
+ * await client.metricsV2.metrics({
5754
+ * query: "query"
5755
+ * })
5756
+ */
5757
+ metrics(request, requestOptions) {
5758
+ return HttpResponsePromise.fromPromise(
5759
+ this.__metrics(request, requestOptions)
5760
+ );
5761
+ }
5762
+ async __metrics(request, requestOptions) {
5763
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
5764
+ const { query } = request;
5765
+ const _queryParams = {};
5766
+ _queryParams["query"] = query;
5767
+ let _headers = mergeHeaders(
5768
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
5769
+ mergeOnlyDefinedHeaders({
5770
+ Authorization: await this._getAuthorizationHeader(),
5771
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
5772
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
5773
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
5774
+ }),
5775
+ requestOptions == null ? void 0 : requestOptions.headers
5776
+ );
5777
+ const _response = await fetcher({
5778
+ url: url_exports.join(
5779
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
5780
+ "/api/public/v2/metrics"
5781
+ ),
5782
+ method: "GET",
5783
+ headers: _headers,
5784
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
5785
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
5786
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
5787
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
5788
+ });
5789
+ if (_response.ok) {
5790
+ return {
5791
+ data: _response.body,
5792
+ rawResponse: _response.rawResponse
5793
+ };
5794
+ }
5795
+ if (_response.error.reason === "status-code") {
5796
+ switch (_response.error.statusCode) {
5797
+ case 400:
5798
+ throw new Error2(
5799
+ _response.error.body,
5800
+ _response.rawResponse
5801
+ );
5802
+ case 401:
5803
+ throw new UnauthorizedError(
5804
+ _response.error.body,
5805
+ _response.rawResponse
5806
+ );
5807
+ case 403:
5808
+ throw new AccessDeniedError(
5809
+ _response.error.body,
5810
+ _response.rawResponse
5811
+ );
5812
+ case 405:
5813
+ throw new MethodNotAllowedError(
5814
+ _response.error.body,
5815
+ _response.rawResponse
5816
+ );
5817
+ case 404:
5818
+ throw new NotFoundError(
5819
+ _response.error.body,
5820
+ _response.rawResponse
5821
+ );
5822
+ default:
5823
+ throw new LangfuseAPIError({
5824
+ statusCode: _response.error.statusCode,
5825
+ body: _response.error.body,
5826
+ rawResponse: _response.rawResponse
5827
+ });
5828
+ }
5829
+ }
5830
+ switch (_response.error.reason) {
5831
+ case "non-json":
5832
+ throw new LangfuseAPIError({
5833
+ statusCode: _response.error.statusCode,
5834
+ body: _response.error.rawBody,
5835
+ rawResponse: _response.rawResponse
5836
+ });
5837
+ case "timeout":
5838
+ throw new LangfuseAPITimeoutError(
5839
+ "Timeout exceeded when calling GET /api/public/v2/metrics."
5840
+ );
5841
+ case "unknown":
5842
+ throw new LangfuseAPIError({
5843
+ message: _response.error.errorMessage,
5844
+ rawResponse: _response.rawResponse
5845
+ });
5846
+ }
5847
+ }
5848
+ async _getAuthorizationHeader() {
5849
+ const username = await Supplier.get(this._options.username);
5850
+ const password = await Supplier.get(this._options.password);
5851
+ if (username != null && password != null) {
5852
+ return BasicAuth.toAuthorizationHeader({
5853
+ username,
5854
+ password
5855
+ });
5856
+ }
5857
+ return void 0;
5858
+ }
5859
+ };
5860
+
5591
5861
  // src/api/api/resources/metrics/client/Client.ts
5592
5862
  var Metrics = class {
5593
5863
  constructor(_options) {
@@ -5596,6 +5866,8 @@ var Metrics = class {
5596
5866
  /**
5597
5867
  * Get metrics from the Langfuse project using a query object.
5598
5868
  *
5869
+ * Consider using the [v2 metrics endpoint](/api-reference#tag/metricsv2/GET/api/public/v2/metrics) for better performance.
5870
+ *
5599
5871
  * For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
5600
5872
  *
5601
5873
  * @param {LangfuseAPI.GetMetricsRequest} request
@@ -6163,6 +6435,221 @@ var Models = class {
6163
6435
  }
6164
6436
  };
6165
6437
 
6438
+ // src/api/api/resources/observationsV2/client/Client.ts
6439
+ var ObservationsV2 = class {
6440
+ constructor(_options) {
6441
+ this._options = _options;
6442
+ }
6443
+ /**
6444
+ * Get a list of observations with cursor-based pagination and flexible field selection.
6445
+ *
6446
+ * ## Cursor-based Pagination
6447
+ * This endpoint uses cursor-based pagination for efficient traversal of large datasets.
6448
+ * The cursor is returned in the response metadata and should be passed in subsequent requests
6449
+ * to retrieve the next page of results.
6450
+ *
6451
+ * ## Field Selection
6452
+ * Use the `fields` parameter to control which observation fields are returned:
6453
+ * - `core` - Always included: id, traceId, startTime, endTime, projectId, parentObservationId, type
6454
+ * - `basic` - name, level, statusMessage, version, environment, bookmarked, public, userId, sessionId
6455
+ * - `time` - completionStartTime, createdAt, updatedAt
6456
+ * - `io` - input, output
6457
+ * - `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
6458
+ * - `model` - providedModelName, internalModelId, modelParameters
6459
+ * - `usage` - usageDetails, costDetails, totalCost
6460
+ * - `prompt` - promptId, promptName, promptVersion
6461
+ * - `metrics` - latency, timeToFirstToken
6462
+ *
6463
+ * If not specified, `core` and `basic` field groups are returned.
6464
+ *
6465
+ * ## Filters
6466
+ * Multiple filtering options are available via query parameters or the structured `filter` parameter.
6467
+ * When using the `filter` parameter, it takes precedence over individual query parameter filters.
6468
+ *
6469
+ * @param {LangfuseAPI.GetObservationsV2Request} request
6470
+ * @param {ObservationsV2.RequestOptions} requestOptions - Request-specific configuration.
6471
+ *
6472
+ * @throws {@link LangfuseAPI.Error}
6473
+ * @throws {@link LangfuseAPI.UnauthorizedError}
6474
+ * @throws {@link LangfuseAPI.AccessDeniedError}
6475
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
6476
+ * @throws {@link LangfuseAPI.NotFoundError}
6477
+ *
6478
+ * @example
6479
+ * await client.observationsV2.getMany()
6480
+ */
6481
+ getMany(request = {}, requestOptions) {
6482
+ return HttpResponsePromise.fromPromise(
6483
+ this.__getMany(request, requestOptions)
6484
+ );
6485
+ }
6486
+ async __getMany(request = {}, requestOptions) {
6487
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
6488
+ const {
6489
+ fields,
6490
+ expandMetadata,
6491
+ limit,
6492
+ cursor,
6493
+ parseIoAsJson,
6494
+ name,
6495
+ userId,
6496
+ type: type_,
6497
+ traceId,
6498
+ level,
6499
+ parentObservationId,
6500
+ environment,
6501
+ fromStartTime,
6502
+ toStartTime,
6503
+ version,
6504
+ filter
6505
+ } = request;
6506
+ const _queryParams = {};
6507
+ if (fields != null) {
6508
+ _queryParams["fields"] = fields;
6509
+ }
6510
+ if (expandMetadata != null) {
6511
+ _queryParams["expandMetadata"] = expandMetadata;
6512
+ }
6513
+ if (limit != null) {
6514
+ _queryParams["limit"] = limit.toString();
6515
+ }
6516
+ if (cursor != null) {
6517
+ _queryParams["cursor"] = cursor;
6518
+ }
6519
+ if (parseIoAsJson != null) {
6520
+ _queryParams["parseIoAsJson"] = parseIoAsJson.toString();
6521
+ }
6522
+ if (name != null) {
6523
+ _queryParams["name"] = name;
6524
+ }
6525
+ if (userId != null) {
6526
+ _queryParams["userId"] = userId;
6527
+ }
6528
+ if (type_ != null) {
6529
+ _queryParams["type"] = type_;
6530
+ }
6531
+ if (traceId != null) {
6532
+ _queryParams["traceId"] = traceId;
6533
+ }
6534
+ if (level != null) {
6535
+ _queryParams["level"] = level;
6536
+ }
6537
+ if (parentObservationId != null) {
6538
+ _queryParams["parentObservationId"] = parentObservationId;
6539
+ }
6540
+ if (environment != null) {
6541
+ if (Array.isArray(environment)) {
6542
+ _queryParams["environment"] = environment.map((item) => item);
6543
+ } else {
6544
+ _queryParams["environment"] = environment;
6545
+ }
6546
+ }
6547
+ if (fromStartTime != null) {
6548
+ _queryParams["fromStartTime"] = fromStartTime;
6549
+ }
6550
+ if (toStartTime != null) {
6551
+ _queryParams["toStartTime"] = toStartTime;
6552
+ }
6553
+ if (version != null) {
6554
+ _queryParams["version"] = version;
6555
+ }
6556
+ if (filter != null) {
6557
+ _queryParams["filter"] = filter;
6558
+ }
6559
+ let _headers = mergeHeaders(
6560
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
6561
+ mergeOnlyDefinedHeaders({
6562
+ Authorization: await this._getAuthorizationHeader(),
6563
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
6564
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
6565
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
6566
+ }),
6567
+ requestOptions == null ? void 0 : requestOptions.headers
6568
+ );
6569
+ const _response = await fetcher({
6570
+ url: url_exports.join(
6571
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
6572
+ "/api/public/v2/observations"
6573
+ ),
6574
+ method: "GET",
6575
+ headers: _headers,
6576
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
6577
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
6578
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
6579
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
6580
+ });
6581
+ if (_response.ok) {
6582
+ return {
6583
+ data: _response.body,
6584
+ rawResponse: _response.rawResponse
6585
+ };
6586
+ }
6587
+ if (_response.error.reason === "status-code") {
6588
+ switch (_response.error.statusCode) {
6589
+ case 400:
6590
+ throw new Error2(
6591
+ _response.error.body,
6592
+ _response.rawResponse
6593
+ );
6594
+ case 401:
6595
+ throw new UnauthorizedError(
6596
+ _response.error.body,
6597
+ _response.rawResponse
6598
+ );
6599
+ case 403:
6600
+ throw new AccessDeniedError(
6601
+ _response.error.body,
6602
+ _response.rawResponse
6603
+ );
6604
+ case 405:
6605
+ throw new MethodNotAllowedError(
6606
+ _response.error.body,
6607
+ _response.rawResponse
6608
+ );
6609
+ case 404:
6610
+ throw new NotFoundError(
6611
+ _response.error.body,
6612
+ _response.rawResponse
6613
+ );
6614
+ default:
6615
+ throw new LangfuseAPIError({
6616
+ statusCode: _response.error.statusCode,
6617
+ body: _response.error.body,
6618
+ rawResponse: _response.rawResponse
6619
+ });
6620
+ }
6621
+ }
6622
+ switch (_response.error.reason) {
6623
+ case "non-json":
6624
+ throw new LangfuseAPIError({
6625
+ statusCode: _response.error.statusCode,
6626
+ body: _response.error.rawBody,
6627
+ rawResponse: _response.rawResponse
6628
+ });
6629
+ case "timeout":
6630
+ throw new LangfuseAPITimeoutError(
6631
+ "Timeout exceeded when calling GET /api/public/v2/observations."
6632
+ );
6633
+ case "unknown":
6634
+ throw new LangfuseAPIError({
6635
+ message: _response.error.errorMessage,
6636
+ rawResponse: _response.rawResponse
6637
+ });
6638
+ }
6639
+ }
6640
+ async _getAuthorizationHeader() {
6641
+ const username = await Supplier.get(this._options.username);
6642
+ const password = await Supplier.get(this._options.password);
6643
+ if (username != null && password != null) {
6644
+ return BasicAuth.toAuthorizationHeader({
6645
+ username,
6646
+ password
6647
+ });
6648
+ }
6649
+ return void 0;
6650
+ }
6651
+ };
6652
+
6166
6653
  // src/api/api/resources/observations/client/Client.ts
6167
6654
  var Observations = class {
6168
6655
  constructor(_options) {
@@ -6272,7 +6759,9 @@ var Observations = class {
6272
6759
  }
6273
6760
  }
6274
6761
  /**
6275
- * Get a list of observations
6762
+ * Get a list of observations.
6763
+ *
6764
+ * Consider using the [v2 observations endpoint](/api-reference#tag/observationsv2/GET/api/public/v2/observations) for cursor-based pagination and field selection.
6276
6765
  *
6277
6766
  * @param {LangfuseAPI.GetObservationsRequest} request
6278
6767
  * @param {Observations.RequestOptions} requestOptions - Request-specific configuration.
@@ -7717,7 +8206,7 @@ var Projects = class {
7717
8206
  * await client.projects.update("projectId", {
7718
8207
  * name: "name",
7719
8208
  * metadata: undefined,
7720
- * retention: 1
8209
+ * retention: undefined
7721
8210
  * })
7722
8211
  */
7723
8212
  update(projectId, request, requestOptions) {
@@ -10124,7 +10613,8 @@ var ScoreV2 = class {
10124
10613
  traceId,
10125
10614
  queueId,
10126
10615
  dataType,
10127
- traceTags
10616
+ traceTags,
10617
+ fields
10128
10618
  } = request;
10129
10619
  const _queryParams = {};
10130
10620
  if (page != null) {
@@ -10189,6 +10679,9 @@ var ScoreV2 = class {
10189
10679
  _queryParams["traceTags"] = traceTags;
10190
10680
  }
10191
10681
  }
10682
+ if (fields != null) {
10683
+ _queryParams["fields"] = fields;
10684
+ }
10192
10685
  let _headers = mergeHeaders(
10193
10686
  (_a2 = this._options) == null ? void 0 : _a2.headers,
10194
10687
  mergeOnlyDefinedHeaders({
@@ -11428,6 +11921,10 @@ var LangfuseAPIClient = class {
11428
11921
  var _a2;
11429
11922
  return (_a2 = this._media) != null ? _a2 : this._media = new Media(this._options);
11430
11923
  }
11924
+ get metricsV2() {
11925
+ var _a2;
11926
+ return (_a2 = this._metricsV2) != null ? _a2 : this._metricsV2 = new MetricsV2(this._options);
11927
+ }
11431
11928
  get metrics() {
11432
11929
  var _a2;
11433
11930
  return (_a2 = this._metrics) != null ? _a2 : this._metrics = new Metrics(this._options);
@@ -11436,6 +11933,10 @@ var LangfuseAPIClient = class {
11436
11933
  var _a2;
11437
11934
  return (_a2 = this._models) != null ? _a2 : this._models = new Models(this._options);
11438
11935
  }
11936
+ get observationsV2() {
11937
+ var _a2;
11938
+ return (_a2 = this._observationsV2) != null ? _a2 : this._observationsV2 = new ObservationsV2(this._options);
11939
+ }
11439
11940
  get observations() {
11440
11941
  var _a2;
11441
11942
  return (_a2 = this._observations) != null ? _a2 : this._observations = new Observations(this._options);
@@ -12082,6 +12583,7 @@ export {
12082
12583
  ObservationType,
12083
12584
  PricingTierOperator,
12084
12585
  PromptType,
12586
+ ScoreConfigDataType,
12085
12587
  ScoreDataType,
12086
12588
  ScoreSource,
12087
12589
  ServiceUnavailableError,
@@ -12111,8 +12613,10 @@ export {
12111
12613
  LoggerSingleton as logger,
12112
12614
  media_exports as media,
12113
12615
  metrics_exports as metrics,
12616
+ metricsV2_exports as metricsV2,
12114
12617
  models_exports as models,
12115
12618
  observations_exports as observations,
12619
+ observationsV2_exports as observationsV2,
12116
12620
  opentelemetry_exports as opentelemetry,
12117
12621
  organizations_exports as organizations,
12118
12622
  projects_exports as projects,