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

# Datasets

> Upload a JSONL file or import a Hugging Face split, read the server's check, and delete.

A dataset is a JSONL file, one sample a line. The sample format is in [Data](https://docs.physionlabs.ai/nexcloud/guides/data.md#the-format);
images and videos are in [Images and videos](https://docs.physionlabs.ai/nexcloud/guides/media.md). An organisation keeps up to 50 datasets, 10 GB
a file.

## The dataset object

```json theme={null}
{
  "id": "ds_500e9ca27f404300",
  "name": "support-tickets train",
  "bytes": 51868,
  "state": "ready",
  "created": 1796332283.169084,
  "samples": 112,
  "est_tokens": 26583,
  "too_long": 0,
  "converted_from": null,
  "tools": 0,
  "estimated": false,
  "errors": [],
  "sample": false,
  "source": null,
  "validation": false,
  "kind": "chat",
  "images": null,
  "videos": null,
  "tokens": {
    "qwen3.5-4b": {
      "total": 10962,
      "max": 110,
      "over": { "32768": 0, "65536": 0, "131072": 0, "262144": 0, "1048576": 0 }
    }
  }
}
```

| Field | |
| - | - |
| `state` | `uploading`, `importing` (from Hugging Face), `checking`, then `ready` or `invalid` |
| `errors` | why an `invalid` dataset was refused, with line numbers |
| `samples` | the number of samples |
| `est_tokens` | the largest token count over all models; a job's estimate uses it |
| `tokens[model]` | `total` tokens, `max` (the longest sample), and `over`: how many samples are longer than each `max_seq_len` a job can pick. One entry per model; one is shown |
| `too_long` | samples over 65,536 tokens for at least one model |
| `estimated` | true for a file over 50 MB: the counts come from one sample in 100 until the first job measures them |
| `kind` | `chat`, `rl` (prompts with answers), `preference` (DPO pairs) or `images` |
| `images`, `videos` | file counts; null for text |
| `tools` | samples with tool calls |
| `sample` | a sample dataset every account can train on; it cannot be deleted |
| `validation` | marks the held-out sets among the sample datasets |
| `source`, `converted_from` | where a sample dataset comes from; the format an upload was converted from |

## Upload a file

Three requests: reserve the upload, send the file, ask for the check.

**1. Reserve**

`POST /v1/datasets` with the file's `name` and its size in `bytes`.

```bash theme={null}
curl https://nexcloud.physionlabs.ai/v1/datasets \
  -H "Authorization: Bearer $NEXTRON_API_KEY" -H "Content-Type: application/json" \
  -d '{"name": "support-tickets train", "bytes": 51868, "images": false}'
```

The answer is the dataset in `uploading`, with where to send the file:

```json theme={null}
{
  "id": "ds_500e9ca27f404300",
  "state": "uploading",
  "upload_url": "https://...",
  "upload_headers": { "Content-Type": "application/jsonl" }
}
```

A large file gets `part_urls` instead (a multipart upload, then complete); the SDK handles it.

**2. Send the file**

One `PUT` of the file to `upload_url`, with the `upload_headers`. No `Authorization` header on this one.

```bash theme={null}
curl -X PUT "$UPLOAD_URL" -H "Content-Type: application/jsonl" --data-binary @data/train.jsonl
```

**3. Complete**

`POST /v1/datasets/{id}/complete` starts the server's check and returns the dataset in `checking`.

```bash theme={null}
curl -X POST https://nexcloud.physionlabs.ai/v1/datasets/ds_500e9ca27f404300/complete \
  -H "Authorization: Bearer $NEXTRON_API_KEY"
```

**4. Wait for the check**

Poll `GET /v1/datasets/{id}` until `state` is `ready` or `invalid`. A small file takes a few seconds.

The SDK and the command line do all four, after checking the format locally:

```python Python theme={null}
dataset = client.datasets.upload("data/train.jsonl", name="support-tickets train")
dataset = client.datasets.wait(dataset.id)      # "ready", or "invalid" with dataset.errors
```

```bash CLI theme={null}
nextron-cloud datasets check data/train.jsonl    # the server's format check, locally
nextron-cloud datasets upload data/train.jsonl --name "support-tickets train"
```

`"images": true` means the upload is a bundle: a tar of the samples and the image and video files they name, as the
SDK writes it. Use the SDK or the command line for those.

## Import from Hugging Face

`POST /v1/datasets/huggingface/splits` lists a dataset's splits; `POST /v1/datasets/huggingface` imports one. The
split must already be in an [accepted format](https://docs.physionlabs.ai/nexcloud/guides/data.md#the-format). A gated or private dataset needs
`hf_token`.

```bash curl theme={null}
curl https://nexcloud.physionlabs.ai/v1/datasets/huggingface/splits \
  -H "Authorization: Bearer $NEXTRON_API_KEY" -H "Content-Type: application/json" \
  -d '{"url": "HuggingFaceH4/no_robots"}'

curl https://nexcloud.physionlabs.ai/v1/datasets/huggingface \
  -H "Authorization: Bearer $NEXTRON_API_KEY" -H "Content-Type: application/json" \
  -d '{"url": "HuggingFaceH4/no_robots", "config": "default", "split": "train", "name": "no-robots"}'
```

```python Python theme={null}
client.datasets.huggingface_splits("HuggingFaceH4/no_robots")
dataset = client.datasets.import_huggingface("HuggingFaceH4/no_robots", config="default", split="train")
dataset = client.datasets.wait(dataset.id)
```

```bash CLI theme={null}
nextron-cloud datasets splits HuggingFaceH4/no_robots
nextron-cloud datasets import HuggingFaceH4/no_robots --config default --split train
```

The splits:

```json theme={null}
{
  "repo": "HuggingFaceH4/no_robots",
  "splits": [
    { "config": "default", "split": "train", "rows": 9500, "bytes": 10474682 },
    { "config": "default", "split": "test", "rows": 500, "bytes": 570905 }
  ]
}
```

The import returns the dataset in `importing`; it goes on to `checking`, then `ready` or `invalid`.

## List and read

`GET /v1/datasets` returns your datasets and the sample datasets as a list; `GET /v1/datasets/{id}` returns one.

```bash curl theme={null}
curl https://nexcloud.physionlabs.ai/v1/datasets -H "Authorization: Bearer $NEXTRON_API_KEY"
curl https://nexcloud.physionlabs.ai/v1/datasets/ds_500e9ca27f404300 -H "Authorization: Bearer $NEXTRON_API_KEY"
```

```python Python theme={null}
client.datasets.list()
client.datasets.get("ds_500e9ca27f404300")
```

```bash CLI theme={null}
nextron-cloud datasets list              # --sample: the sample datasets only
nextron-cloud datasets get ds_500e9ca27f404300
```

## The batch a job would train with

`GET /v1/datasets/{id}/plan?model=...` says how a model would step through the dataset. Query parameters: `model`
(required), `layout`, `max_seq_len`, `batch_size`, `tokens_per_gpu`, `gradient_accumulation_steps`, `train_type`.

```bash theme={null}
curl "https://nexcloud.physionlabs.ai/v1/datasets/ds_500e9ca27f404300/plan?model=qwen3.5-4b&train_type=lora" \
  -H "Authorization: Bearer $NEXTRON_API_KEY"
```

The main fields of the answer:

```json theme={null}
{
  "layout": "1x8-h100",
  "gpus": 8,
  "samples": 112,
  "batch": 112,
  "pack_len": 131072,
  "min_batch": 112,
  "micro_steps": 1,
  "tokens_per_gpu": 10962,
  "steps_per_epoch": 1,
  "efficient": false,
  "fits": true
}
```

`batch` is the samples a step takes and `steps_per_epoch` what that gives. This dataset is smaller than one step, so
an epoch is one step; see [Small datasets](https://docs.physionlabs.ai/nexcloud/guides/training.md#small-datasets). The answer is 409 for an
`estimated` dataset before the model's first job.

## Download and delete

| Call | Does |
| - | - |
| `GET /v1/datasets/{id}/download` | `{"url": ...}`: a one-hour link to the file as training reads it |
| `DELETE /v1/datasets/{id}` | deletes it (204). 409 while an unfinished job uses it |

```bash curl theme={null}
curl https://nexcloud.physionlabs.ai/v1/datasets/ds_500e9ca27f404300/download -H "Authorization: Bearer $NEXTRON_API_KEY"
curl -X DELETE https://nexcloud.physionlabs.ai/v1/datasets/ds_500e9ca27f404300 -H "Authorization: Bearer $NEXTRON_API_KEY"
```

```python Python theme={null}
client.datasets.download_url("ds_500e9ca27f404300")
client.datasets.delete("ds_500e9ca27f404300")
```

```bash CLI theme={null}
nextron-cloud datasets download-url ds_500e9ca27f404300
nextron-cloud datasets delete ds_500e9ca27f404300
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.