> ## 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.

# Quick start

> From an API key to a finished fine-tuning job, on a sample dataset that comes with this page.

You will fine-tune a small model on 112 example support tickets, watch the job, and read its results. You do not need
your own data. The training costs a few cents, and you see the exact price before anything starts.

You need:

* a NexCloud account with some credit. Accounts are by invitation: write to
  [support@physionlabs.ai](mailto:support@physionlabs.ai) if you do not have one;
* a terminal on macOS or Linux, with [uv](https://docs.astral.sh/uv/getting-started/installation/) installed (it
  installs Python for you).

**1. Get an API key**

Sign in to the [console](https://nexcloud.physionlabs.ai) and open **API keys**. Create a key and copy it: it is
shown once. Only an owner of the organisation can create one.

Put it in your terminal:

```bash theme={null}
export NEXTRON_API_KEY="nk_live_..."
```

**2. Install and make the first call**

In an empty folder:

```bash theme={null}
uv venv && uv pip install --prerelease=allow nextron-cloud
uv run nextron-cloud me
```

You should see your organisation and its balance in US cents (`"credits": 5000` is \$50.00):

```json theme={null}
{
  "org": { "id": "org_1a2b3c4d5e6f7a8b", "name": "Acme Research", "role": "owner", "credits": 5000 }
}
```

An `invalid_api_key` error means the key was not copied whole, or `NEXTRON_API_KEY` is not set in this terminal.

**3. Get the sample dataset**

Download it, then split it into a training set and a small validation set:

```bash theme={null}
curl -O https://docs.physionlabs.ai/nexcloud/files/support-tickets.json
uv run nextron-cloud datasets prepare support-tickets.json --out-dir data
```

This writes `data/train.jsonl` (112 samples) and `data/val.jsonl` (12 samples). Each line is one conversation:
a made-up support ticket, and the answer the model should learn to give, as JSON with a category, a priority and
a reply.

```json theme={null}
{"messages": [
  {"role": "system", "content": "You are a support agent for Acme. Answer every ticket with a JSON object with the keys category, priority and reply."},
  {"role": "user", "content": "Urgent: How do I cancel Acme Teams? Please help."},
  {"role": "assistant", "content": "{\"category\": \"cancellation\", \"priority\": \"medium\", \"reply\": \"Open Settings > Billing > Cancel plan. You keep access until the end of the period you paid for.\"}"}
]}
```

**4. Upload it**

```bash theme={null}
uv run nextron-cloud datasets upload data/train.jsonl --name "quickstart train"
uv run nextron-cloud datasets upload data/val.jsonl --name "quickstart val"
```

Each command checks the file, uploads it and waits for the server's check. Note the two ids it prints
(`"id": "ds_..."`) and that `"state"` is `"ready"`.

**5. See the price**

Put your two dataset ids in place of `ds_TRAIN` and `ds_VAL`:

```bash theme={null}
uv run nextron-cloud jobs create --model qwen3.5-4b --dataset ds_TRAIN \
  --param train_type=lora --param learning_rate=1e-4 --param num_train_epochs=10 \
  --param val_dataset_id=ds_VAL --name "quickstart"
```

This starts nothing. It prints the estimate; the part to read:

```json theme={null}
{
  "estimate": { "tokens": 109620, "price_per_mtok": 20, "credits": 3, "enough": true, "steps": 10 },
  "created": false
}
```

`credits` is the price in US cents: 3 cents here. `steps` is how many training steps the job will take. The
`FEW_STEPS` warning is expected for a dataset this small.

**6. Start the job**

The same command with `--yes`:

```bash theme={null}
uv run nextron-cloud jobs create --model qwen3.5-4b --dataset ds_TRAIN \
  --param train_type=lora --param learning_rate=1e-4 --param num_train_epochs=10 \
  --param val_dataset_id=ds_VAL --name "quickstart" --yes
```

Note the job's id (`"id": "job_..."`).

**7. Watch it**

```bash theme={null}
uv run nextron-cloud jobs progress job_YOURS     # where it is now
uv run nextron-cloud jobs wait job_YOURS         # returns when training is over
```

`phase` goes from `queued` to `starting`, `loading`, `training` and `saving`. Once the job starts, it
takes about 4 minutes. While `phase` is `queued`, the job is waiting for free GPUs, and `jobs_ahead` says how many
jobs start before yours. The console's **Jobs** page shows the same.

**8. Read the results**

```bash theme={null}
uv run nextron-cloud report job_YOURS --table
uv run nextron-cloud jobs billing job_YOURS
```

* `state` should be `succeeded`.
* `loss` is how far the model's answers were from the training answers at the last step, and `best_val_loss` the
  same on the 12 samples it never trained on. Lower is better. When we ran this page, the loss fell from 1.59 at
  step 1 to 0.29 at step 10, and the validation loss from 1.24 to 0.37.
* `charged_credits` is what you paid, in US cents: 3 in our run.

That is a full fine-tuning job: data in, a trained model out.

## Get the model

The trained model is kept for 30 days. This job trained a LoRA adapter, which is small (about 150 MB):

```bash theme={null}
uv run nextron-cloud jobs wait-checkpoint job_YOURS
uv run nextron-cloud jobs download job_YOURS checkpoints/quickstart
```

To try it without downloading, start an [inference run](https://docs.physionlabs.ai/nexcloud/guides/inference.md) from the job. An inference run
is billed by GPU time, not by tokens: the start command prints the price first, and you must stop the run when you
are done.

## The same in Python

```python theme={null}
from nextron_cloud import NexTron
from nextron_cloud.data import prepare_file

client = NexTron()   # reads NEXTRON_API_KEY

prepare_file("support-tickets.json", "data")
train = client.datasets.wait(client.datasets.upload("data/train.jsonl", name="quickstart train").id)
val = client.datasets.wait(client.datasets.upload("data/val.jsonl", name="quickstart val").id)

draft = dict(
    model="qwen3.5-4b",
    dataset_id=train.id,
    params={"train_type": "lora", "learning_rate": 1e-4, "num_train_epochs": 10, "val_dataset_id": val.id},
)
quote = client.jobs.estimate(**draft)
print(f"${quote.credits / 100:.2f}", quote.steps, "steps")

job = client.jobs.create(**draft, name="quickstart")   # starts the job: this is the step that costs money
job = client.jobs.wait(job.id)
print(job.state, client.jobs.metrics(job.id)[-1], client.jobs.billing(job.id).charged_credits)
```

## Next

> [card] [Train on your own data](https://docs.physionlabs.ai/nexcloud/guides/data.md)
>
> The sample format, converting a CSV, and what the server checks.

> [card] [Pick a model and settings](https://docs.physionlabs.ai/nexcloud/guides/training.md)
>
> Models, parameters, cost and time, and how to plan a real run.

> [card] [API reference](https://docs.physionlabs.ai/nexcloud/api/overview.md)
>
> Every endpoint, with the matching Python and command-line call.

> [card] [Cookbook](https://github.com/Physion-Labs/nextron-cookbook)
>
> Tested recipes for chat, images, video, preference training and RL, with measured results.


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