Skip to content

feat(api): update API spec from langfuse/langfuse 71b8050#1555

Closed
langfuse-bot wants to merge 1 commit intomainfrom
api-spec-bot-71b8050
Closed

feat(api): update API spec from langfuse/langfuse 71b8050#1555
langfuse-bot wants to merge 1 commit intomainfrom
api-spec-bot-71b8050

Conversation

@langfuse-bot
Copy link
Collaborator

@langfuse-bot langfuse-bot commented Mar 6, 2026

Disclaimer: Experimental PR review

Greptile Summary

This auto-generated PR reorganizes the Langfuse Python SDK's API client structure by promoting newer v2 endpoints to first-class status and moving older v1 endpoints into a new legacy namespace, reflecting the API spec update from langfuse/langfuse commit 71b8050.

Key structural changes:

  • New legacy namespace (client.legacy.*): Consolidates older v1 endpoints — score_v1 (create/delete scores), observations_v1 (page-based observation listing), and metrics_v1 (v1 metrics) — under client.legacy.* sub-clients.
  • metrics client promoted to v2: client.metrics.metrics() now hits api/public/v2/metrics and returns MetricsV2Response; the old v1 metrics endpoint is accessible via client.legacy.metrics_v1.metrics().
  • observations client promoted to v2: client.observations.get_many() now uses api/public/v2/observations with cursor-based pagination and field selection; the old page-based endpoint moves to client.legacy.observations_v1.
  • scores module replaces score_v2: client.scores takes over from the removed score_v2 client for score listing operations.
  • Breaking removals: CreateScoreRequest, CreateScoreResponse, MetricsResponse, Observations, ObservationsViews are removed from the top-level __all__ and are now only accessible via langfuse.api.legacy.*.
  • Inline imports inside property methods are present in the newly added legacy and scores properties, which violates the project's import placement rule (imports should be at the top of the module, not inside functions/methods).

Confidence Score: 4/5

  • This PR is safe to merge; it is auto-generated from Fern and performs an intentional, well-structured API reorganization with one style rule violation.
  • The changes are entirely auto-generated by Fern and the restructuring is internally consistent — all dynamic import maps, all lists, client properties, and type references are updated in lockstep. The one issue is the inline import pattern (violating the custom rule) in the new langfuse/api/client.py and langfuse/api/legacy/client.py properties, but this is a pervasive pattern throughout the pre-existing file and is a style concern rather than a runtime bug.
  • langfuse/api/client.py and langfuse/api/legacy/client.py contain the inline import violations; langfuse/api/__init__.py is the most impactful file for downstream consumers due to the breaking removals from __all__.

Important Files Changed

Filename Overview
langfuse/api/init.py Replaces module references from the old top-level flat structure (score, score_v2, metrics, metrics_v2, observations, observations_v2) to the new namespaced structure (legacy, scores, metrics, observations). All dynamic imports and all exports are updated consistently.
langfuse/api/client.py Adds the new legacy and scores sub-clients and removes the old score, score_v2, metrics_v2, and observations_v2 properties. New properties use inline imports inside their bodies, violating the project's import placement rule.
langfuse/api/legacy/init.py New file that acts as the namespace package for all legacy (v1) API endpoints, exporting CreateScoreRequest, CreateScoreResponse, MetricsResponse, Observations, ObservationsViews via lazy dynamic imports.
langfuse/api/legacy/client.py New file that groups the three legacy sub-clients (metrics_v1, observations_v1, score_v1). All three sub-client properties use inline imports inside their methods, violating the import placement rule.
langfuse/api/legacy/metrics_v1/client.py New file extracted from the old metrics client, wrapping the api/public/metrics (v1) endpoint and returning MetricsResponse. Both sync and async variants added.
langfuse/api/legacy/observations_v1/client.py Renamed/moved from observations_v2/client.py; now represents the legacy v1 api/public/observations endpoint with page-based pagination. Adds a new get() method and simplifies get_many() parameters.
langfuse/api/legacy/score_v1/client.py Renamed from score/client.py; renames ScoreClient → ScoreV1Client and RawScoreClient → RawScoreV1Client, updates docstring examples to reference client.legacy.score_v1.
langfuse/api/metrics/client.py The metrics client now targets the v2 endpoint (api/public/v2/metrics) and returns MetricsV2Response instead of MetricsResponse. Docstrings greatly expanded with available views, dimensions, and measures.
langfuse/api/observations/client.py The observations client now targets the v2 endpoint with cursor-based pagination and field selection (ObservationsV2Response). The legacy get() method is removed (moved to legacy/observations_v1).
langfuse/api/scores/client.py New file renamed from score_v2/client.py; client renamed ScoreV2Client → ScoresClient with full scores listing/filtering functionality.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[LangfuseAPI / AsyncLangfuseAPI] --> B[client.metrics]
    A --> C[client.observations]
    A --> D[client.scores]
    A --> E[client.legacy]
    A --> F[client.score_configs]

    B -->|api/public/v2/metrics| B1[MetricsV2Response]
    C -->|api/public/v2/observations\ncursor-based pagination| C1[ObservationsV2Response]
    D -->|GET /api/public/scores| D1[GetScoresResponse]

    E --> G[legacy.metrics_v1]
    E --> H[legacy.observations_v1]
    E --> I[legacy.score_v1]

    G -->|api/public/metrics\nv1 endpoint| G1[MetricsResponse]
    H -->|api/public/observations\npage-based pagination| H1[ObservationsViews]
    H -->|api/public/observations/:id| H2[ObservationsView]
    I -->|POST /api/public/scores| I1[CreateScoreResponse]
    I -->|DELETE /api/public/scores/:id| I2[void]
Loading

Last reviewed commit: eb4acfc

Context used:

  • Rule from dashboard - Move imports to the top of the module instead of placing them within functions or methods. (source)

@langfuse-bot langfuse-bot requested a review from hassiebp March 6, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant