> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zespan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Compare two dataset runs

> Compare two runs of a dataset. Returns each dataset item shared by both runs with each run's trace id and score side by side, plus each run's average score over the shared items.




## OpenAPI

````yaml /api-reference/openapi.yaml get /v1/datasets/{datasetId}/runs/compare
openapi: 3.1.0
info:
  title: Zespan Public API
  version: 1.0.0
  description: >
    The Zespan Public API covers the endpoints that customers call directly or
    through the Zespan SDKs: trace ingestion (native and OpenTelemetry), prompt
    management, datasets and dataset runs, and the runtime guardrails check.

    All endpoints authenticate with a project API key sent in the `x-api-key`
    header. Create and manage API keys from the project settings in the Zespan
    dashboard.
servers:
  - url: https://api.zespan.com
    description: Zespan production API
security:
  - ApiKeyAuth: []
tags:
  - name: Ingestion
    description: Send traces and events to Zespan.
  - name: OpenTelemetry
    description: OTLP-compatible ingestion endpoints.
  - name: Prompts
    description: Manage versioned prompts and their labels, tags, and folders.
  - name: Datasets
    description: Read datasets and manage dataset runs used for experiments and scoring.
  - name: Guardrails
    description: Runtime guardrail evaluation.
paths:
  /v1/datasets/{datasetId}/runs/compare:
    get:
      tags:
        - Datasets
      summary: Compare two dataset runs
      description: >
        Compare two runs of a dataset. Returns each dataset item shared by both
        runs with each run's trace id and score side by side, plus each run's
        average score over the shared items.
      operationId: compareDatasetRuns
      parameters:
        - $ref: '#/components/parameters/DatasetId'
        - name: a
          in: query
          required: true
          schema:
            type: string
            format: uuid
          description: First run id.
        - name: b
          in: query
          required: true
          schema:
            type: string
            format: uuid
          description: Second run id.
        - $ref: '#/components/parameters/ProjectIdQuery'
      responses:
        '200':
          description: Comparison result.
          content:
            application/json:
              schema:
                type: object
                properties:
                  runA:
                    $ref: '#/components/schemas/DatasetRunCompareSide'
                  runB:
                    $ref: '#/components/schemas/DatasetRunCompareSide'
                  rows:
                    type: array
                    items:
                      type: object
                      properties:
                        datasetItemId:
                          type: string
                          format: uuid
                        input: {}
                        a:
                          $ref: '#/components/schemas/DatasetRunCompareCell'
                        b:
                          $ref: '#/components/schemas/DatasetRunCompareCell'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    DatasetId:
      name: datasetId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Dataset id.
    ProjectIdQuery:
      name: projectId
      in: query
      required: false
      schema:
        type: string
        format: uuid
      description: >
        Project id. Optional and ignored when authenticating with an API key,
        since the key already scopes the request to one project.
  schemas:
    DatasetRunCompareSide:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        avgScore:
          type: number
          nullable: true
    DatasetRunCompareCell:
      type: object
      properties:
        traceId:
          type: string
        score:
          type: number
          nullable: true
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
          example: Unauthorized
        code:
          type: string
          description: Machine-readable error code, when present.
          example: rate_limit_exceeded
      required:
        - error
  responses:
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Project API key. Manage keys in the Zespan dashboard under project
        settings.

````