Skip to main content

Custom Training

Page Outline

Custom Models Only

This endpoint is only applicable to models with model_type: "custom". It is not available for AutoML (model_type: "auto") models.

Triggers a custom training pipeline for a model, executing the user-supplied training script against the linked dataset within a sandboxed execution environment.

Base Path: /api/v1/models

Method: POST

Path: /{model_id}/custom/train

Auth: Requires a valid Bearer token (Authorization: Bearer <JWT>)

Path Parameters

ParameterTypeDescription
model_idstringUnique identifier of the custom model

Request Body

{
"entry_point": "train.py",
"runtime": "python3.11",
"environment_vars": {
"LEARNING_RATE": "0.001",
"EPOCHS": "50"
},
"compute": {
"cpu_cores": 4,
"memory_gb": 16,
"gpu": false
},
"run_label": "custom-run-experiment-1",
"timeout_seconds": 14400
}
FieldTypeRequiredDescription
entry_pointstringFilename of the uploaded script asset to execute (must match an uploaded asset_type: "script" asset)
runtimestringExecution runtime: python3.10, python3.11, python3.12
environment_varsobjectKey-value environment variables passed to the training script
compute.cpu_coresintegerNumber of CPU cores to allocate (default: 2, max: 32)
compute.memory_gbintegerRAM in GB to allocate (default: 8, max: 128)
compute.gpubooleanIf true, a GPU worker is requested (subject to availability)
run_labelstringHuman-readable label for this training run
timeout_secondsintegerMax execution time before auto-cancellation (default: 7200, max: 86400)

Behavior

  • Requires at least one uploaded asset_type: "script" asset. Returns HTTP 422 if none exist.
  • The training script operates within a sandboxed container. It receives the linked dataset path via the DATASET_PATH environment variable.
  • The script is expected to write the serialized model artifact to the path specified in the MODEL_OUTPUT_PATH environment variable; otherwise no version is created upon completion.
  • Model status transitions to training immediately upon a successful submission.
  • Returns HTTP 409 if a training run is already in progress.
  • An audit log entry is written with action model.custom_training_started.
  • Poll progress via the Get Metrics or Get Logs endpoints using the returned run_id.

Response

Returns a CustomTrainingRun object.

{
"run_id": "run-custom-20260313-f7e2a1",
"model_id": "mdl-7f3a19bc",
"model_type": "custom",
"status": "queued",
"entry_point": "train.py",
"runtime": "python3.11",
"compute": {
"cpu_cores": 4,
"memory_gb": 16,
"gpu": false
},
"run_label": "custom-run-experiment-1",
"created_at": "2026-03-13T16:10:00Z",
"estimated_start_time": "2026-03-13T16:12:00Z"
}