Fetch the dataset before running. Python: `dataset = langfuse.get_dataset(name="my-dataset")`. JS/TS: `const dataset = await langfuse.dataset.get("my-dataset")`.
Run the experiment bound to the dataset so Langfuse creates a DatasetRun and links one trace per item. Python: `result = dataset.run_experiment(name="Baseline Experiment v1", description="Monthly evaluation", task=lambda *, item, **kwargs: item.expected_output)`. JS/TS: `const result = await dataset.runExperiment({ name: "Baseline Experiment v1", task: async (item) => item.expectedOutput })`.
Define a real task function with the documented signature. Python: `def my_task(*, item, **kwargs): question = item["input"]; ...; return response`. JS/TS: `const myTask: ExperimentTask = async (item) => { const question = item.input; ...; return response; }`.
To run against arbitrary local data instead of a hosted dataset, use the standalone runner. Python: `langfuse.run_experiment(name="Geography Quiz", description="Testing basic functionality", data=local_data, task=my_task, evaluators=[...], run_evaluators=[...], max_concurrency=10)`. JS/TS: `await langfuse.experiment.run({ name, description, data: localData, task: myTask })`.
Print a quick summary from the result object: `print(result.format())` in Python, `console.log(await result.format())` in JS/TS.
Compare runs in the UI: open the dataset, list its DatasetRuns, and use the run-comparison view to diff outputs and scores across runs (for example gpt-4 versus gpt-4o, or prompt v3 versus v4). Each DatasetRunItem links a datasetItemId to the produced traceId.
Verified against current official docs on 2026-07-29: https://langfuse.com/docs/evaluation/experiments/experiments-via-sdk , https://langfuse.com/docs/evaluation/experiments/datasets
Known gotchas
Item access differs by data source and is easy to get wrong: hosted dataset items are objects accessed by attribute (`item.expected_output` in Python, `item.expectedOutput` in JS/TS), while local data passed to the standalone runner is typically plain dicts accessed by key (`item["input"]`). Mixing the two raises AttributeError or TypeError at runtime.
Documentation paths moved. The older `/docs/evaluation/dataset-runs/get-started` and `/docs/evaluation/dataset-runs/datasets` URLs now 404; the current canonical paths are under `/docs/evaluation/experiments/`. Update bookmarks and any link checks.
Terminology shifted from dataset run to Experiment (`run_experiment` / `experiment.run`), with DatasetRun and DatasetRunItem remaining as the underlying data-model objects. Older posts using earlier `createRun`-style APIs no longer match the SDK.
`dataset.run_experiment` / `dataset.runExperiment` creates a Langfuse-hosted DatasetRun visible in the UI. The standalone `langfuse.run_experiment(data=...)` on local data does not produce a comparable hosted run by default, so pick the entrypoint that matches whether you need UI-side run comparison.
Each dataset item execution creates a new trace. Re-running large datasets in CI on every commit multiplies ingestion volume and cost; bound it with `max_concurrency`/`maxConcurrency` and sampling.
`observationId` on DatasetRunItem exists for backward compatibility; new integrations should rely on `traceId` as the link between a run item and its execution trace.
Give your agent this knowledge — and 15,700+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?