Skip to main content
A dataset run executes your prompt or agent over every item in a dataset and links each produced trace back to the item that generated it. Zespan never calls your model for you here — your own code (a script, a CI job, a scheduled batch) does the work; the SDK just records which trace answered which dataset item. Once every item is linked, you score the run with an evaluator from the dashboard, compare it against a baseline run, and — for prompts — feed it into the quality gate before promoting a version to production. DatasetsClient is the SDK interface for this workflow, available in both the TypeScript and Python SDKs with the same method names and behavior (Python uses snake_case). See Datasets for the dashboard-side concepts (creating datasets, versioning, scoring, comparing runs) that this page assumes.
There’s no separate “start” call — createRun/create_run is idempotent. Calling it again with the same run name (for example, the next time a scheduled job starts) re-attaches to the existing run instead of creating a duplicate, so linking is always additive.

Getting a DatasetsClient

Step 1 — Fetch the dataset’s items

getItems(datasetName) (TypeScript) / get_items(dataset_name) (Python) resolves the dataset by name and returns its items. Each item carries the input your pipeline should run, and — if the dataset has one — an expectedOutput for comparison-style evaluators.
string
required
The dataset’s name (not its id). Resolved to an id internally and cached in-memory for the lifetime of the DatasetsClient instance. Named dataset_name in Python.

Step 2 — Create (or re-attach to) the run

createRun(datasetName, runName, options?) (TypeScript) / create_run(dataset_name, run_name, description=None) (Python) creates a named run under the dataset, or returns the existing one if a run with that name already exists. The returned handle is what you call link() on.
string
required
The dataset to run against. Named dataset_name in Python.
string
required
A name for this run, unique within the dataset (e.g. a model + prompt version combination). Reusing a name re-attaches to the existing run instead of erroring. Named run_name in Python.
string
Optional human-readable description. In TypeScript this is a key on the third options object ({ description }); in Python it’s a plain keyword argument on create_run — the two SDKs shape this parameter differently.
For each item, call your own LLM or agent (traced the same way it always is — through a wrapped provider client, withAgent, etc.) and then call link(datasetItemId, traceId, observationId?) on the run handle with the trace ID that call produced. Pass observationId as well if you want to point at one span within the trace rather than the trace as a whole. The link call itself doesn’t need to know how the trace was produced — only its ID. The most direct way to know that ID ahead of time is to establish the trace context yourself with withZespanTrace (TypeScript) or with_zespan_context (Python) before calling your pipeline, rather than trying to read the ID back off a manually created span.
string
required
The id of the dataset item this trace answers. Named dataset_item_id in Python.
string
required
The trace ID your pipeline call produced. Named trace_id in Python.
string
Optional — points the link at a single span within the trace instead of the trace as a whole. Named observation_id in Python.
Re-linking the same datasetItemId on the same run updates the trace pointer rather than erroring — safe to call again if a step in your job fails partway through and retries.

Complete example

This example fetches a dataset’s items, creates (or re-attaches to) a run, runs a wrapped OpenAI call per item, and links every result.

Scoring and gating the run

Linking is the last thing the SDK does — scoring happens in the dashboard, against the linked traces:
1

Open the run

Open the dataset in Datasets, click the Runs tab, and find the run your job created (it’s created the first time your code calls createRun/create_run).
2

Score it

Pick an evaluator and click Score. Zespan looks up each linked trace and scores it, showing a per-item score and the run’s overall average.
3

Compare or gate

Compare two scored runs side by side from the Runs tab, or — for a prompt version — run this same dataset/run through the quality gate to get a pass/fail verdict against a baseline before promoting.
Scoring a run calls the evaluator’s LLM judge, which requires a project LLM connection. Without one, scoring fails with “No LLM connection configured — add one in Settings → LLM Connections.” Connect a provider key under LLM Connections first.

No-code alternative

If you don’t want to wire up the SDK loop above, the dashboard can execute the dataset run for you instead of your own code: the Run over dataset button, available from a prompt’s Versions tab and from a seeded Playground session, runs the candidate prompt version against every item in the dataset and links the results automatically. This still requires an LLM connection, since Zespan is making the model calls on your behalf in that path — unlike the SDK-driven workflow on this page, where your own code (and your own inference spend) produces the traces.

Next steps

  • Datasets — creating datasets, versioning, scoring, and comparing runs
  • Prompt management — fetch and compile the prompt version your pipeline is testing
  • LLM Connections — required to score a run or use the no-code Run over dataset button