Skip to main content
POST
/
v1
/
fit
import os, json, requests

# Define your dataset path
train_path = "train.csv"

# Get your API key from the environment
api_key = os.getenv("PRIORLABS_API_KEY")
headers = {"Authorization": f"Bearer {api_key}"}

# Upload your training dataset to /v1/fit
payload = {
"task": "classification",
"schema": {
"target": "churn",
"description": "Customer churn dataset"
}
}

files = {
"data": (None, json.dumps(payload), "application/json"),
"dataset_file": (train_path, open(train_path, "rb")),
}

fit_response = requests.post(
"https://api.priorlabs.ai/v1/fit",
headers=headers,
files=files,
)

model_id = fit_response.json().get("model_id")
print(f"✅ Model trained: {model_id}")
{
"model_id": "123e4567-e89b-12d3-a456-426614174000",
"task": "classification"
}

Authorizations

Authorization
string
header
required

Bearer token for authentication, obtained after signing up and generating an API key.

Body

multipart/form-data
  • Option 1
  • Option 2
data
string
required

A JSON string defining the training configuration.

Supported Systems:

  • ["preprocessing"] - Applies skrub preprocessing,
  • ["text"] - Adds text embeddings for text columns.

Default: ["preprocessing", "text"].

Supported Config Parameters:

  • n_estimators (int, 1-10) - Number of ensemble estimators,
  • softmax_temperature (float) - Temperature for softmax scaling,
  • average_before_softmax (bool) - Average before softmax,
  • ignore_pretraining_limits (bool) - Ignore pretraining limits,
  • random_state (int) - Random seed for reproducibility.
dataset_file
file
required

Option 1: CSV file containing both features (X_train) and labels (y_train). Use this when you have all data in a single file.

features_file
file

Option 2:: CSV file containing only feature columns (X_train). Must be used together with labels_file.

labels_file
file

Option 2: CSV file containing only the target/label column (y_train). Must be used together with features_file.

Response

Model fitted successfully — returns a model ID for later prediction calls.

model_id
string<uuid>
required

Unique identifier for the fitted model (used for prediction calls).

task
enum<string>
required

Specifies the type of task to perform — either classification or regression.

Available options:
classification,
regression