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

# Training jobs

> Estimate, start, watch and cancel a training job, and download its checkpoint.

A job is one whole training run: a model, a dataset and settings. One endpoint starts every managed method;
`params.train_type` picks it: `full` or `lora` (supervised fine-tuning), `dpo` (preference pairs) or `grpo`
(reinforcement fine-tuning).

## The request body

`POST /v1/training/estimate`, `POST /v1/training/plan` and `POST /v1/training/jobs` take the same body.

| Field | | |
| - | - | - |
| `model` | required | a model id from [`GET /v1/models`](https://docs.physionlabs.ai/nexcloud/api/account#models) |
| `dataset_id` | required | a `ready` dataset of the method's kind |
| `layout` | required | a GPU setup id, or `"auto"`: the smallest free one that trains the model. A larger setup picked by hand costs 5% more per size step. The SDK and the command line send `"auto"` unless you set one |
| `params` | optional | the training settings: every key, its default and its range are in [All endpoints](https://docs.physionlabs.ai/nexcloud/api/endpoints.md#params) |
| `name`, `tags` | optional | your label (up to 200 characters) and up to 20 tags of `A-Z a-z 0-9 _ . : = / + -` |
| `wandb` | optional | `{"api_key", "project", "entity"?, "run_name"?}`: also log to your Weights & Biases. The key is stored encrypted and never returned |

## Estimate

`POST /v1/training/estimate` starts nothing. It runs the checks a job would get and returns the price.

```bash curl theme={null}
curl https://nexcloud.physionlabs.ai/v1/training/estimate \
  -H "Authorization: Bearer $NEXTRON_API_KEY" -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.5-4b",
    "dataset_id": "ds_500e9ca27f404300",
    "layout": "auto",
    "params": {"train_type": "lora", "learning_rate": 1e-4, "num_train_epochs": 10}
  }'
```

```python Python theme={null}
quote = client.jobs.estimate(
    model="qwen3.5-4b",
    dataset_id="ds_500e9ca27f404300",
    params={"train_type": "lora", "learning_rate": 1e-4, "num_train_epochs": 10},
)
print(quote.credits / 100, quote.enough, quote.steps, quote.warnings)
```

```bash CLI theme={null}
nextron-cloud jobs estimate --model qwen3.5-4b --dataset ds_500e9ca27f404300 \
  --param train_type=lora --param learning_rate=1e-4 --param num_train_epochs=10
```

```json theme={null}
{
  "metered": true,
  "tokens": 109620,
  "price_per_mtok": 20,
  "credits": 3,
  "balance": 4520,
  "enough": true,
  "valid": true,
  "error": null,
  "steps": 10,
  "params": {
    "train_type": "lora",
    "learning_rate": 0.0001,
    "num_train_epochs": 10,
    "warmup_ratio": 0.03,
    "weight_decay": 0.1,
    "lr_scheduler_type": "cosine",
    "max_seq_len": 65536,
    "seed": 42,
    "lora_save": "adapter"
  },
  "warnings": [
    {
      "code": "FEW_STEPS",
      "text": "about 10 optimizer steps: warmup and the schedule are coarse; more epochs, a smaller batch size or more data give more"
    }
  ],
  "truncated_samples": 0,
  "video": null
}
```

| Field | |
| - | - |
| `credits` | what starting the job would hold from the balance, in US cents: `tokens` × `price_per_mtok`. When the job ends it is charged for the tokens it trained, and the rest is released |
| `balance`, `enough` | your balance, and whether it covers the hold |
| `metered` | false for a model without a price: the job is free |
| `valid`, `error` | whether a job with this body would be accepted. If not, the status is still 200, `valid` is false and `error` says why: a sentence, or a list naming each wrong field. The SDK raises `APIError` (422) then |
| `params` | the settings the job would run with, defaults filled in |
| `steps` | about how many optimizer steps; null for the large models with a tuned step |
| `truncated_samples` | samples longer than `max_seq_len` |
| `warnings` | `FEW_STEPS`, `SAMPLES_TRUNCATED` |
| `video` | the video settings, for a dataset with videos |

`POST /v1/training/plan` returns the checks without the price: `valid`, `params`, `steps`, `truncated_samples`,
`warnings`, and the dataset's `tokens` for the model. For a body a job would refuse it answers 422.

## Start a job

`POST /v1/training/jobs`. The job costs money from here: send the body you estimated. An `Idempotency-Key` header
makes the request safe to repeat (the same key with the same body returns the same job).

```bash curl theme={null}
curl https://nexcloud.physionlabs.ai/v1/training/jobs \
  -H "Authorization: Bearer $NEXTRON_API_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: support-lora-1" \
  -d '{
    "model": "qwen3.5-4b",
    "dataset_id": "ds_500e9ca27f404300",
    "layout": "auto",
    "params": {"train_type": "lora", "learning_rate": 1e-4, "num_train_epochs": 10},
    "name": "support lora",
    "tags": ["support-v1"]
  }'
```

```python Python theme={null}
job = client.jobs.create(
    model="qwen3.5-4b",
    dataset_id="ds_500e9ca27f404300",
    params={"train_type": "lora", "learning_rate": 1e-4, "num_train_epochs": 10},
    name="support lora",
    tags=["support-v1"],
    idempotency_key="support-lora-1",
)
```

```bash CLI theme={null}
# without --yes this prints the estimate and starts nothing (exit code 3)
nextron-cloud jobs create --model qwen3.5-4b --dataset ds_500e9ca27f404300 \
  --param train_type=lora --param learning_rate=1e-4 --param num_train_epochs=10 \
  --name "support lora" --tag support-v1 --yes
```

The answer is the job, in `queued`. Refusals: 402 when the balance does not cover the hold, 422 for a setting or data
the model does not take, 429 with 10 jobs already queued or running.

## The job object

`GET /v1/training/jobs/{id}` returns one job; `GET /v1/training/jobs` returns your organisation's jobs, newest first,
as a list.

```bash curl theme={null}
curl https://nexcloud.physionlabs.ai/v1/training/jobs/job_26c2f39989634135 \
  -H "Authorization: Bearer $NEXTRON_API_KEY"
```

```python Python theme={null}
job = client.jobs.get("job_26c2f39989634135")
jobs = client.jobs.list(tag="support-v1")
```

```bash CLI theme={null}
nextron-cloud jobs get job_26c2f39989634135
nextron-cloud jobs list --tag support-v1
```

```json theme={null}
{
  "id": "job_26c2f39989634135",
  "name": "support lora",
  "tags": [
    "support-v1"
  ],
  "state": "succeeded",
  "model": "qwen3.5-4b",
  "layout": "1x8-h100",
  "dataset_id": "ds_500e9ca27f404300",
  "params": {
    "train_type": "lora",
    "learning_rate": 0.0001,
    "num_train_epochs": 10,
    "warmup_ratio": 0.03,
    "weight_decay": 0.1,
    "lr_scheduler_type": "cosine",
    "max_seq_len": 65536,
    "seed": 42,
    "val_dataset_id": "ds_39ee1cba117e46f2",
    "eval_steps": 1,
    "lora_save": "adapter"
  },
  "created": 1796332300.12,
  "finished": 1796334079.93,
  "metrics": {
    "step": 10,
    "total_steps": 10,
    "loss": 0.2928,
    "step_time_s": 0.7,
    "tokens_per_s_per_gpu": 1891,
    "tokens_per_s_total": 15129,
    "ts": 1796334051
  },
  "checkpoint": {
    "status": "ready",
    "step": 10,
    "files": 8,
    "bytes": 149935866
  },
  "error": null,
  "tokens_trained": 109620,
  "notices": [
    {
      "level": "info",
      "code": "BATCH",
      "text": "Batch: about 112 samples per step (8 GPUs, each packing 128K tokens)"
    }
  ],
  "timeline": {
    "queued": 1796332300.12,
    "starting": 1796333850,
    "training": 1796333912,
    "trained": 1796334051,
    "saved": 1796334052,
    "done": 1796334095.43
  }
}
```

| Field | |
| - | - |
| `state` | `queued` → `submitting` → `pending` → `running` → `succeeded`, `failed` or `cancelled` |
| `metrics` | the latest step only; every step is in [metrics](#metrics) |
| `checkpoint` | `status` (`uploading`, then `ready`), `step`, `files`, `bytes`, once it is being saved |
| `error` | a short reason on a failed job; the cause is in `notices` and the [logs](#logs) |
| `tokens_trained` | what the job is charged for |
| `notices` | sentences worth reading, each with a `level` and a `code` (`SAMPLES_TRUNCATED`, `BATCH`, `GPU_OUT_OF_MEMORY`, ...) |
| `timeline` | Unix times of each stage; null until it happens |
| `config` | the training config the engine ran, as text, paths masked |
| `resumable_step` | on a failed job that saved while training: the step a [resumed job](https://docs.physionlabs.ai/nexcloud/guides/training.md#resume-a-failed-job) goes on from |

`timeline`, `notices`, `tokens_trained` and `config` come with one job, not with the list. What to look at while a
job runs, and what to do when one fails, is in [Monitoring](https://docs.physionlabs.ai/nexcloud/guides/monitoring.md).

## Progress

`GET /v1/training/jobs/{id}/progress` says where the job is in one answer.

```bash curl theme={null}
curl https://nexcloud.physionlabs.ai/v1/training/jobs/job_26c2f39989634135/progress \
  -H "Authorization: Bearer $NEXTRON_API_KEY"
```

```python Python theme={null}
p = client.jobs.progress("job_26c2f39989634135")
job = client.jobs.wait("job_26c2f39989634135")   # blocks until succeeded, failed or cancelled
```

```bash CLI theme={null}
nextron-cloud jobs progress job_26c2f39989634135
nextron-cloud jobs wait job_26c2f39989634135
```

```json theme={null}
{
  "id": "job_26c2f39989634135",
  "state": "succeeded",
  "phase": "done",
  "jobs_ahead": null,
  "training": {
    "step": 10,
    "total_steps": 10,
    "fraction": 1.0,
    "seconds_per_step": 0.7,
    "eta_seconds": 0,
    "loss": 0.2928
  },
  "checkpoint": {
    "status": "ready",
    "stage": null,
    "bytes_total": null,
    "bytes_done": null,
    "uploads_ahead": null,
    "eta_seconds": null
  },
  "timeline": {
    "queued": 1796332300.12,
    "starting": 1796333850.0,
    "training": 1796333912.0,
    "trained": 1796334051.0,
    "saved": 1796334052.0,
    "done": 1796334095.43
  },
  "last_activity": 1796334095.77,
  "idle_seconds": 32
}
```

`phase` goes `queued` → `starting` → `loading` → `training` → `saving` → `checkpoint_queued` →
`checkpoint_preparing` → `checkpoint_uploading` → `done`, or `failed` / `cancelled`. `jobs_ahead` counts the queued
jobs that start before this one.

## Events

`GET /v1/training/jobs/{id}/events?after=&limit=` returns what happened, in order. Pass the last `seq` you saw as
`after` to read on.

```bash curl theme={null}
curl "https://nexcloud.physionlabs.ai/v1/training/jobs/job_26c2f39989634135/events?after=0&limit=6" \
  -H "Authorization: Bearer $NEXTRON_API_KEY"
```

```python Python theme={null}
for event in client.jobs.events("job_26c2f39989634135", follow=True):   # until training is over
    print(event.type, event.data)
```

```bash CLI theme={null}
nextron-cloud jobs events job_26c2f39989634135 --follow
```

```json theme={null}
{
  "events": [
    {"seq": 1, "ts": 1796332300.12, "type": "job.state", "data": {"state": "queued"}},
    {"seq": 2, "ts": 1796333791.72, "type": "job.state", "data": {"state": "submitting", "layout": "1x8-h100"}},
    {"seq": 3, "ts": 1796333800.5, "type": "job.state", "data": {"state": "pending"}},
    {"seq": 4, "ts": 1796333852.58, "type": "job.state", "data": {"state": "running"}},
    {"seq": 5, "ts": 1796334041.0, "type": "training.step", "data": {"step": 1, "total_steps": 10, "loss": 1.5888, "step_time_s": 129.0}},
    {"seq": 6, "ts": 1796334042.0, "type": "training.validation", "data": {"step": 1, "val_loss": 1.2445}}
  ],
  "next_cursor": 6
}
```

Event types: `job.state`, `job.cancel_requested`, `training.step`, `training.validation` (`step`, `val_loss`),
`training.rollout` (GRPO, one a round) and `checkpoint.stage` (`queued`, `converting`, `hashing`, `transferring`,
`ready`).

## Metrics

`GET /v1/training/jobs/{id}/metrics` returns one point per step so far, as a list.

```bash curl theme={null}
curl https://nexcloud.physionlabs.ai/v1/training/jobs/job_26c2f39989634135/metrics \
  -H "Authorization: Bearer $NEXTRON_API_KEY"
```

```python Python theme={null}
points = client.jobs.metrics("job_26c2f39989634135")
print(points[-1].loss, points[-1].val_loss)
```

```bash CLI theme={null}
nextron-cloud jobs metrics job_26c2f39989634135
nextron-cloud report job_26c2f39989634135 --table   # one row per job: steps, loss, best val_loss, tokens, minutes
```

```json theme={null}
[
  {
    "step": 10,
    "total_steps": 10,
    "loss": 0.2928,
    "ts": 1796334051.0,
    "lr": 0.0,
    "step_time_s": 0.7,
    "tokens_per_s_per_gpu": 1891,
    "tokens_per_s_total": 15129,
    "samples": 112,
    "real_tokens": 10962,
    "trained_tokens": 4820,
    "padding_tokens": 302,
    "val_loss": 0.3682
  }
]
```

`real_tokens` is every token of the step's samples, which is what is billed; `trained_tokens` is the assistant tokens
the loss is computed on. `val_loss` appears on the steps where the validation set ran. A GRPO job adds the reward
fields ([Reinforcement fine-tuning](https://docs.physionlabs.ai/nexcloud/guides/reinforcement-fine-tuning.md#watch)).

## Logs

`GET /v1/training/jobs/{id}/logs?cursor=&limit=` returns `{"lines": [{"seq", "ts", "line"}], "next_cursor"}`. Pass
`next_cursor` back as `cursor` to read on.

```bash curl theme={null}
curl "https://nexcloud.physionlabs.ai/v1/training/jobs/job_26c2f39989634135/logs?limit=200" \
  -H "Authorization: Bearer $NEXTRON_API_KEY"
```

```python Python theme={null}
for line in client.jobs.logs("job_26c2f39989634135", follow=True):
    print(line.line)
```

```bash CLI theme={null}
nextron-cloud jobs logs job_26c2f39989634135 --follow
```

## Billing

`GET /v1/training/jobs/{id}/billing` shows what the job held and what it was charged.

```bash curl theme={null}
curl https://nexcloud.physionlabs.ai/v1/training/jobs/job_26c2f39989634135/billing \
  -H "Authorization: Bearer $NEXTRON_API_KEY"
```

```python Python theme={null}
bill = client.jobs.billing("job_26c2f39989634135")
print(bill.charged_credits / 100)
```

```bash CLI theme={null}
nextron-cloud jobs billing job_26c2f39989634135
```

```json theme={null}
{
  "job_id": "job_26c2f39989634135",
  "state": "succeeded",
  "billing": "settled",
  "price_per_mtok": 20,
  "tokens_charged": 109620,
  "held_credits": 3,
  "charged_credits": 3,
  "settled_at": 1796334080
}
```

`billing` is `held` while the job runs, then `settled`, `released` (nothing charged) or `not_metered`. A failed job is
free; a cancelled one pays for the tokens trained before it stopped. The charge is rounded up to a whole cent.

## Cancel

`POST /v1/training/jobs/{id}/cancel`. A queued job is cancelled at once; a running one stops soon after and leaves no
checkpoint.

```bash curl theme={null}
curl -X POST https://nexcloud.physionlabs.ai/v1/training/jobs/job_26c2f39989634135/cancel \
  -H "Authorization: Bearer $NEXTRON_API_KEY"
```

```python Python theme={null}
client.jobs.cancel("job_26c2f39989634135")
```

```bash CLI theme={null}
nextron-cloud jobs cancel job_26c2f39989634135
```

## Download the checkpoint

The checkpoint uploads after training succeeds and stays for 30 days. `GET /v1/training/jobs/{id}/checkpoint` lists
its files, each with a link that works for 24 hours.

```bash curl theme={null}
curl https://nexcloud.physionlabs.ai/v1/training/jobs/job_26c2f39989634135/checkpoint \
  -H "Authorization: Bearer $NEXTRON_API_KEY"
```

```python Python theme={null}
client.jobs.wait_checkpoint("job_26c2f39989634135")
client.jobs.download_checkpoint("job_26c2f39989634135", "checkpoints/job_26c2f39989634135")   # checks every sha256
```

```bash CLI theme={null}
nextron-cloud jobs wait-checkpoint job_26c2f39989634135
nextron-cloud jobs download job_26c2f39989634135 checkpoints/job_26c2f39989634135
```

```json theme={null}
{
  "step": 10,
  "bytes": 149935866,
  "expires": 1798926095.43,
  "files": [
    {"name": "adapter_config.json", "bytes": 437, "sha256": "184aa8389ac5933bc2d4e9fb6834c707e531b0ae181445b17e8de0c4ca2d9449", "url": "https://..."},
    {"name": "adapter_model.safetensors", "bytes": 129934944, "sha256": "83dca4ba99094e28988ee4f7a69a0960348d6465bb55d0c998db2e1659beb843", "url": "https://..."}
  ]
}
```

Two of this checkpoint's eight files are shown. 409 means it is still uploading; 410 means the 30 days are over. What the files are, and how to serve them, is in
[Checkpoints](https://docs.physionlabs.ai/nexcloud/guides/checkpoints.md).

## The job's record

| Call | Returns |
| - | - |
| `GET /v1/training/jobs/{id}/manifest` | the sha256 of every record and checkpoint file (409 until the checkpoint is uploaded) |
| `GET /v1/training/jobs/{id}/export` | the whole record as a zip: job, config, logs, metrics, GPU telemetry, manifest |
| `GET /v1/training/jobs/{id}/trace` | a per-rank Chrome trace |
| `GET /v1/training/jobs/{id}/telemetry` | GPU and host utilisation while it trained |

In the SDK: `jobs.manifest(id)`, `jobs.export(id, dest)`, `jobs.trace(id)`, `jobs.telemetry(id)`; on the command line
`nextron-cloud jobs export ID DEST`.


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