Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(scores): release v3 scores API (#14099)

Niklas Semmlerd32b8521a3b1
diff --git a/.env.dev.example b/.env.dev.example
index d41bcedce2..165dd0fb65 100644
--- a/.env.dev.example
+++ b/.env.dev.example
@@ -193,7 +193,5 @@ LANGFUSE_MIGRATION_V4_NATIVE_OTEL_BEHAVIOUR=dual_write
# Legacy tracing UI controls
LANGFUSE_DISABLE_LEGACY_TRACING_IO_SEARCH=false
-LANGFUSE_ENABLE_SCORES_V3_API=true
-
CLICKHOUSE_USE_LIGHTWEIGHT_UPDATE="true"
CLICKHOUSE_DISABLE_LAZY_MATERIALIZATION=true
diff --git a/.env.prod.example b/.env.prod.example
index 24631cc66f..9c833cf816 100644
--- a/.env.prod.example
+++ b/.env.prod.example
@@ -354,7 +354,3 @@ LANGFUSE_ENABLE_BLOB_STORAGE_FILE_LOG=true
# LANGFUSE_INIT_ORG_CLOUD_PLAN=
### END Langfuse CI Config
-
-# v3 Scores API (preview, Cloud-only). Self-hosted instances should leave this
-# unset until the API graduates from preview.
-# LANGFUSE_ENABLE_SCORES_V3_API=false
diff --git a/fern/apis/server/_drafts/scores-v3.yml b/fern/apis/server/definition/scores-v3.yml
similarity index 97%
rename from fern/apis/server/_drafts/scores-v3.yml
rename to fern/apis/server/definition/scores-v3.yml
index 2c648556f3..9f19fe3aa8 100644
--- a/fern/apis/server/_drafts/scores-v3.yml
+++ b/fern/apis/server/definition/scores-v3.yml
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json
imports:
- commons: ../definition/commons.yml
+ commons: ./commons.yml
service:
auth: true
@@ -10,6 +10,8 @@ service:
docs: |
Get a list of scores with a polymorphic `value` field (v3).
+ This endpoint requires Langfuse v4 or later.
+
The `value` field type depends on `dataType`:
- `NUMERIC` → number
- `BOOLEAN` → boolean
@@ -17,12 +19,6 @@ service:
Use the `fields` parameter to include optional field groups beyond the
default `core`. Unknown group names return HTTP 400.
-
- Unknown query parameters (e.g. `field` instead of `fields`) return HTTP
- 400 rather than being silently ignored.
-
- Currently in preview for Langfuse Cloud v4 users; not yet available on
- self-hosted Langfuse.
method: GET
path: /v3/scores
request:
diff --git a/web/public/generated/api/openapi.yml b/web/public/generated/api/openapi.yml
index feeb1eb576..4f62edea21 100644
--- a/web/public/generated/api/openapi.yml
+++ b/web/public/generated/api/openapi.yml
@@ -5295,6 +5295,243 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/UpdateScoreConfigRequest'
+ /api/public/v3/scores:
+ get:
+ description: |-
+ Get a list of scores with a polymorphic `value` field (v3).
+
+ This endpoint requires Langfuse v4 or later.
+
+ The `value` field type depends on `dataType`:
+ - `NUMERIC` → number
+ - `BOOLEAN` → boolean
+ - `CATEGORICAL`, `TEXT`, `CORRECTION` → string
+
+ Use the `fields` parameter to include optional field groups beyond the
+ default `core`. Unknown group names return HTTP 400.
+ operationId: scoresV3_getManyV3
+ tags:
+ - ScoresV3
+ parameters:
+ - name: limit
+ in: query
+ description: >-
+ Number of items per page. Maximum 100, default 50. Requests with a
+ limit greater than 100 return HTTP 400.
+ required: false
+ schema:
+ type: integer
+ nullable: true
+ - name: cursor
+ in: query
+ description: >-
+ URL-safe base64 (base64url) cursor for pagination. Use the cursor
+ from the previous response to get the next page. Absent on the final
+ page.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: fields
+ in: query
+ description: >-
+ Comma-separated field groups to include. Allowed: core, details,
+ subject, annotation. Defaults to "core". Unknown names return HTTP
+ 400.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: id
+ in: query
+ description: >-
+ Comma-separated list of score IDs to filter by (OR within, AND
+ across filters).
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: name
+ in: query
+ description: Comma-separated list of score names to filter by.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: source
+ in: query
+ description: >-
+ Comma-separated list of score sources to filter by (e.g. API,
+ ANNOTATION, EVAL). Case-insensitive — `api` and `API` are
+ equivalent.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: dataType
+ in: query
+ description: >-
+ Comma-separated list of data types to filter by (NUMERIC, BOOLEAN,
+ CATEGORICAL, TEXT, CORRECTION). Case-insensitive — `numeric` and
+ `NUMERIC` are equivalent. Must be a single value when used with
+ value, valueMin, or valueMax; otherwise the request returns HTTP
+ 400. Must be NUMERIC when used with valueMin or valueMax.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: environment
+ in: query
+ description: Comma-separated list of environments to filter by.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: configId
+ in: query
+ description: Comma-separated list of score config IDs to filter by.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: queueId
+ in: query
+ description: Comma-separated list of annotation queue IDs to filter by.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: authorUserId
+ in: query
+ description: Comma-separated list of author user IDs to filter by.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: value
+ in: query
+ description: >-
+ Comma-separated list of exact values to filter by. Requires a single
+ dataType from NUMERIC, BOOLEAN, or CATEGORICAL; any other dataType,
+ multiple dataTypes, or omitting dataType returns HTTP 400. For
+ BOOLEAN, each value must be "true" or "false"; for NUMERIC, each
+ value must be a finite number. Otherwise the request returns HTTP
+ 400.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: valueMin
+ in: query
+ description: >-
+ Inclusive lower bound on the numeric value. Requires
+ dataType=NUMERIC as a single value; otherwise the request returns
+ HTTP 400.
+ required: false
+ schema:
+ type: number
+ format: double
+ nullable: true
+ - name: valueMax
+ in: query
+ description: >-
+ Inclusive upper bound on the numeric value. Requires
+ dataType=NUMERIC as a single value; otherwise the request returns
+ HTTP 400.
+ required: false
+ schema:
+ type: number
+ format: double
+ nullable: true
+ - name: traceId
+ in: query
+ description: >-
+ Comma-separated list of trace IDs to filter by. Mutually exclusive
+ with sessionId, experimentId. May be combined with observationId to
+ scope the observation lookup to a specific trace.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: sessionId
+ in: query
+ description: >-
+ Comma-separated list of session IDs to filter by. Mutually exclusive
+ with traceId, observationId, experimentId.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: observationId
+ in: query
+ description: >-
+ Comma-separated list of observation IDs to filter by. Requires
+ traceId to be specified, because observation IDs are scoped to a
+ trace. Mutually exclusive with sessionId, experimentId. Returns HTTP
+ 400 when used without traceId.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: experimentId
+ in: query
+ description: >-
+ Comma-separated list of dataset run IDs (experiment IDs) to filter
+ by. Mutually exclusive with traceId, sessionId, observationId.
+ required: false
+ schema:
+ type: string
+ nullable: true
+ - name: fromTimestamp
+ in: query
+ description: Inclusive lower bound on the score timestamp.
+ required: false
+ schema:
+ type: string
+ format: date-time
+ nullable: true
+ - name: toTimestamp
+ in: query
+ description: Exclusive upper bound on the score timestamp.
+ required: false
+ schema:
+ type: string
+ format: date-time
+ nullable: true
+ responses:
+ '200':
+ description: ''
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/GetScoresV3Response'
+ '400':
+ description: ''
+ content:
+ application/json:
+ schema: {}
+ '401':
+ description: ''
+ content:
+ application/json:
+ schema: {}
+ '403':
+ description: ''
+ content:
+ application/json:
+ schema: {}
+ '404':
+ description: ''
+ content:
+ application/json:
+ schema: {}
+ '405':
+ description: ''
+ content:
+ application/json:
+ schema: {}
+ security:
+ - BasicAuth: []
/api/public/v2/scores:
get:
description: Get a list of scores (supports both trace and session scores)
@@ -11979,6 +12216,308 @@ components:
Description is shown across the Langfuse UI and can be used to e.g.
explain the config categories in detail, why a numeric range was
set, or provide additional context on config name or usage
+ ScoreSubjectTraceV3:
+ title: ScoreSubjectTraceV3
+ type: object
+ properties:
+ id:
+ type: string
+ description: The trace ID.
+ required:
+ - id
+ ScoreSubjectObservationV3:
+ title: ScoreSubjectObservationV3
+ type: object
+ properties:
+ id:
+ type: string
+ description: The observation ID.
+ traceId:
+ type: string
+ nullable: true
+ description: The parent trace ID, if available.
+ required:
+ - id
+ ScoreSubjectSessionV3:
+ title: ScoreSubjectSessionV3
+ type: object
+ properties:
+ id:
+ type: string
+ description: The session ID.
+ required:
+ - id
+ ScoreSubjectExperimentV3:
+ title: ScoreSubjectExperimentV3
+ type: object
+ properties:
+ id:
+ type: string
+ description: The dataset run ID (experiment ID).
+ required:
+ - id
+ ScoreSubjectV3:
+ title: ScoreSubjectV3
+ oneOf:
+ - type: object
+ allOf:
+ - type: object
+ properties:
+ kind:
+ type: string
+ enum:
+ - trace
+ - $ref: '#/components/schemas/ScoreSubjectTraceV3'
+ required:
+ - kind
+ - type: object
+ allOf:
+ - type: object
+ properties:
+ kind:
+ type: string
+ enum:
+ - observation
+ - $ref: '#/components/schemas/ScoreSubjectObservationV3'
+ required:
+ - kind
+ - type: object
+ allOf:
+ - type: object
+ properties:
+ kind:
+ type: string
+ enum:
+ - session
+ - $ref: '#/components/schemas/ScoreSubjectSessionV3'
+ required:
+ - kind
+ - type: object
+ allOf:
+ - type: object
+ properties:
+ kind:
+ type: string
+ enum:
+ - experiment
+ - $ref: '#/components/schemas/ScoreSubjectExperimentV3'
+ required:
+ - kind
+ description: >-
+ A reference to the entity this score is attached to. Discriminated by
+ "kind" — one of trace, observation, session, or experiment.
+ BaseScoreV3:
+ title: BaseScoreV3
+ type: object
+ properties:
+ id:
+ type: string
+ projectId:
+ type: string
+ name:
+ type: string
+ source:
+ $ref: '#/components/schemas/ScoreSource'
+ timestamp:
+ type: string
+ format: date-time
+ environment:
+ type: string
+ description: The environment from which this score originated.
+ createdAt:
+ type: string
+ format: date-time
+ updatedAt:
+ type: string
+ format: date-time
+ comment:
+ type: string
+ nullable: true
+ description: >-
+ Optional comment attached to the score. Present when "details" is
+ included in the fields parameter.
+ configId:
+ type: string
+ nullable: true
+ description: >-
+ The score config ID, if this score was created from a config.
+ Present when "details" is included in the fields parameter.
+ metadata:
+ type: object
+ additionalProperties: true
+ nullable: true
+ description: >-
+ Arbitrary metadata attached to the score. Present when "details" is
+ included in the fields parameter.
+ authorUserId:
+ type: string
+ nullable: true
+ description: >-
+ The user who created this score, if available. Present when
+ "annotation" is included in the fields parameter.
+ queueId:
+ type: string
+ nullable: true
+ description: >-
+ The annotation queue this score belongs to, if any. Present when
+ "annotation" is included in the fields parameter.
+ subject:
+ $ref: '#/components/schemas/ScoreSubjectV3'
+ nullable: true
+ description: >-
+ The entity this score is attached to (trace, observation, session,
+ or experiment). Present when "subject" is included in the fields
+ parameter.
+ required:
+ - id
+ - projectId
+ - name
+ - source
+ - timestamp
+ - environment
+ - createdAt
+ - updatedAt
+ NumericScoreV3:
+ title: NumericScoreV3
+ type: object
+ properties:
+ value:
+ type: number
+ format: double
+ description: The numeric value of the score.
+ required:
+ - value
+ allOf:
+ - $ref: '#/components/schemas/BaseScoreV3'
+ BooleanScoreV3:
+ title: BooleanScoreV3
+ type: object
+ properties:
+ value:
+ type: boolean
+ description: The boolean value of the score.
+ required:
+ - value
+ allOf:
+ - $ref: '#/components/schemas/BaseScoreV3'
+ CategoricalScoreV3:
+ title: CategoricalScoreV3
+ type: object
+ properties:
+ value:
+ type: string
+ description: The string category value of the score.
+ required:
+ - value
+ allOf:
+ - $ref: '#/components/schemas/BaseScoreV3'
+ TextScoreV3:
+ title: TextScoreV3
+ type: object
+ properties:
+ value:
+ type: string
+ description: The text content of the score.
+ required:
+ - value
+ allOf:
+ - $ref: '#/components/schemas/BaseScoreV3'
+ CorrectionScoreV3:
+ title: CorrectionScoreV3
+ type: object
+ properties:
+ value:
+ type: string
+ description: The correction content of the score. Empty string if not set.
+ required:
+ - value
+ allOf:
+ - $ref: '#/components/schemas/BaseScoreV3'
+ ScoreV3:
+ title: ScoreV3
+ oneOf:
+ - type: object
+ allOf:
+ - type: object
+ properties:
+ dataType:
+ type: string
+ enum:
+ - NUMERIC
+ - $ref: '#/components/schemas/NumericScoreV3'
+ required:
+ - dataType
+ - type: object
+ allOf:
+ - type: object
+ properties:
+ dataType:
+ type: string
+ enum:
+ - BOOLEAN
+ - $ref: '#/components/schemas/BooleanScoreV3'
+ required:
+ - dataType
+ - type: object
+ allOf:
+ - type: object
+ properties:
+ dataType:
+ type: string
+ enum:
+ - CATEGORICAL
+ - $ref: '#/components/schemas/CategoricalScoreV3'
+ required:
+ - dataType
+ - type: object
+ allOf:
+ - type: object
+ properties:
+ dataType:
+ type: string
+ enum:
+ - TEXT
+ - $ref: '#/components/schemas/TextScoreV3'
+ required:
+ - dataType
+ - type: object
+ allOf:
+ - type: object
+ properties:
+ dataType:
+ type: string
+ enum:
+ - CORRECTION
+ - $ref: '#/components/schemas/CorrectionScoreV3'
+ required:
+ - dataType
+ GetScoresV3Meta:
+ title: GetScoresV3Meta
+ type: object
+ properties:
+ limit:
+ type: integer
+ cursor:
+ type: string
+ nullable: true
+ description: >-
+ URL-safe base64 (base64url) cursor for the next page. Absent when
+ there are no more results.
+ required:
+ - limit
+ GetScoresV3Response:
+ title: GetScoresV3Response
+ type: object
+ properties:
+ data:
+ type: array
+ items:
+ $ref: '#/components/schemas/ScoreV3'
+ meta:
+ $ref: '#/components/schemas/GetScoresV3Meta'
+ required:
+ - data
+ - meta
GetScoresResponseTraceData:
title: GetScoresResponseTraceData
type: object
diff --git a/web/src/env.mjs b/web/src/env.mjs
index d4af969ecf..8478b9db19 100644
--- a/web/src/env.mjs
+++ b/web/src/env.mjs
@@ -436,8 +436,6 @@ export const env = createEnv({
.enum(["legacy", "dual", "events_only"])
.default("legacy"),
- LANGFUSE_ENABLE_SCORES_V3_API: z.enum(["true", "false"]).default("false"),
-
// Blocked users for chat completion API (userId:reason format)
LANGFUSE_BLOCKED_USERIDS_CHATCOMPLETION: z
.string()
@@ -845,7 +843,6 @@ export const env = createEnv({
// Legacy tracing search controls
LANGFUSE_DISABLE_LEGACY_TRACING_IO_SEARCH:
process.env.LANGFUSE_DISABLE_LEGACY_TRACING_IO_SEARCH,
- LANGFUSE_ENABLE_SCORES_V3_API: process.env.LANGFUSE_ENABLE_SCORES_V3_API,
LANGFUSE_BLOCKED_USERIDS_CHATCOMPLETION:
process.env.LANGFUSE_BLOCKED_USERIDS_CHATCOMPLETION,
},
diff --git a/web/src/pages/api/public/v3/scores/index.ts b/web/src/pages/api/public/v3/scores/index.ts
index 70c9328cfd..2f4c580c27 100644
--- a/web/src/pages/api/public/v3/scores/index.ts
+++ b/web/src/pages/api/public/v3/scores/index.ts
@@ -1,13 +1,8 @@
import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";
import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";
-import {
- GetScoresQueryV3,
- GetScoresResponseV3,
- LangfuseNotFoundError,
-} from "@langfuse/shared";
+import { GetScoresQueryV3, GetScoresResponseV3 } from "@langfuse/shared";
import { listScoresV3ForPublicApi } from "@/src/features/public-api/server/scores-api-v3";
import { EncodedScoresCursorV3 } from "@/src/features/public-api/types/scores";
-import { env } from "@/src/env.mjs";
const GetScoresV3Query = GetScoresQueryV3.extend({
cursor: EncodedScoresCursorV3.optional(),
@@ -107,14 +102,6 @@ export default withMiddlewares({
querySchema: GetScoresV3Query,
responseSchema: GetScoresResponseV3,
fn: async ({ query, auth }) => {
- if (env.LANGFUSE_ENABLE_SCORES_V3_API !== "true") {
- // Returns 404 to authenticated callers when disabled. Note: auth and
- // Zod parsing already ran, so an unauthenticated caller sees 401 here
- // (signalling the endpoint exists). Cloud has the flag on by default;
- // self-hosted instances see 404 until the API graduates from preview.
- throw new LangfuseNotFoundError("Not Found");
- }
-
const result = await listScoresV3ForPublicApi({
projectId: auth.scope.projectId,
limit: query.limit,