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

# Dataset

## Dataset

```typescript theme={null}
type Dataset = {
  id: string;
  createdAt: string;
  name?: Maybe<string>;
  description?: Maybe<string>;
  metadata: Record<string, any>;
  items?: Maybe<DatasetItem[]>;
  type?: Maybe<DatasetType>
}
```

<ParamField path="id" type="string">
  The unique identifier of the dataset. This is an immutable field generated when the dataset is created.
</ParamField>

<ParamField path="createdAt" type="string">
  The date and time when the dataset was created, expressed in ISO 8601 format.
</ParamField>

<ParamField path="metadata" type="Record<string, any>">
  A dictionary containing additional data associated with the dataset. This can include user-defined key-value pairs that provide more context or details about the dataset.
</ParamField>

<ParamField path="name" type="Maybe<string>">
  An optional name for the dataset. This can be used to give a descriptive, human-readable title to the dataset for easier identification.
</ParamField>

<ParamField path="description" type="Maybe<string>">
  An optional description field that can provide more detailed information about the dataset, such as its purpose, contents, or specific characteristics.
</ParamField>

<ParamField path="items" type="Maybe<DatasetItem[]>">
  An optional list of items contained within the dataset. Each item in the list is a dictionary representing a specific data entry in the dataset.
</ParamField>

<ParamField path="type" type="Maybe<DatasetType>">
  An optional type of dataset. Defaults to "key\_value", other option is "generation".
</ParamField>

### Create a dataset

```typescript theme={null}
const dataset = await literalAiClient.api.createDataset({
    name: "Foo", 
    description: "A dataset to store samples.", 
    metadata: { isDemo: true },
});
```

#### Params

<ParamField path="dataset" type="DatasetInput">
  A partial representation of a dataset.
</ParamField>

<ParamField path="dataset.name" type="Maybe<string>">
  An optional name for the dataset. This can be used to give a descriptive, human-readable title to the dataset for easier identification.
</ParamField>

<ParamField path="dataset.description" type="Maybe<string>">
  An optional description field that can provide more detailed information about the dataset, such as its purpose, contents, or specific characteristics.
</ParamField>

<ParamField path="dataset.metadata" type="Maybe<Record<string, any>>">
  A dictionary containing additional data associated with the dataset. This can include user-defined key-value pairs that provide more context or details about the dataset.
</ParamField>

#### Response

<ResponseField name="dataset" type="Dataset">
  Return a Dataset
</ResponseField>

### Update a dataset

```typescript theme={null}
const dataset = await literalAiClient.api.updateDataset("dataset_id", {
  name: "Baz",
});
```

#### Params

<ParamField path="id" type="string">
  The unique identifier of the dataset. This is an immutable field generated when the dataset is created.
</ParamField>

<ParamField path="dataset" type="DatasetInput">
  A partial representation of a dataset.
</ParamField>

<ParamField path="dataset.name" type="Maybe<string>">
  An optional name for the dataset. This can be used to give a descriptive, human-readable title to the dataset for easier identification.
</ParamField>

<ParamField path="dataset.description" type="Maybe<string>">
  An optional description field that can provide more detailed information about the dataset, such as its purpose, contents, or specific characteristics.
</ParamField>

<ParamField path="dataset.metadata" type="Maybe<Record<string, any>>">
  A dictionary containing additional data associated with the dataset. This can include user-defined key-value pairs that provide more context or details about the dataset.
</ParamField>

#### Response

<ResponseField name="dataset" type="Dataset">
  Return a Dataset
</ResponseField>

### Get a dataset

```typescript theme={null}
const dataset = await literalAiClient.api.getDataset("dataset_id")
```

#### Params

<ParamField path="id" type="string">
  The unique identifier of the dataset. This is an immutable field generated when the dataset is created.
</ParamField>

#### Response

<ResponseField name="dataset" type="Dataset">
  Return a Dataset
</ResponseField>

### Delete a dataset

```typescript theme={null}
await literalAiClient.api.deleteDataset("dataset_id")
```

#### Params

<ParamField path="id" type="string">
  The unique identifier of the dataset. This is an immutable field generated when the dataset is created.
</ParamField>

#### Response

<ResponseField name="dataset" type="Dataset">
  Return a Dataset
</ResponseField>

## DatasetItem

```typescript theme={null}
type DatasetItem = {
  id: string;
  createdAt: string;
  datasetId: string;
  metadata: Record<string, any>;
  input: Record<string, any>;
  expectedOutput?: Maybe<Record<string, any>>;
  intermediarySteps: Record<string, any>[];
  stepId?: Maybe<string>;
}
```

<ParamField path="id" type="string">
  The unique identifier of the dataset item. Each item within a dataset has its own unique ID.
</ParamField>

<ParamField path="createdAt" type="string">
  The date and time when the dataset item was created, expressed in ISO 8601 format.
</ParamField>

<ParamField path="datasetId" type="string">
  The identifier of the dataset to which this item belongs. Links the item to its parent dataset.
</ParamField>

<ParamField path="metadata" type="Record<string, any>">
  A dictionary containing additional data associated with this dataset item. This can include specific details relevant to the item.
</ParamField>

<ParamField path="input" type="Record<string, any>">
  The input data for this dataset item. Typically contains the parameters or information that forms the LLM request.
</ParamField>

<ParamField path="expectedOutput" type="Maybe<Record<string, any>>">
  The optional output data for this dataset item. Represents the result or outcome associated with the item's input.
</ParamField>

<ParamField path="intermediarySteps" type="Record<string, any>[]">
  An optional list of intermediary steps involved in the output. This can include any processing steps or intermediate results. They are automatically generated when using "steps" to build a dataset.
</ParamField>

<ParamField path="stepId" type="Record<string, any>[]">
  The optional reference ID to a specific step.
</ParamField>

### Create a dataset item

```typescript theme={null}
const datasetItem = await literalAiClient.api.createDatasetItem("dataset_id", {
  input: { content: "What is Literal AI?" },
  expectedOutput: { content: "Literal AI is an observability solution." },
});

# Or directly through a Dataset
const datasetItem = await dataset.createDatasetItem("dataset_id", {
  input: { content: "What is Literal AI?" },
  expectedOutput: { content: "Literal AI is an observability solution." },
});
```

#### Params

<ParamField path="datasetId" type="string">
  The identifier of the dataset to which this item belongs.
</ParamField>

<ParamField path="datasetItem" type="DatasetItemInput">
  A partial representation of a dataset item.
</ParamField>

<ParamField path="datasetItem.input" type="Record<string, any>">
  The input data for this dataset item. Typically contains the parameters or information that forms the LLM request.
</ParamField>

<ParamField path="datasetItem.expectedOutput" type="Maybe<Record<string, any>>">
  The optional output data for this dataset item. Represents the result or outcome associated with the item's input.
</ParamField>

<ParamField path="datasetItem.metadata" type="Maybe<Record<string, any>>">
  A dictionary containing additional data associated with this dataset item. This can include specific details relevant to the item.
</ParamField>

#### Response

<ResponseField name="datasetItem" type="DatasetItem">
  Return a DatasetItem
</ResponseField>

### Add a step to a dataset

```typescript theme={null}
const datasetItem = await literalAiClient.api.addStepToDataset("dataset_id", "step_id");

# Or directly through a Dataset
const datasetItem = await dataset.addStep("step_id");
```

#### Params

<ParamField path="datasetId" type="string">
  The identifier of the dataset to which this item belongs.
</ParamField>

<ParamField path="stepId" type="string">
  The identifier of the step created beforehand.
</ParamField>

<ParamField path="metadata" type="Maybe<Record<string, any>>">
  A dictionary containing additional data associated with this dataset item. This can include specific details relevant to the item.
</ParamField>

#### Response

<ResponseField name="datasetItem" type="DatasetItem">
  Return a DatasetItem
</ResponseField>

### Add a generation to a dataset

```typescript theme={null}
const datasetItem = await literalAiClient.api.addGeneationToDataset("dataset_id", "generation_id");

# Or directly through a Dataset
const datasetItem = await dataset.addGeneration("generation_id");
```

#### Params

<ParamField path="datasetId" type="string">
  The identifier of the dataset to which this item belongs.
</ParamField>

<ParamField path="generationId" type="string">
  The identifier of the generation created beforehand.
</ParamField>

<ParamField path="metadata" type="Maybe<Record<string, any>>">
  A dictionary containing additional data associated with this dataset item. This can include specific details relevant to the item.
</ParamField>

#### Response

<ResponseField name="datasetItem" type="DatasetItem">
  Return a DatasetItem
</ResponseField>

### Get a dataset item

```typescript theme={null}
const datasetItem = await literalAiClient.api.getDatasetItem("dataset_item_id");
```

#### Params

<ParamField path="id" type="string">
  The unique identifier of the dataset item. Each item within a dataset has its own unique ID.
</ParamField>

#### Response

<ResponseField name="datasetItem" type="DatasetItem">
  Return a DatasetItem
</ResponseField>

### Delete a dataset item

```typescript theme={null}
await literalAiClient.api.deleteDatasetItem("dataset_item_id");

# Or directly through a Dataset
await dataset.deleteDatasetItem("dataset_item_id");
```

#### Params

<ParamField path="id" type="string">
  The unique identifier of the dataset item. Each item within a dataset has its own unique ID.
</ParamField>

#### Response

<ResponseField name="datasetItem" type="DatasetItem">
  Return a DatasetItem
</ResponseField>
