Training runs

Training runs

Record a model while it trains: a run's batches of points, its heartbeat, files, stop and finish, and the run itself.

A run is one training of a model: its config, environment and code version, the series it logged (losses, metrics, learning rates, hardware load and per-layer statistics), its events, console output and files, and the health findings Kaimei and the client raise about it. The Python client writes runs for you (kaimei.init; see Kaimei Training). These routes are what it calls, and what a dashboard or a script reads back.

A run's id is made by the client, so a run can be written to its journal on disk before the network is up and created once. Every point carries a step and a time in epoch milliseconds; run timestamps are ISO 8601. Numbers that are not finite travel as the strings "NaN", "Infinity" and "-Infinity", both ways; a bare NaN or Infinity in a request is read too.

API keys need the runs scope (runs:read to read). Viewers and reviewers read runs and change nothing (403 read_only_role). The plan sets how many runs start and how many are imported each month, how many are live at once, and how many points, bytes, checkpoints and landscapes they hold; see limits. Everything a run stores counts in the workspace's training storage: its points and files, and its own values (config, environment, module tree, notes, tags, summary values, the client's findings). Past it, creating or changing a run is 403 quota_exceeded (param: training_storage); finishing one never is.

#The run object

GET /v1/runs/{run_id} returns all of it. A list leaves out config, environment and module_tree (unless include=config), keeps in summary only the primary metric, val/loss and the keys asked for with columns, and adds a sparkline.

Attributes

idstring
run_ and 8 to 64 lowercase letters or digits, made by the client.
namestring

Given, or made up when the run starts, such as bright-falcon-12.

project / modelobject | null
{id, slug, name} of the project the run belongs to and of the model it produced, once linked.
group / job_type / tags / notes

Your own grouping and words.

statusstring
running, finished, failed, crashed or stopped. A live run that misses five heartbeats (150 seconds without a batch or a heartbeat) is crashed, and back to running when it is heard from again.
syncstring
live, after or offline: how the client sends it. Only a live run can be marked crashed.
sourcestring
sdk, autolog, import, mlflow, tensorboard or wandb.
framework / detailstring | null

The training framework, and how much the client captured inside the network: metrics, standard, full or max.

started_at / ended_at / last_seen_attimestamp
last_seen_at is the last batch or heartbeat.
duration_secondsnumber

From start to end, or to the last time it was heard from.

steps / points / bytes / series_count / writersinteger

The highest step, the points stored, what the run takes in storage (its points and files, and its own values such as config, notes and the client's findings), the number of series, and the processes that wrote them.

primary_metricstring | null

The series the lists chart: train/loss, else loss, another training loss, any loss, or the first scalar.

summaryobject

Each scalar series' last, last_step, min, max, best, best_step, count and goal (min, max or none), and beside them the client's own summary values.

sparklinearray of numbers

Lists only: up to 48 values of the primary metric across the run.

stop_requested / liveboolean

Someone asked the run to stop; the run is running, sent live, and was heard from in the last 5 minutes.

findingsobject

Open findings: open and a count by severity.

parent_run_id / imported_from / exit

The run this one is nested under; {tool, id, url} of the run an import copied; {code, exception, message, traceback} of how the process ended.

created_byobject | null
{id, name} of the person whose key or session started it.
cursorstring

Changes whenever anything about the run does. GET …/updates?since= takes it.

config / environment / module_treeobject

Hyperparameters; what the client captured (Python, OS, CPU and GPUs, packages, git, and datasets, the datasets the run declared); the network's modules with their parameters' names and shapes, never weights.

GET /v1/runs/{run_id} response
{
  "object": "run",
  "id": "run_3f2a19c0d1e2f3a4b5c6",
  "name": "bright-falcon-12",
  "project": {
    "id": "prj_d28a961cfec4c14af1e9",
    "slug": "credit-risk",
    "name": "credit-risk"
  },
  "model": null,
  "group": null,
  "job_type": null,
  "tags": ["baseline"],
  "notes": null,
  "status": "running",
  "sync": "live",
  "source": "sdk",
  "framework": "pytorch",
  "detail": "standard",
  "started_at": "2026-12-05T12:00:00.000000+00:00",
  "ended_at": null,
  "last_seen_at": "2026-12-05T12:01:00.285428+00:00",
  "created_at": "2026-12-05T12:00:00.000000+00:00",
  "updated_at": "2026-12-05T12:01:00.249239+00:00",
  "duration_seconds": 60.285,
  "steps": 1200,
  "points": 22,
  "bytes": 1792,
  "series_count": 5,
  "writers": 1,
  "primary_metric": "train/loss",
  "summary": {
    "opt/lr": {
      "last": 0.0005,
      "last_step": 1200,
      "min": 0.0005,
      "max": 0.001,
      "best": null,
      "best_step": null,
      "count": 2,
      "goal": "none"
    },
    "train/loss": {
      "last": 0.52,
      "last_step": 1200,
      "min": 0.52,
      "max": 2.31,
      "best": 0.52,
      "best_step": 1200,
      "count": 12,
      "goal": "min"
    },
    "val/loss": {
      "last": 0.74,
      "last_step": 1200,
      "min": 0.71,
      "max": 0.98,
      "best": 0.71,
      "best_step": 800,
      "count": 3,
      "goal": "min"
    }
  },
  "stop_requested": false,
  "live": true,
  "findings": {
    "open": 1,
    "critical": 0,
    "high": 1,
    "medium": 0,
    "low": 0,
    "info": 0
  },
  "parent_run_id": null,
  "imported_from": null,
  "exit": null,
  "created_by": {
    "id": "usr_2c27309f0aa9af60b2ff",
    "name": "Ada Lovelace"
  },
  "cursor": "v2",
  "config": {
    "lr": 0.001,
    "batch_size": 256,
    "optimizer": "AdamW",
    "epochs": 3
  },
  "environment": {
    "python": "3.11.9",
    "os": "Linux-6.5.0-x86_64",
    "gpus": [
      {"name": "NVIDIA A10G"}
    ],
    "git": {
      "commit": "4f2a19c",
      "branch": "main",
      "dirty": false
    },
    "datasets": [
      {"name": "train", "fingerprint": "sha256:9c1e0b"}
    ]
  },
  "module_tree": null
}

#Create or resume a run

POST/v1/runsAPI key or session

Start a run, or answer with the run its id already names in this workspace. kaimei.init calls it once, so a client that retries after a timeout gets the same run back. The same id in another workspace is 409 run_id_taken.

Counts against the runs started this month (403 quota_exceeded, param: training_runs) and the runs live at once (training_live_runs). An import (source: "import") counts against the runs imported this month instead (training_imports), and its checkpoints get no model. Past the training storage, param: training_storage.

Body parameters

idstringoptional
run_ and 8 to 64 lowercase letters or digits. Left out, the API makes one.
projectstringoptional

A project's slug, id or name. One that doesn't exist is made, within the plan's projects. Left out, the run belongs to no project.

namestringoptional

Up to 200 characters. Left out: an adjective, a noun and a number.

group / job_typestringoptional

Up to 120 characters each: runs of one sweep or cross-validation, and what kind of job each is.

tagsarray of stringsoptional

notesstringoptional

Up to 20,000 characters.

configobjectoptional

Hyperparameters and settings. The client masks values under secret-looking names, such as api_key or password, before they leave the machine.

syncstringoptionaldefault "live"
live, after or offline; see sync modes.
sourcestringoptionaldefault "sdk"
sdk, autolog, import, mlflow, tensorboard or wandb.
frameworkstringoptional

Such as pytorch, keras or xgboost.

detailstringoptionaldefault "standard"
metrics, standard, full or max.
environmentobjectoptional
python, os, cpu, gpus, memory_bytes, packages, frameworks, git (commit, branch, remote, dirty), argv, host, and datasets: [{name, fingerprint, …}], which the training record lists.
module_treeobjectoptional
{version, framework, param_count, modules}, each module {name, type, parent, params} with its parameters' names, shapes and whether they train. At most 2 MB.
parent_run_idstringoptional

The run this one is nested under.

started_attimestampoptional

Left out: now. An import passes the original time.

resumebooleanoptionaldefault false

With an id this workspace already has: set that run running again.

imported_fromobjectoptional
{tool, id, url} of the run an import copied, up to 64 KB.

Returns

The run. 201 when it is new; 200 with the run as it is when the id is already this workspace's.
import kaimei

run = kaimei.init(project="credit-risk", name="bright-falcon-12", tags=["baseline"],
                  config={"lr": 0.001, "batch_size": 256, "optimizer": "AdamW", "epochs": 3})
print(run.id)        # run_3f2a19c0d1e2f3a4b5c6
curl -X POST https://api.kaimei.ai/v1/runs \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"id": "run_3f2a19c0d1e2f3a4b5c6", "project": "credit-risk", "name": "bright-falcon-12",
       "config": {"lr": 0.001, "batch_size": 256}, "framework": "pytorch"}'
201 CreatedResponse
{
  "object": "run",
  "id": "run_3f2a19c0d1e2f3a4b5c6",
  "name": "bright-falcon-12",
  "project": {
    "id": "prj_d28a961cfec4c14af1e9",
    "slug": "credit-risk",
    "name": "credit-risk"
  },
  "model": null,
  "group": null,
  "job_type": null,
  "tags": ["baseline"],
  "notes": null,
  "status": "running",
  "sync": "live",
  "source": "sdk",
  "framework": "pytorch",
  "detail": "standard",
  "started_at": "2026-12-05T12:00:00.000000+00:00",
  "ended_at": null,
  "last_seen_at": "2026-12-05T12:00:00.000000+00:00",
  "created_at": "2026-12-05T12:00:00.000000+00:00",
  "updated_at": "2026-12-05T12:00:00.000000+00:00",
  "duration_seconds": 60.234,
  "steps": null,
  "points": 0,
  "bytes": 0,
  "series_count": 0,
  "writers": 0,
  "primary_metric": null,
  "summary": {},
  "stop_requested": false,
  "live": true,
  "findings": {
    "open": 0,
    "critical": 0,
    "high": 0,
    "medium": 0,
    "low": 0,
    "info": 0
  },
  "parent_run_id": null,
  "imported_from": null,
  "exit": null,
  "created_by": {
    "id": "usr_2c27309f0aa9af60b2ff",
    "name": "Ada Lovelace"
  },
  "cursor": "v1",
  "config": {
    "lr": 0.001,
    "batch_size": 256,
    "optimizer": "AdamW",
    "epochs": 3
  },
  "environment": …,
  "module_tree": null
}

#List runs

GET/v1/runsAPI key or session

Runs of the workspace, newest first, each with its primary metric's sparkline.

Query parameters

projectstringoptional

A project's slug, id or name.

modelstringoptional

A model's slug or id: the runs linked to it.

statusstringoptional

Comma separated: running, finished, failed, crashed, stopped.

group / tag / sourcestringoptional

One group, one tag, one source.

livebooleanoptional
true: only runs live now.
qstringoptional

Matches the name, an id prefix or a tag.

columnsstringoptional

Comma-separated series keys whose statistics go in each run's summary.

includestringoptional
config adds config, environment and module_tree.
sortstringoptionaldefault "-created_at"
created_at, -created_at, name, -last_seen_at or -duration.
limitintegeroptionaldefault 50

1 to 200.

offsetintegeroptionaldefault 0

Runs to skip.

cursorstringoptional

The next_cursor of the page before.

Returns

A page of runs.
for run in client.runs.iterate(project="credit-risk", status="finished", columns=["val/auc"]):
    print(run.name, run.summary["val/auc"]["best"])

live = client.runs.list(live=True)
curl https://api.kaimei.ai/v1/runs?project=credit-risk&columns=val/auc&limit=50 \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "object": "list",
  "data": [
    {
      "object": "run",
      "id": "run_3f2a19c0d1e2f3a4b5c6",
      "name": "bright-falcon-12",
      "project": {
        "id": "prj_d28a961cfec4c14af1e9",
        "slug": "credit-risk",
        "name": "credit-risk"
      },
      "model": null,
      "group": null,
      "job_type": null,
      "tags": ["baseline"],
      "notes": null,
      "status": "running",
      "sync": "live",
      "source": "sdk",
      "framework": "pytorch",
      "detail": "standard",
      "started_at": "2026-12-05T12:00:00.000000+00:00",
      "ended_at": null,
      "last_seen_at": "2026-12-05T12:01:00.285428+00:00",
      "created_at": "2026-12-05T12:00:00.000000+00:00",
      "updated_at": "2026-12-05T12:01:00.249239+00:00",
      "duration_seconds": 60.285,
      "steps": 1200,
      "points": 22,
      "bytes": 1792,
      "series_count": 5,
      "writers": 1,
      "primary_metric": "train/loss",
      "summary": {
        "train/loss": {
          "last": 0.52,
          "last_step": 1200,
          "min": 0.52,
          "max": 2.31,
          "best": 0.52,
          "best_step": 1200,
          "count": 12,
          "goal": "min"
        },
        "val/loss": {
          "last": 0.74,
          "last_step": 1200,
          "min": 0.71,
          "max": 0.98,
          "best": 0.71,
          "best_step": 800,
          "count": 3,
          "goal": "min"
        }
      },
      "stop_requested": false,
      "live": true,
      "findings": {
        "open": 1,
        "critical": 0,
        "high": 1,
        "medium": 0,
        "low": 0,
        "info": 0
      },
      "parent_run_id": null,
      "imported_from": null,
      "exit": null,
      "created_by": {
        "id": "usr_2c27309f0aa9af60b2ff",
        "name": "Ada Lovelace"
      },
      "cursor": "v2",
      "sparkline": [
        2.31, 1.62, 1.18, 0.94, 0.81, 0.72, 0.66, 0.61, 0.58,
        0.55, 0.53, 0.52
      ]
    },
    …
  ],
  "total": 14,
  "limit": 50,
  "offset": 0,
  "has_more": false,
  "next_cursor": null
}

#Retrieve a run

GET/v1/runs/{run_id}API key or session

The run with its config, environment, module tree, and the statistics of every scalar series in summary.

Path parameters

run_idstringrequired

The run's id: run_ and 8 to 64 lowercase letters or digits.

Returns

The run.
run = client.runs.retrieve("run_3f2a19c0d1e2f3a4b5c6")
print(run.status, run.summary["val/loss"]["best"], run.config["lr"])
curl https://api.kaimei.ai/v1/runs/run_3f2a19c0d1e2f3a4b5c6 \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "object": "run",
  "id": "run_3f2a19c0d1e2f3a4b5c6",
  "name": "bright-falcon-12",
  "project": {
    "id": "prj_d28a961cfec4c14af1e9",
    "slug": "credit-risk",
    "name": "credit-risk"
  },
  "model": null,
  "group": null,
  "job_type": null,
  "tags": ["baseline"],
  "notes": null,
  "status": "running",
  "sync": "live",
  "source": "sdk",
  "framework": "pytorch",
  "detail": "standard",
  "started_at": "2026-12-05T12:00:00.000000+00:00",
  "ended_at": null,
  "last_seen_at": "2026-12-05T12:01:00.285428+00:00",
  "created_at": "2026-12-05T12:00:00.000000+00:00",
  "updated_at": "2026-12-05T12:01:00.249239+00:00",
  "duration_seconds": 60.285,
  "steps": 1200,
  "points": 22,
  "bytes": 1792,
  "series_count": 5,
  "writers": 1,
  "primary_metric": "train/loss",
  "summary": {
    "train/loss": {
      "last": 0.52,
      "last_step": 1200,
      "min": 0.52,
      "max": 2.31,
      "best": 0.52,
      "best_step": 1200,
      "count": 12,
      "goal": "min"
    },
    "val/loss": {
      "last": 0.74,
      "last_step": 1200,
      "min": 0.71,
      "max": 0.98,
      "best": 0.71,
      "best_step": 800,
      "count": 3,
      "goal": "min"
    },
    …: …
  },
  "stop_requested": false,
  "live": true,
  "findings": {
    "open": 1,
    "critical": 0,
    "high": 1,
    "medium": 0,
    "low": 0,
    "info": 0
  },
  "parent_run_id": null,
  "imported_from": null,
  "exit": null,
  "created_by": {
    "id": "usr_2c27309f0aa9af60b2ff",
    "name": "Ada Lovelace"
  },
  "cursor": "v2",
  "config": {
    "lr": 0.001,
    "batch_size": 256,
    "optimizer": "AdamW",
    "epochs": 3
  },
  "environment": {
    "python": "3.11.9",
    "os": "Linux-6.5.0-x86_64",
    "gpus": [
      {"name": "NVIDIA A10G"}
    ],
    "git": {
      "commit": "4f2a19c",
      "branch": "main",
      "dirty": false
    },
    "datasets": [
      {"name": "train", "fingerprint": "sha256:9c1e0b"}
    ]
  },
  "module_tree": null
}

#Update a run

PATCH/v1/runs/{run_id}API key or session

Rename, tag, annotate or link a run. Only the fields sent change. A change that would take the workspace past its training storage is 403 quota_exceeded and changes nothing.

Path parameters

run_idstringrequired

The run's id: run_ and 8 to 64 lowercase letters or digits.

Body parameters

name / group / job_type / notesstringoptional

As when creating a run.

tagsarray of stringsoptional

The new tags, in place of the old ones.

projectstring | nulloptional

A project's slug, id or name, or null for none.

modelstring | nulloptional

A model's slug or id to link the run to (the model it produced), or null to unlink.

config / environmentobjectoptional

Merged into what the run holds, key by key at the top level.

module_treeobjectoptional

In place of the one it has.

frameworkstring | nulloptional

The training framework, for an adapter that learns it after the run was made; null clears it.

detailstringoptional

The detail level the run captures at: metrics, standard, full or max. run.watch(detail=...) sends it when it changes the level after the run was made; null keeps the level.

Returns

The run.
client.runs.update("run_3f2a19c0d1e2f3a4b5c6", notes="Baseline for the Q4 retrain.", tags=["baseline", "q4"])
curl -X PATCH https://api.kaimei.ai/v1/runs/run_3f2a19c0d1e2f3a4b5c6 \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"notes": "Baseline for the Q4 retrain.", "tags": ["baseline", "q4"]}'
200 OKResponse
{
  "object": "run",
  "id": "run_3f2a19c0d1e2f3a4b5c6",
  "name": "bright-falcon-12",
  "tags": ["baseline", "q4"],
  "notes": "Baseline for the Q4 retrain.",
  "status": "running",
  "updated_at": "2026-12-05T12:01:00.521047+00:00",
  …: …
}

#Delete a run

DELETE/v1/runs/{run_id}API key or session

Delete the run and everything recorded for it: series, events, logs, files, findings, landscapes, probe results, the hidden models of its checkpoints, and what an MLflow client stored with it. A legal hold on one of its checkpoint models keeps it (409 record_held). The deletion is in the audit log.

Path parameters

run_idstringrequired

The run's id: run_ and 8 to 64 lowercase letters or digits.

Returns

A deletion receipt.
client.runs.delete("run_3f2a19c0d1e2f3a4b5c6")
curl -X DELETE https://api.kaimei.ai/v1/runs/run_3f2a19c0d1e2f3a4b5c6 \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "id": "run_3f2a19c0d1e2f3a4b5c6",
  "object": "run",
  "deleted": true
}

#Record a batch

POST/v1/runs/{run_id}/recordsAPI key or session

One batch of what a training process recorded: scalar points, per-layer matrices, distributions, events, console lines, the client's own findings, series goals and summary values. It is stored exactly once: each writer (a process writing the run) numbers its batches from 1, a batch whose seq was already stored is answered duplicate: true and changes nothing, and one that skips a number is 409 seq_gap with the expected one, so the client resends from there. A refused batch does not use up its number.

JSON, optionally with Content-Encoding: gzip: at most 100,000 points and 8 MB as sent (64 MB unpacked), else 413 batch_too_large. A point is a scalar value, a distribution row, or a cell of a matrix. A run keeps its newest 1,000 of the client's findings (older ones are deleted; the batch is never refused for them), and its summary values take at most 1 MB together (400 invalid_records, param: summary; the client then sends the batch again without them). Batches are taken in any status, so an after run uploads before it finishes and kaimei sync sends a crashed run's tail. Over the month's points, the storage or 10,000 series a run is 403 quota_exceeded (param training_points, training_storage or training_series); faster than the plan's points a second is 429 rate_limited with Retry-After.

Path parameters

run_idstringrequired

The run's id: run_ and 8 to 64 lowercase letters or digits.

Headers

Content-Encodingstringoptional
gzip (or x-gzip) for a compressed body. Any other encoding is 415 unsupported_encoding, refused before the body is read.

Body parameters

writerstringrequired

Who writes: wr_ and 16 hex digits, one per process.

seqintegerrequired

1 for the writer's first batch, then one more each time.

rank / world_size / hostoptional

Where the writer runs, for distributed training.

scalarsarrayoptional
{key, step: [...], time: [...], value: [...]}, the three lists the same length.
matricesarrayoptional

Per-layer measures: {key, layers: [names], step, time, values: [[one value a layer], …]}. A matrix's layers may grow from batch to batch.

distributionsarrayoptional
{key, step, time, quantiles: [[9 values], …], hist: [{edges: [65], counts: [64]} | null, …]}, the quantiles at 0, 1, 5, 25, 50, 75, 95, 99 and 100%.
eventsarrayoptional
{kind, step, time, payload}. kind is epoch, eval, checkpoint, lr_change, resume, exception, note, auto_stop, stop_requested, governor, sync or custom; a custom event names itself in payload.name, such as hardest_examples.
consolearrayoptional
{t, step, stream, text}, stream stdout or stderr.
findingsarrayoptional

The client's findings: {detector, severity, title, summary, step_lo, step_hi, evidence, advice, layer}. Its five mirrored health checks update the run's open finding of the same check and layer; run.alert() sends detector: "custom", matched by title and never resolved by Kaimei.

definesarrayoptional
{key, goal, unit}: whether lower or higher is better for a series (min, max or none).
summaryobjectoptional

The client's own summary values, kept beside the series' statistics.

heartbeatbooleanoptional

This batch also counts as a heartbeat.

Returns

accepted_seq, duplicate, stop_requested, the findings made or changed since the writer's last batch, points_left this month (null without a limit), and the run's cursor.
curl -X POST https://api.kaimei.ai/v1/runs/run_3f2a19c0d1e2f3a4b5c6/records \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"writer": "wr_7d2c9e1f0a3b4c5d", "seq": 1,
       "scalars": [{"key": "train/loss", "step": [100, 200], "time": [1796472005000, 1796472010000], "value": [2.31, 1.62]}],
       "events": [{"kind": "epoch", "step": 400, "time": 1796472020000, "payload": {"epoch": 1}}],
       "findings": [{"detector": "custom", "severity": "high", "title": "Validation AUC below 0.7", "summary": "val/auc is 0.66 at step 1200."}],
       "heartbeat": true}'
200 OKResponse
{
  "accepted_seq": 1,
  "duplicate": false,
  "stop_requested": false,
  "findings": [
    {
      "object": "finding",
      "id": "fnd_8057422bb9588d65c631",
      "run_id": "run_3f2a19c0d1e2f3a4b5c6",
      "detector": "custom",
      "severity": "high",
      "state": "open",
      "layer": null,
      "step_lo": 1200,
      "step_hi": 1200,
      "title": "Validation AUC below 0.7",
      "summary": "val/auc is 0.66 at step 1200.",
      "evidence": {},
      "advice": null,
      "source": "client",
      "note": null,
      "created_at": "2026-12-05T12:01:00.249239+00:00",
      "updated_at": "2026-12-05T12:01:00.249239+00:00",
      "resolved_at": null
    }
  ],
  "points_left": null,
  "cursor": "v2"
}
200 OKThe same batch again
{
  "accepted_seq": 1,
  "duplicate": true,
  "stop_requested": false,
  "findings": [],
  "points_left": null,
  "cursor": "v2"
}
409 Conflictseq skipped
{
  "error": {
    "type": "conflict_error",
    "message": "This writer's next batch is 2, and this one is 3. Send the batches in order, starting from the expected one.",
    "code": "seq_gap",
    "param": "seq",
    "details": {"expected": 2, "received": 3},
    "expected": 2
  }
}

#Send a heartbeat

POST/v1/runs/{run_id}/heartbeatAPI key or session

A live run's writer is still there. The client sends one every 30 seconds when no batch went out. Five missed (150 seconds with no batch and no heartbeat) mark a live run crashed; the next batch or heartbeat sets it back to running. Runs sent after or offline, and runs an MLflow client records, are never marked crashed.

Path parameters

run_idstringrequired

The run's id: run_ and 8 to 64 lowercase letters or digits.

Body parameters

writerstringrequired

The writer's id.

Returns

stop_requested, the findings made or changed since the writer last heard, and the run's cursor.
curl -X POST https://api.kaimei.ai/v1/runs/run_3f2a19c0d1e2f3a4b5c6/heartbeat \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"writer": "wr_7d2c9e1f0a3b4c5d"}'
200 OKResponse
{
  "stop_requested": false,
  "findings": [],
  "cursor": "v2"
}

#Finish a run

POST/v1/runs/{run_id}/finishAPI key or session

End the run. run.finish() calls it, and so does the client when the program exits with the run still open (failed if it died of an exception).

Path parameters

run_idstringrequired

The run's id: run_ and 8 to 64 lowercase letters or digits.

Body parameters

statusstringoptionaldefault "finished"
finished, failed, stopped or crashed.
ended_attimestampoptional

Left out: now.

exitobjectoptional
{code, exception, message, traceback}.
summaryobjectoptional

Summary values to keep, such as best_epoch. A run's summary values take at most 1 MB together (400 value_too_large, param: summary).

modelstringoptional

The slug or id of a model in this workspace that the run produced: links them, and puts the run's training record in the model's evidence.

Returns

The run.
run.finish(model="credit-risk")      # links the run to the registered model
curl -X POST https://api.kaimei.ai/v1/runs/run_3f2a19c0d1e2f3a4b5c6/finish \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"status": "finished", "summary": {"best_epoch": 2}, "model": "credit-risk"}'
200 OKResponse
{
  "object": "run",
  "id": "run_3f2a19c0d1e2f3a4b5c6",
  "name": "bright-falcon-12",
  "status": "finished",
  "ended_at": "2026-12-05T12:01:00.898001+00:00",
  "duration_seconds": 60.898,
  "exit": null,
  "live": false,
  …: …
}

#Ask a run to stop

POST/v1/runs/{run_id}/stopAPI key or session

The run's next batch or heartbeat answers stop_requested: true: run.stop_requested turns true and every framework adapter stops its loop cleanly. Recorded as a stop_requested event. An alert rule with stop_run asks the same.

Path parameters

run_idstringrequired

The run's id: run_ and 8 to 64 lowercase letters or digits.

Body parameters

reasonstringoptional

Up to 2,000 characters, shown with the event.

Returns

The run, with stop_requested: true. The body may be left out.
client.runs.stop("run_3f2a19c0d1e2f3a4b5c6", reason="validation loss rising")
curl -X POST https://api.kaimei.ai/v1/runs/run_3f2a19c0d1e2f3a4b5c6/stop \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason": "validation loss rising"}'
200 OKResponse
{
  "object": "run",
  "id": "run_3f2a19c0d1e2f3a4b5c6",
  "name": "bright-falcon-12",
  "status": "running",
  "stop_requested": true,
  "live": true,
  …: …
}

#Attach a file

POST/v1/runs/{run_id}/filesAPI key or session

An image, a text, a table, a code diff or any file, at a step. multipart/form-data, at most 16 MB (413 file_too_large). The client sends kaimei.Image, kaimei.Text and kaimei.Table values this way, a probe set's inputs as probes/<name>/inputs when asked to (send_inputs=True), the git diff as code/diff, and MLflow artifacts as kind artifact.

Path parameters

run_idstringrequired

The run's id: run_ and 8 to 64 lowercase letters or digits.

Body parameters

filefilerequired

The content.

kindstringoptional
media, text, table, code, artifact or other.
keystringoptional

What it is, such as samples/predictions; files under one key form a series by step.

namestringoptional

Left out: the uploaded file's name.

stepintegeroptional

The step it belongs to.

Returns

The file: id, kind, key, name, step, size, sha256, content_type, created_at. 201.
run.log({"samples/predictions": kaimei.Table(frame)}, step=400)
curl https://api.kaimei.ai/v1/runs/run_3f2a19c0d1e2f3a4b5c6/files \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -F kind=text -F key=notes -F step=400 \
  -F [email protected]
201 CreatedResponse
{
  "object": "run_file",
  "id": "rfl_2d9df83180f57573fb55",
  "kind": "text",
  "key": "notes",
  "name": "notes.txt",
  "step": 400,
  "size": 23,
  "sha256": "03567ace5ca0491f8771a8f239ed65b40a553dcb1ec417d2e925f677c5e7b91f",
  "content_type": "text/plain",
  "created_at": "2026-12-05T12:01:00.509665+00:00"
}

#List a run's files

GET/v1/runs/{run_id}/filesAPI key or session

Every file of the run, filtered by kind or key.

Path parameters

run_idstringrequired

The run's id: run_ and 8 to 64 lowercase letters or digits.

Query parameters

kindstringoptional

One kind.

keystringoptional

One key.

Returns

A list of files.
curl https://api.kaimei.ai/v1/runs/run_3f2a19c0d1e2f3a4b5c6/files?kind=text \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "object": "list",
  "data": [
    {
      "object": "run_file",
      "id": "rfl_2d9df83180f57573fb55",
      "kind": "text",
      "key": "notes",
      "name": "notes.txt",
      "step": 400,
      "size": 23,
      "sha256": "03567ace5ca0491f8771a8f239ed65b40a553dcb1ec417d2e925f677c5e7b91f",
      "content_type": "text/plain",
      "created_at": "2026-12-05T12:01:00.509665+00:00"
    }
  ]
}

#Download a run's file

GET/v1/runs/{run_id}/files/{file_id}/contentAPI key or session

The file's bytes, as an attachment with its content type.

Path parameters

run_idstringrequired

The run's id: run_ and 8 to 64 lowercase letters or digits.

file_idstringrequired
rfl_ identifier.

Returns

The file.
curl https://api.kaimei.ai/v1/runs/run_3f2a19c0d1e2f3a4b5c6/files/rfl_2d9df83180f57573fb55/content \
  -H "Authorization: Bearer $KAIMEI_API_KEY" --output notes.txt

#Export a run

GET/v1/runs/{run_id}/exportAPI key or session

Everything about the run as a zip: run.json, series/<key>.csv (step, time, value), layers/<measure>.csv, distributions/<key>.jsonl, events.jsonl, findings.jsonl, logs.jsonl, landscapes/<id>.json, checkpoints.jsonl, probes/<probe set>.json and .jsonl (the set, then one evaluation a line), mlflow.json for a run an MLflow client recorded, and files/index.json. Keys are made safe as file names. The export is in the audit log.

kaimei export RUN --format parquet turns it into JSON Lines, CSV or Parquet.

Path parameters

run_idstringrequired

The run's id: run_ and 8 to 64 lowercase letters or digits.

Returns

application/zip.
client.runs.export("run_3f2a19c0d1e2f3a4b5c6", "bright-falcon-12.zip")
curl https://api.kaimei.ai/v1/runs/run_3f2a19c0d1e2f3a4b5c6/export \
  -H "Authorization: Bearer $KAIMEI_API_KEY" --output bright-falcon-12.zip