Neural Inverse is Open Source →
DocsQuery via SDKs
DocsAPI & Data PlatformFeaturesQuery via SDKs

Query Data via SDKs

Neural Inverse is open-source and data tracked with Neural Inverse is open. Use the Python and JS/TS SDKs to query the same public APIs without writing raw HTTP requests.

Common use cases:

  • Query row-level observations for evaluation pipelines, few-shot examples, or fine-tuning datasets.
  • Query aggregate cost, usage, latency, volume, and score metrics for dashboards or billing workflows.
  • Programmatically create datasets.

If you are new to Neural Inverse, we recommend familiarizing yourself with the Neural Inverse data model.

New data is typically available for querying within 15-30 seconds of ingestion, though processing times may vary at times. Please visit status.langfuse.com if you encounter any issues.

SDKs

Via the SDKs for Python and JS/TS you can easily query the API without having to write the HTTP requests yourself.

The api namespace is auto-generated from the Public API (OpenAPI). Method names mirror REST resources and support filters and pagination.

From Python SDK v4 and JS/TS SDK v5 onward, the high-performance v2 data APIs are the defaults:

  • api.observations (formerly api.observations_v_2 / api.observationsV2)
  • api.scores (formerly api.score_v_2 / api.scoreV2)
  • api.metrics (formerly api.metrics_v_2 / api.metricsV2)

The old v2 aliases were removed in Python SDK v4 and JS/TS SDK v5.

The older trace, observation, and metrics read APIs remain available, but they are not recommended as the default for new data extraction workflows because they are less performant at scale. See Observations API v2 for row-level data and Metrics API v2 for aggregates.

pip install langfuse
from langfuse import get_client
langfuse = get_client()  # uses environment variables to authenticate

Observations

observations = langfuse.api.observations.get_many(
    trace_id="abcdef1234",
    type="GENERATION",
    limit=100,
    fields="core,basic,usage"
)

Use trace_id to retrieve the observations that belong to a single trace. Use parent_observation_id in the response to reconstruct an observation tree when needed.

Metrics

For the full query schema, supported dimensions, filters, and examples, see the Metrics API v2 documentation.

query = """
{
  "view": "observations",
  "metrics": [{"measure": "totalCost", "aggregation": "sum"}],
  "dimensions": [{"field": "providedModelName"}],
  "filters": [],
  "fromTimestamp": "2025-05-01T00:00:00Z",
  "toTimestamp": "2025-05-13T00:00:00Z"
}
"""

metrics = langfuse.api.metrics.get(query = query)

Other resources

Sessions:

sessions = langfuse.api.sessions.list(limit=50)

Scores:

scores = langfuse.api.scores.get_many(score_ids = "ScoreId")

Prompts:

Please refer to the prompt management documentation on fetching prompts.

Datasets:

# Namespaces:
# - langfuse.api.datasets.*
# - langfuse.api.dataset_items.*
# - langfuse.api.dataset_run_items.*

Async equivalents

# All endpoints are also available as async under `async_api`:
observations = await langfuse.async_api.observations.get_many(
    trace_id="abcdef1234",
    limit=100,
    fields="core,basic,usage",
)
metrics = await langfuse.async_api.metrics.get(query = query)

For row-level observation filters, field selection, and cursor pagination, see the Observations API v2 documentation.

The methods on the langfuse.api are auto-generated from the API reference and cover all entities. You can explore more entities via Intellisense

npm install @langfuse/client
import { LangfuseClient } from "@langfuse/client";

const langfuse = new LangfuseClient();

Observations

const observations = await langfuse.api.observations.getMany({
  traceId: "abcdef1234",
  type: "GENERATION",
  limit: 100,
  fields: "core,basic,usage",
});

Use traceId to retrieve the observations that belong to a single trace. Use parentObservationId in the response to reconstruct an observation tree when needed.

For row-level observation filters, field selection, and cursor pagination, see the Observations API v2 documentation.

Metrics

For the full query schema, supported dimensions, filters, and examples, see the Metrics API v2 documentation.

const query = {
  view: "observations",
  metrics: [{ measure: "totalCost", aggregation: "sum" }],
  dimensions: [{ field: "providedModelName" }],
  filters: [],
  fromTimestamp: "2025-05-01T00:00:00Z",
  toTimestamp: "2025-05-13T00:00:00Z",
};

const metrics = await langfuse.api.metrics.get({
  query: JSON.stringify(query),
});

Other resources

Sessions:

const sessions = await langfuse.api.sessions.list({ limit: 50 });

Scores:

const scores = await langfuse.api.scores.getMany();

Prompts:

Please refer to the prompt management documentation on fetching prompts.

Datasets:

// Namespaces:
// - langfuse.api.datasets.*
// - langfuse.api.datasetItems.*
// - langfuse.api.datasetRunItems.*

Explore more entities via Intellisense on langfuse.api.

  • To move existing trace or observation reads to v2, see Observations API v2.
  • To move existing metrics queries to v2, see Metrics API v2.
  • For large-scale data exports (e.g., all traces for fine-tuning or analytics), consider using the Blob Storage Export to automatically sync data to S3, GCS, or Azure on a schedule instead of paginating through the API.
  • To manually export filtered data from the Neural Inverse UI, see Export from UI.

Was this page helpful?