v2 Metrics and Observations API (Beta)

New high-performance v2 APIs for metrics and observations with cursor-based pagination, selective field retrieval, and optimized data architecture.
We’re releasing new v2 endpoints for our Metrics and Observations APIs, designed from the ground up for performance at scale.
The v2 APIs are currently in beta. They are stable for production use, but some parameters and behaviors may evolve based on user feedback before general availability.
Cloud-only (Beta): The v2 APIs are only available on Langfuse Cloud and currently in beta. We are working on a robust migration path for self-hosted deployments.
Important: With current SDK versions, data may take approximately 5 minutes to appear on v2 endpoints. We will be releasing updated SDK versions soon that will make data available immediately on v2 endpoints.
Why v2?
The v1 /public/traces and /public/observations endpoints have been among the most resource-intensive APIs to serve. After analyzing usage patterns, we identified several opportunities to dramatically reduce query overhead:
- No single way to request partial data - The v1 API always returns complete rows with I/O, usage, and metadata even when only a few fields are needed. Traces v1 endpoint supports
fieldsparameter, but it is too coarse-grained. - Offset pagination doesn’t scale - Page-based pagination makes database do more work than strictly necessary.
- JSON parsing is expensive - Automatic JSON parsing of input/output adds overhead even when raw strings suffice
The v2 APIs address all of these issues. Additionally, v2 is built on top of a new immutable data model that is inherently faster - it requires fewer joins and eliminates the need for deduplication at query time.
What’s New
Metrics API v2
GET /api/public/v2/metricsBuilt on an optimized data model, the v2 Metrics API delivers significantly faster query performance.
The traces view is no longer available in v2. Instead, use the observations view which is both faster and more powerful.
Row limit - Default limit of 100 rows per query ensures consistent performance. Override with a custom rowLimit in your query.
High cardinality dimensions - Certain dimensions like id, traceId, userId, and sessionId can no longer be used for grouping in the v2 Metrics API. Grouping by these high cardinality fields is not performant and rarely useful in practice. These dimensions remain available for filtering.
Observations API v2
GET /api/public/v2/observationsA redesigned endpoint for high-performance observation retrieval:
- Selective field retrieval - Specify which field groups you need (e.g.,
core,basic,io,usage). Defaults tocoreandbasicif not specified - Cursor-based pagination - Consistent performance regardless of pagination depth
- Optimized I/O handling - Returns I/O as strings by default; set
parseIoAsJson: trueonly when needed - Stricter limits - Default limit of 50 (max 1,000). With cursor based pagination, large result sets can be efficiently retrieved in smaller chunks, while less work is required per chunk.
Migration Notes
The v2 APIs are additive - v1 endpoints remain available and unchanged. When ready to migrate:
- Update your API calls to use
/api/public/v2/prefix - Use the
fieldsparameter to specify which field groups you need - Replace page-based pagination with cursor-based pagination
- Note that
parseIoAsJsondefaults tofalsein v2 (v1 always parsed I/O as JSON)
Using v1 /api/public/traces? Consider v2 /api/public/v2/observations instead - it’s significantly faster and covers most use cases.
Learn more
For full documentation, see the Metrics API docs and Observations API docs.