> This page is for version v4.0.
> For other versions, use one of these documentation indexes:
> - v5.0 (default): https://humanloop.com/docs/v5/llms.txt
> - v4.0: https://humanloop.com/docs/v4/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://humanloop.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://humanloop.com/docs/_mcp/server.

> Learn how to create Datasets in Humanloop to define fixed examples for your projects, and build up a collection of input-output pairs for evaluation and fine-tuning.

You can currently create Datasets in Humanloop in three ways: from existing **logs**, by uploading a **CSV** or via the **API**.

# Create a Dataset from Logs

Prerequisites:

* A [Prompt](/docs/explanation/prompts) in Humanloop
* Some [Logs](./generate-and-log-with-the-sdk) available in that Prompt

To create a Dataset from existing Logs:

### Go to the **Logs** tab

### Select a subset of the Logs

### Choose **Add to Dataset**

In the menu in the top right of the page, select **Add to dataset**.

![Select some logs and then click \*\*Add to Dataset\*\*](/docs/_fern-img/419dd764f7b5452bc3fc7421838fa3a5c09c47277742474ba01aa3e86b5cfb2e.webp)

### Add to a new or existing Dataset

Provide a name of the new dataset and click **Create**, or you can click **add to existing dataset** to append the selected to a dataset you already have.

# Upload data from CSV

Prerequisites:

* A [Prompt](/docs/explanation/prompts) in Humanloop

To create a dataset from a CSV file, we'll first create a CSV in Google Sheets and then upload it to a dataset in Humanloop.

### Create a CSV file.

* In our Google Sheets example below, we have a column called `user_query` which is an input to a prompt variable of that name. So in our model config, we'll need to include `{{ user_query }}` somewhere, and that placeholder will be populated with the value from the `user_query` input in the datapoint at generation-time.
* You can include as many columns of prompt variables as you need for your model configs.
* There is additionally a column called `target` which will populate the target of the datapoint. In this case, we use simple strings to define the target.
* Note: `messages` are harder to incorporate into a CSV file as they tend to be verbose and hard-to-read JSON. If you want a dataset with messages, consider using the API to upload, or convert from existing logs.

![A CSV file in Google Sheets defining a collection of 9 datapoints.](/docs/_fern-img/346ec171ede357009e83f4d99c7c27a5fb45602a4ebbc87abe56e31338fe487a.webp)

### Export the Google Sheet to CSV

Choose **File** → **Download** → **Comma-separated values (.csv)**

### Create a new Dataset File

### Click **Upload CSV**

Uupload the CSV file from step 2 by drag-and-drop or using the file explorer.

![Uploading a CSV file to create a dataset.](/docs/_fern-img/e8199e6b2fc5403e8bb38bf1bc409d26d5d81e92d9b381e9ed06ec26ebe58cd4.webp)

### Click **Upload Dataset from CSV**

You should see a new dataset appear in the datasets tab. You can explore it by clicking in.

### Follow the link in the pop-up to inspect the dataset that was created in the upload.

You'll see a column with the input key-value pairs for each datapoint, a messages column (in our case we didn't use messages, so they're all empty) and a target column with the expected model output.

![](/docs/_fern-img/66432aca4daeba0cdf2c8c61b9cd220b7a809b631de18ac87fc7c26de9e52aca.webp)

# Upload via API

#### Install and initialize the SDK

First you need to install and initialize the SDK. If you have already done this, skip to the next section.

Open up your terminal and follow these steps:

1. Install the Humanloop SDK:

```python
pip install humanloop
```

```typescript
npm install humanloop
```

2. Initialize the SDK with your Humanloop API key (you can get it from the [Organization Settings page](https://app.humanloop.com/account/api-keys)).

```python
from humanloop import Humanloop
humanloop = Humanloop(api_key="<YOUR HUMANLOOP KEY>")

# Check that the authentication was successful
print(humanloop.prompts.list())
```

```typescript
import { HumanloopClient, Humanloop } from "humanloop";

const humanloop = new HumanloopClient({ apiKey: "YOUR_API_KEY" });

// Check that the authentication was successful
console.log(await humanloop.prompts.list());
```

### First define some sample data

This should consist of user messages and target extraction pairs. This is where you could load up any existing data you wish to use for your evaluation:

**`Python`**

```python Python
# Example test case data
data = [
    {
        "messages": [
            {
                "role": "user",
                "content": "Hi Humanloop support team, I'm having trouble understanding how to use the evaluations feature in your software. Can you provide a step-by-step guide or any resources to help me get started?",
            }
        ],
        "target": {"feature": "evaluations", "issue": "needs step-by-step guide"},
        "inputs": {},
    },
    {
        "messages": [
            {
                "role": "user",
                "content": "Hi there, I'm interested in fine-tuning a language model using your software. Can you explain the process and provide any best practices or guidelines?",
            }
        ],
        "target": {
            "feature": "fine-tuning",
            "issue": "process explanation and best practices",
        },
        "inputs": {},
    },
]
```

### Then define a dataset and upload the datapoints

**`Python`**

```python Python
# Create a dataset
dataset = humanloop.datasets.create(
    project_id=project_id,
    name="Sample dataset",
    description="Examples of featue requests extracted from user messages",
)
dataset_id = dataset.id

# Create datapoints for the dataset
datapoints = humanloop.datasets.create_datapoint(
    dataset_id=dataset_id,
    body=data,
)
```

On the datasets tab in your Humanloop project you will now see the dataset you just uploaded via the API.

![](/docs/_fern-img/23d6f651c73081e388e277eb178d34c4fc2bf392cc484f1c3c99ac09d4445730.webp)