Train a model
POST /v1/models
apiKeyX-Spavik-Api-Key<token>Spavik integration API key (sk-spv-api-...), sent in X-Spavik-Api-Key.
Idempotency-Key?stringSame workspace, method, path, key and payload prevent another execution or charge, subject to current model access. Successful responses are replayed for every data policy, including ZDR, from the technical PostgreSQL cache (default retention 24 hours from operation creation). The data policy only controls inference input/output archiving to GCS/BigQuery; it never changes replay behavior. A different key or an expired completed key starts a new operation and may be charged again. REQUEST_IN_PROGRESS: wait Retry-After. REQUEST_INTERRUPTED: outcome uncertain; contact support. IDEMPOTENCY_RESPONSE_UNAVAILABLE: a completed response is missing; do not retry with a new key. Completed keys expire; unresolved keys remain protected. Reusing a key with different input returns 422. A key is required on the original call for safe retries.
User-Agent?stringInformation about the agent originating the request, when known. Browsers supply their own value. Optional diagnostic metadata, declared by the caller and never used for authorization. Omit unknown values. Values are trimmed and truncated to the documented length.
length <= 1024X-Spavik-Client-Name?stringHTTP caller: SDK, MCP server or direct application (for example spavik-sdk-python, spavik-sdk-javascript or spavik-mcp). Optional diagnostic metadata, declared by the caller and never used for authorization. Omit unknown values. Values are trimmed and truncated to the documented length.
length <= 128X-Spavik-Client-Version?stringVersion of that SDK, MCP server or direct application. Optional diagnostic metadata, declared by the caller and never used for authorization. Omit unknown values. Values are trimmed and truncated to the documented length.
length <= 64- body
target*stringengine_family?stringImmutable model family. Omitted: the family marked is_default in GET /v1/engine-families. The latest active engine prepares the initial context; predictions can only use versions of this family.
"flair""presage""prophecy"name?stringModel name.
explain?booleanAsks for the most influential features (version.top_factors). Off by default: measuring them roughly triples training time.
auto_update?booleanFold outcomes in without waiting for a call to /refresh. Each post to /outcomes then triggers an integration: send your outcomes in batches.
retain_outcomes?booleanDeprecatedDeprecated and ignored. Outcomes and refresh do not require a retention opt-in. Inference data retention is unchanged.
data*array<>Data rows, one object per row.
Model trained
application/json- response
The model created, the version produced (n_train, metrics, warnings) and the data validation report. The version is not repeated inside the model.
model?version?validation?import requestsurl = "https://api.spavik.co/v1/models"body = """{ "target": "churn", "engine_family": "presage", "data": [ { "plan": "pro", "seats": 12, "tickets_90d": 3, "churn": 0 }, { "plan": "free", "seats": 1, "tickets_90d": 9, "churn": 1 }, { "plan": "pro", "seats": 40, "tickets_90d": 0, "churn": 0 }, { "plan": "free", "seats": 2, "tickets_90d": 7, "churn": 1 }, { "plan": "growth", "seats": 120, "tickets_90d": 1, "churn": 0 }, { "plan": "free", "seats": 1, "tickets_90d": 12, "churn": 1 }, { "plan": "pro", "seats": 25, "tickets_90d": 2, "churn": 0 }, { "plan": "free", "seats": 3, "tickets_90d": 5, "churn": 1 }, { "plan": "growth", "seats": 80, "tickets_90d": 4, "churn": 0 }, { "plan": "pro", "seats": 8, "tickets_90d": 11, "churn": 1 }, { "plan": "growth", "seats": 200, "tickets_90d": 0, "churn": 0 }, { "plan": "free", "seats": 4, "tickets_90d": 2, "churn": 0 } ]}"""response = requests.request("POST", url, data = body, headers = { "Content-Type": "application/json"})print(response.text){ "model": { "id": "string", "name": "string", "slug": "string", "engine_family": "flair", "target": "string", "task": "classification", "engine": "string", "feature_columns": [ "string" ], "status": "string", "auto_update": true, "retain_outcomes": true, "latest_version": 0, "created_at": "2019-08-24T14:15:22Z" }, "version": { "id": "string", "version": 0, "status": "string", "target": "string", "task": "string", "n_train": 0, "n_sampled_from": 0, "metrics": { "AUC": 0, "Accuracy": 0, "AveragePrecision": 0, "LogLoss": 0, "MacroF1": 0, "MAE": 0, "RMSE": 0, "R²": 0, "MASE": 0, "Bias": 0, "BiasRatio": 0, "Pinball": 0, "property1": 0, "property2": 0 }, "baselines": {}, "classification_report": { "evaluated_count": 0, "decision_rule": { "kind": "argmax", "description": "string", "class_order": [ "string" ], "threshold": 0, "tie_break": "first_in_class_order" }, "per_class": [ { "class": "string", "support": 0, "predicted_count": 0, "true_positive": 0, "precision": 0, "recall": 0, "f1": 0, "undefined_reasons": { "precision": "no_predicted_samples", "recall": "no_actual_samples", "f1": "no_actual_or_predicted_samples" } } ] }, "calibration": { "available": true, "unavailable_reason": "no_evaluated_samples", "evaluated_count": 0, "evaluated_on": "test", "kind": "one_vs_rest", "interpretation": "descriptive_only", "binning": "uniform", "n_bins": 10, "bin_boundaries": "left_closed_right_open_last_closed", "per_class": [ { "class": "string", "bins": [ { "lower": 0, "upper": 0, "count": 0, "positive_count": 0, "mean_predicted_probability": 0, "observed_frequency": 0 }, { "lower": 0, "upper": 0, "count": 0, "positive_count": 0, "mean_predicted_probability": 0, "observed_frequency": 0 }, { "lower": 0, "upper": 0, "count": 0, "positive_count": 0, "mean_predicted_probability": 0, "observed_frequency": 0 }, { "lower": 0, "upper": 0, "count": 0, "positive_count": 0, "mean_predicted_probability": 0, "observed_frequency": 0 }, { "lower": 0, "upper": 0, "count": 0, "positive_count": 0, "mean_predicted_probability": 0, "observed_frequency": 0 }, { "lower": 0, "upper": 0, "count": 0, "positive_count": 0, "mean_predicted_probability": 0, "observed_frequency": 0 }, { "lower": 0, "upper": 0, "count": 0, "positive_count": 0, "mean_predicted_probability": 0, "observed_frequency": 0 }, { "lower": 0, "upper": 0, "count": 0, "positive_count": 0, "mean_predicted_probability": 0, "observed_frequency": 0 }, { "lower": 0, "upper": 0, "count": 0, "positive_count": 0, "mean_predicted_probability": 0, "observed_frequency": 0 }, { "lower": 0, "upper": 0, "count": 0, "positive_count": 0, "mean_predicted_probability": 0, "observed_frequency": 0 } ] } ] }, "evaluation": { "metric_context": { "undefined_reasons": { "property1": "string", "property2": "string" }, "class_order": [ "string" ], "positive_class": "string", "auc_average": "binary", "average_precision_method": "non_interpolated", "macro_f1_average": "unweighted_defined_classes", "log_loss_epsilon": 0 } }, "warnings": [ "string" ], "top_factors": [ {} ], "engine": "string" }, "validation": {}}How is this guide?
Last updated on