Skip to content

feat(api): update API spec from langfuse/langfuse 3fedbb7 (#1558)#1559

Closed
hassiebp wants to merge 1 commit intomainfrom
feat-move-obs-legacy-namespace
Closed

feat(api): update API spec from langfuse/langfuse 3fedbb7 (#1558)#1559
hassiebp wants to merge 1 commit intomainfrom
feat-move-obs-legacy-namespace

Conversation

@hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Mar 9, 2026

Disclaimer: Experimental PR review

Greptile Summary

This PR reorganizes the auto-generated Fern SDK API surface by promoting v2 endpoints to top-level modules and consolidating deprecated v1 endpoints under a new legacy namespace. The v2 metrics, observations, and scores APIs are now the primary surface (langfuse.api.metrics, langfuse.api.observations, langfuse.api.scores), while the old v1 equivalents move to langfuse.api.legacy.{metrics_v1,observations_v1,score_v1}.

Breaking API change: CreateScoreRequest, CreateScoreResponse, MetricsResponse, Observations, and ObservationsViews are removed from langfuse.api.__all__ and are no longer available at the top level. Existing consumer code doing from langfuse.api import CreateScoreRequest will fail with AttributeError. These types are available in langfuse.api.legacy but this removal is undocumented.

New features: ScoresClient.get_many gains new filter parameters (dataset_run_id, session_id, queue_id, fields, filter, environment, trace_tags) and a new GetScoresResponseTraceData type for optional trace context in score responses.

Confidence Score: 2/5

  • This PR introduces a breaking public API change that will cause AttributeError for existing SDK consumers importing removed top-level symbols without providing migration guidance.
  • The PR successfully reorganizes the API surface per the upstream spec, but the removal of CreateScoreRequest, CreateScoreResponse, MetricsResponse, Observations, and ObservationsViews from the top-level langfuse.api namespace is a hard breaking change. While these types are available via langfuse.api.legacy, the migration path is undocumented. Existing code doing from langfuse.api import CreateScoreRequest will fail immediately after upgrade.
  • langfuse/api/__init__.py — Breaking removal of public symbols requires documentation/deprecation strategy

Flowchart

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

    B --> B1[.metrics_v1\nGET api/public/metrics\nMetricsResponse]
    B --> B2[.observations_v1\nGET api/public/observations\nObservationsViews]
    B --> B3[.score_v1\nCreateScoreRequest / CreateScoreResponse]

    C --> C1[.get_many\nGetScoresResponse\n+ dataset_run_id, session_id,\n  queue_id, fields, filter]

    D --> D1[.metrics\nMetricsV2Response]

    E --> E1[.get_many\nObservationsV2Response\n cursor-based pagination]
    E --> E2[.get\nObservationV2]

    style B fill:#f9c,stroke:#c66
    style B1 fill:#fdd,stroke:#c66
    style B2 fill:#fdd,stroke:#c66
    style B3 fill:#fdd,stroke:#c66
    style C fill:#cfc,stroke:#6a6
    style D fill:#cfc,stroke:#6a6
    style E fill:#cfc,stroke:#6a6
Loading

Last reviewed commit: 1af24f0

Greptile also left 1 inline comment on this PR.

Co-authored-by: langfuse-bot <langfuse-bot@langfuse.com>
Comment on lines 628 to 629
"CreateObservationEvent",
"CreatePromptRequest",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateScoreRequest, CreateScoreResponse, MetricsResponse, Observations, and ObservationsViews are removed from langfuse.api.__all__ and _dynamic_imports. Any user code that imports these symbols directly from langfuse.api (e.g., from langfuse.api import CreateScoreRequest) will receive an AttributeError at runtime after upgrading.

These types have been relocated to langfuse.api.legacy (available via from langfuse.api.legacy.score_v1 import CreateScoreRequest, etc.), but this is a silent breaking change for existing SDK consumers. If intentional, consider adding a deprecation entry or migration guide to help users upgrade.

Rule Used: Move imports to the top of the module instead of p... (source)

Learnt From
langfuse/langfuse-python#1387

@hassiebp hassiebp closed this Mar 9, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1af24f09e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +338 to +342
def scores(self):
if self._scores is None:
from .scores.client import ScoresClient # noqa: E402

self._score = ScoreClient(client_wrapper=self._client_wrapper)
return self._score
self._scores = ScoresClient(client_wrapper=self._client_wrapper)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve deprecated API client attribute aliases

Renaming the top-level client accessors without aliases (scorescores, and similarly removing other *_v2 accessors in this commit) introduces a runtime compatibility break for users upgrading from the previous SDK version: existing code that calls LangfuseAPI().score... (or other removed attributes) now raises AttributeError immediately. Since the old functionality still exists under legacy, keeping deprecated alias properties would avoid breaking existing integrations while allowing the new naming.

Useful? React with 👍 / 👎.

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.

2 participants