# Datasets Keep versioned sets of inputs and expected outputs, import them from files or traces, and read them from code. A dataset is a versioned collection of inputs, with an expected output when you have one, that you run [experiments](https://cetra.sh/docs/evaluation/experiments/) on. ## Items A dataset item has: - `input`: any JSON value (required); - `expected_output`: any JSON value (optional); - `metadata`: an object of your own fields. A dataset has a name of 1 to 200 characters that is unique in the project, and an optional description. A dataset holds up to 50,000 items, and one item can be up to 1 MiB. Wherever a page or an API route takes a dataset, you can give its name or its ID. ## Versions Every change to a dataset's items makes a new version: adding a batch, editing or deleting an item, an import, or adding from a trace. A new dataset is at version 0 with no items. A change that changes nothing makes no version. Reads use the latest version unless you ask for another one. Past versions are read-only. An experiment pins the version it ran on, so you can always compare results with the data they ran against. ## Create a dataset in the UI 1. Open **Datasets** and select **New dataset**. 2. Enter a name, a description and, optionally, JSON Schemas for the input and the expected output. 3. Add items with **Add item**, or const client = new Client(); // the key and URL come from the environment let dataset = await client.datasets.create("faq-v1", { description: "FAQ questions" }); dataset = await dataset.addItems([ { input: { q: "How do I cancel?" }, expectedOutput: { a: "Settings > Billing > Cancel" }, metadata: { topic: "billing" }, }, ]); dataset = await client.datasets.get("faq-v1", { version: 1 }); // the items of version 1 console.log((await client.datasets.list()).map((info) => info.name)); await client.datasets.delete("faq-v1"); // the dataset and its items ``` - Any key other than the three item fields is refused before a request is sent. - `add_items` (`addItems` in TypeScript) sends batches of 1,000 items, and each batch makes a new version. It returns the dataset at its latest version. If a later batch fails, the earlier batches stay stored. - `get` without a version reads the current one. - `create` also takes `input_schema` and `expected_schema` (`inputSchema` and `expectedSchema` in TypeScript). A refused item raises an `ApiError` whose `errors` list names the failing fields. The same operations are available over the REST API under `/api/v1/projects/{project}/datasets`: ```bash curl -H "Authorization: Bearer " \ "http://localhost:8080/api/v1/projects/current/datasets/faq-v1/items?version=1" ```