Skip to content

Models

Examples use $SPAVIK_BASE_URL and $SPAVIK_API_KEY, set in Get started.

POST /v1/datasets/validate

Check a dataset before training on it

Creates nothing, charges nothing. Returns the same validation report as training does, plus what the engine makes of the data: a trial run that persists nothing, with its metrics against the lazy answer (majority class or mean). Use it to iterate on a file until it holds, then train on it.

trial.verdict.level is usable, weak (suspiciously good, usually a column filled in after the event you predict) or no_signal (the columns carry nothing for this target). It is absent when validation already failed.

For a time series, use POST /v1/forecast/backtest instead: a series is judged on its length, its interval and its gaps, not on its classes.

Authentication : API key (X-API-Key) or web session (Authorization: Bearer)

Request body

NameTypeDescription
targetstringrequired
enginestringoptionalPrediction engine (see GET /v1/engines). Required when creating a model; on an already trained model, the previous version engine is used by default.
namestringoptionalModel name.
explainbooleanoptionalAsks for the most influential features (version.top_factors). Off by default: measuring them roughly triples training time.
auto_updatebooleanoptionalFold outcomes in without waiting for a call to /refresh. Each post to /outcomes then triggers an integration: send your outcomes in batches.
dataobject[]requiredData rows, one object per row.

This route also accepts multipart/form-data, to upload a file instead of serialising rows as JSON.

Responses

CodeDescription
200Success
400Data missing, target missing, or unreadable CSV.
401Authentication required, or invalid token.
403This caller is not allowed to perform this action.

Example

sh
curl -X POST "$SPAVIK_BASE_URL/v1/datasets/validate" \
  -H 'X-API-Key: sk-spv-api-...' \
  -H 'Content-Type: application/json' \
  -d '{
  "target": "churn",
  "engine": "tabicl-v2",
  "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
    }
  ]
}'

GET /v1/engines

Available prediction engines

The engine is declared at training time (engine). A model keeps being served by the one that produced it: upgrading the platform does not change the predictions of existing models.

Authentication : Public route, no authentication

Responses

CodeDescription
200Success
503ENGINE_CATALOGUE_MISMATCH: the catalogue could not be read from the engine.

Example

sh
curl -X GET "$SPAVIK_BASE_URL/v1/engines" \
  -H 'X-API-Key: sk-spv-api-...'

GET /v1/models

List the workspace models

Authentication : API key (X-API-Key) or web session (Authorization: Bearer)

Parameters

NameInTypeDescription
limitqueryintegeroptional
offsetqueryintegeroptional
statusqueryarchivedoptionalServing models by default. archived lists what was set aside, so it can be found again and restored. Deleted models are never listed.

Responses

CodeDescription
200Success
401Authentication required, or invalid token.
403This caller is not allowed to perform this action.

Example

sh
curl -X GET "$SPAVIK_BASE_URL/v1/models" \
  -H 'X-API-Key: sk-spv-api-...'

POST /v1/models

Create a model (data + target) and train it

Creating a model is training it: the data goes in the same call, as JSON ('data') or CSV (the 'file' field). The response carries the identifier to use afterwards to predict (POST /v1/models/{id}/predict), without sending the data again.

Authentication : API key (X-API-Key) or web session (Authorization: Bearer)

TIP

Accepts Idempotency-Key: replaying the same call with the same key returns the already computed response, with no second charge.

Request body

NameTypeDescription
targetstringrequired
enginestringoptionalPrediction engine (see GET /v1/engines). Required when creating a model; on an already trained model, the previous version engine is used by default.
namestringoptionalModel name.
explainbooleanoptionalAsks for the most influential features (version.top_factors). Off by default: measuring them roughly triples training time.
auto_updatebooleanoptionalFold outcomes in without waiting for a call to /refresh. Each post to /outcomes then triggers an integration: send your outcomes in batches.
dataobject[]requiredData rows, one object per row.

This route also accepts multipart/form-data, to upload a file instead of serialising rows as JSON.

Responses

CodeDescription
201Model trained
401Authentication required, or invalid token.
402Out of predictions: monthly allowance and balance are both empty.
403This caller is not allowed to perform this action.
413Payload too large.
422Data validation failed.

Example

sh
curl -X POST "$SPAVIK_BASE_URL/v1/models" \
  -H 'X-API-Key: sk-spv-api-...' \
  -H 'Content-Type: application/json' \
  -d '{
  "target": "churn",
  "engine": "tabicl-v2",
  "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
    }
  ]
}'

GET /v1/models/{id}

Model details

Authentication : API key (X-API-Key) or web session (Authorization: Bearer)

Responses

CodeDescription
200Success
401Authentication required, or invalid token.
403This caller is not allowed to perform this action.
404Unknown model.

Example

sh
curl -X GET "$SPAVIK_BASE_URL/v1/models/{id}" \
  -H 'X-API-Key: sk-spv-api-...'

PATCH /v1/models/{id}

Rename a model

Authentication : API key (X-API-Key) or web session (Authorization: Bearer)

Request body

NameTypeDescription
namestringoptional

Responses

CodeDescription
200Success
401Authentication required, or invalid token.
403This caller is not allowed to perform this action.
409Target and task are frozen once trained.

Example

sh
curl -X PATCH "$SPAVIK_BASE_URL/v1/models/{id}" \
  -H 'X-API-Key: sk-spv-api-...' \
  -H 'Content-Type: application/json' \
  -d '{ }'

DELETE /v1/models/{id}

Delete a model for good

Irreversible: the artefacts are purged from the engine and the pending outcomes go with them. To stop serving a model without losing it, archive it instead.

Authentication : API key (X-API-Key) or web session (Authorization: Bearer)

Responses

CodeDescription
204Deleted
401Authentication required, or invalid token.
403This caller is not allowed to perform this action.

Example

sh
curl -X DELETE "$SPAVIK_BASE_URL/v1/models/{id}" \
  -H 'X-API-Key: sk-spv-api-...'

POST /v1/models/{id}/archive

Set a model aside

Nothing is destroyed: the trained artefacts are kept, the model simply stops serving and stops counting against the model quota. Restore it whenever you need it again. Predicting on an archived model returns 409 MODEL_ARCHIVED.

Authentication : API key (X-API-Key) or web session (Authorization: Bearer)

Responses

CodeDescription
204Archived
401Authentication required, or invalid token.
403This caller is not allowed to perform this action.
404Unknown model.

Example

sh
curl -X POST "$SPAVIK_BASE_URL/v1/models/{id}/archive" \
  -H 'X-API-Key: sk-spv-api-...'

POST /v1/models/{id}/outcomes

Report what actually happened

Outcomes pile up, then join the context data of the model (POST /v1/models/{id}/refresh), and serve the predictions that follow. Each outcome is identified by the request_id of the original prediction (the features are looked up) or carries its full set of features. Send outcomes in batches: one call is one batch, and on a model with automatic updates (auto_update) a batch triggers an integration. Sending outcomes one by one would therefore trigger one training run per outcome.

Authentication : API key (X-API-Key) or web session (Authorization: Bearer)

TIP

Accepts Idempotency-Key: replaying the same call with the same key returns the already computed response, with no second charge.

Request body

NameTypeDescription
outcomesobject[]required

Responses

CodeDescription
201Success
401Authentication required, or invalid token.
403This caller is not allowed to perform this action.
404Unknown model.

Example

sh
curl -X POST "$SPAVIK_BASE_URL/v1/models/{id}/outcomes" \
  -H 'X-API-Key: sk-spv-api-...' \
  -H 'Content-Type: application/json' \
  -d '{
  "outcomes": [
    {
      "request_id": "4fa2ebd6-e347-43d4-b40d-a043c9a3121a",
      "actual": 1
    },
    {
      "features": {
        "plan": "free",
        "seats": 2,
        "tickets_90d": 10
      },
      "actual": 0
    }
  ]
}'

GET /v1/models/{id}/performance

Real-world performance, against the training metrics

Compares what was predicted to what happened (the outcomes you reported). observed stays null until an outcome can be matched to a prediction.

Authentication : API key (X-API-Key) or web session (Authorization: Bearer)

Parameters

NameInTypeDescription
daysqueryintegeroptional

Responses

CodeDescription
200Success
401Authentication required, or invalid token.
403This caller is not allowed to perform this action.
503PERFORMANCE_UNAVAILABLE: the log (BigQuery) could not be read.

Example

sh
curl -X GET "$SPAVIK_BASE_URL/v1/models/{id}/performance" \
  -H 'X-API-Key: sk-spv-api-...'

POST /v1/models/{id}/refresh

Fold pending outcomes into the context data

Produces a NEW version, which serves predictions right away; the previous one stays available, so rolling back is possible. No weights change: what grows is the set of examples the model looks at.

Authentication : API key (X-API-Key) or web session (Authorization: Bearer)

TIP

Accepts Idempotency-Key: replaying the same call with the same key returns the already computed response, with no second charge.

Responses

CodeDescription
201New version
401Authentication required, or invalid token.
403This caller is not allowed to perform this action.
409No pending outcomes, or an update is already running.

Example

sh
curl -X POST "$SPAVIK_BASE_URL/v1/models/{id}/refresh" \
  -H 'X-API-Key: sk-spv-api-...'

POST /v1/models/{id}/restore

Put an archived model back in service

Takes a place in the model quota again, so it can be refused when the plan is full. A model deleted for good cannot be restored (409 MODEL_DELETED). If the engine has moved on since, the model is restored but its version may no longer be servable: the next prediction says so (409 ENGINE_MISMATCH), and a refresh produces one on the current engine.

Authentication : API key (X-API-Key) or web session (Authorization: Bearer)

Responses

CodeDescription
200Success
401Authentication required, or invalid token.
402QUOTA_MODELS_EXCEEDED: the plan has no free slot left.
403This caller is not allowed to perform this action.
404Unknown model.
409MODEL_DELETED: deleted for good, nothing to restore.

Example

sh
curl -X POST "$SPAVIK_BASE_URL/v1/models/{id}/restore" \
  -H 'X-API-Key: sk-spv-api-...'

GET /v1/models/{id}/versions

List versions

Authentication : API key (X-API-Key) or web session (Authorization: Bearer)

Responses

CodeDescription
200Success
401Authentication required, or invalid token.
403This caller is not allowed to perform this action.

Example

sh
curl -X GET "$SPAVIK_BASE_URL/v1/models/{id}/versions" \
  -H 'X-API-Key: sk-spv-api-...'

Part of this documentation is generated from the OpenAPI contract.