Skip to main content
The datasets functions are currently in BETA. The API may change without notice. A one-time warning is emitted on first use.

List Datasets

import { listDatasets } from "@arizeai/ax-client";

const { data: datasets, pagination } = await listDatasets({
  space: "my-space",   // space name or ID (optional)
  name: "qa",          // substring filter on dataset name (optional)
  limit: 10,
});

Create a Dataset

import { createDataset } from "@arizeai/ax-client";

const dataset = await createDataset({
  space: "my-space",  // space name or ID
  name: "your_dataset_name",
  examples: [{ question: "What is 2+2?", answer: "4", topic: "math" }],
});

Get a Dataset

import { getDataset } from "@arizeai/ax-client";

// By ID
const dataset = await getDataset({ dataset: "your_dataset_id" });

// By name (requires space)
const dataset = await getDataset({ dataset: "my-dataset", space: "my-space" });

Update a Dataset

Rename a dataset. The new name must be unique within the space.
import { updateDataset } from "@arizeai/ax-client";

const dataset = await updateDataset({
  dataset: "my-dataset",  // dataset name or ID
  space: "my-space",      // required when dataset is a name
  name: "my-renamed-dataset",
});

Delete a Dataset

import { deleteDataset } from "@arizeai/ax-client";

// By ID
await deleteDataset({ dataset: "your_dataset_id" });

// By name (requires space)
await deleteDataset({ dataset: "my-dataset", space: "my-space" });

List Dataset Examples

import { listDatasetExamples } from "@arizeai/ax-client";

const examples = await listDatasetExamples({
  dataset: "your_dataset_id",
  datasetVersionId: "your_dataset_version_id",  // optional
  limit: 10,
});

Append Examples

import { appendExamples } from "@arizeai/ax-client";

const result = await appendExamples({
  dataset: "my-dataset",  // dataset name or ID
  space: "my-space",      // required when dataset is a name
  examples: [
    { question: "What is 3+3?", answer: "6", topic: "math" },
  ],
});
console.log(result.exampleIds); // IDs of the inserted examples

Update Dataset Examples

import { updateExamples } from "@arizeai/ax-client";

const result = await updateExamples({
  dataset: "my-dataset",  // dataset name or ID
  space: "my-space",      // required when dataset is a name
  examples: [
    {
      id: "your_example_id",
      question: "What is 2+2?",
      answer: "4",
      topic: "math",
    },
  ],
  newVersionName: "v2",  // optional: create a new version instead of updating in place
});
console.log(result.exampleIds); // IDs of the updated examples

Annotate Dataset Examples

Write human annotations to a batch of examples in a dataset. Annotations are upserted by annotation config name for each example; submitting the same name for the same example overwrites the previous value. Up to 1000 examples may be annotated per request.
import { annotateDatasetExamples } from "@arizeai/ax-client";

await annotateDatasetExamples({
  dataset: "my-dataset",  // dataset name or ID
  space: "my-space",      // required when dataset is a name
  annotations: [
    {
      recordId: "your_example_id",
      values: [
        { name: "quality", score: 0.9 },
        { name: "topic", label: "science" },
      ],
    },
  ],
});