Skip to content

Prediction

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

POST /v1/forecast

Forecast a time series (zero-shot)

Billed one credit per horizon step per series: five series over 7 steps cost 35 credits, in one call or in five. The call is refused (402 CREDITS_EXHAUSTED) before any computation when horizon x series exceeds what is left.

Several series (item_id) are forecast independently, each from its own history only: grouping them saves round trips but changes neither the price nor the values, and one series does not learn from another.

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
horizonintegeroptionalNumber of future steps (alias: prediction_length).
dataobject[]requiredData rows, one object per row.
timestampstringoptionalTimestamp column (inferred when omitted).
quantilesnumber[]optional
item_idstringoptionalColumn identifying several series. Each series is forecast on its own history only.
point_estimatemean | medianoptionalStatistic served in <target>_prediction (defaults to mean).

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

Responses

CodeDescription
200Success
400Invalid series or horizon (INVALID_INPUT: fewer than ten points, irregular interval, unreadable target).
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.
422FORECAST_FAILED: the computation itself failed.

Example

sh
curl -X POST "$SPAVIK_BASE_URL/v1/forecast" \
  -H 'X-API-Key: sk-spv-api-...' \
  -H 'Content-Type: application/json' \
  -d '{
  "target": "ventes",
  "horizon": 7,
  "data": [
    {
      "date": "2026-07-01",
      "ventes": 100
    },
    {
      "date": "2026-07-02",
      "ventes": 112
    },
    {
      "date": "2026-07-03",
      "ventes": 118
    },
    {
      "date": "2026-07-04",
      "ventes": 121
    },
    {
      "date": "2026-07-05",
      "ventes": 130
    },
    {
      "date": "2026-07-06",
      "ventes": 84
    },
    {
      "date": "2026-07-07",
      "ventes": 72
    },
    {
      "date": "2026-07-08",
      "ventes": 105
    },
    {
      "date": "2026-07-09",
      "ventes": 117
    },
    {
      "date": "2026-07-10",
      "ventes": 123
    },
    {
      "date": "2026-07-11",
      "ventes": 126
    },
    {
      "date": "2026-07-12",
      "ventes": 135
    },
    {
      "date": "2026-07-13",
      "ventes": 89
    },
    {
      "date": "2026-07-14",
      "ventes": 77
    },
    {
      "date": "2026-07-15",
      "ventes": 110
    },
    {
      "date": "2026-07-16",
      "ventes": 122
    },
    {
      "date": "2026-07-17",
      "ventes": 128
    },
    {
      "date": "2026-07-18",
      "ventes": 131
    },
    {
      "date": "2026-07-19",
      "ventes": 140
    },
    {
      "date": "2026-07-20",
      "ventes": 94
    },
    {
      "date": "2026-07-21",
      "ventes": 82
    },
    {
      "date": "2026-07-22",
      "ventes": 115
    },
    {
      "date": "2026-07-23",
      "ventes": 127
    },
    {
      "date": "2026-07-24",
      "ventes": 133
    },
    {
      "date": "2026-07-25",
      "ventes": 136
    },
    {
      "date": "2026-07-26",
      "ventes": 145
    },
    {
      "date": "2026-07-27",
      "ventes": 99
    },
    {
      "date": "2026-07-28",
      "ventes": 87
    }
  ]
}'

POST /v1/forecast/backtest

Check whether a series can be forecast at all

Creates nothing, charges nothing. Validates the series (length, regular interval, duplicate timestamps, numeric target) and, if it holds, replays windows of the history to score what the engine would have predicted against what happened.

verdict.level is usable or no_signal, decided on the MASE against the naive baseline, never against the fixed threshold of 1. by_window says whether the model is consistent, which an average hides.

The forecast values are never returned here: forecasting is billed, this route is free. Use POST /v1/forecast to get them.

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

Request body

NameTypeDescription
targetstringrequired
horizonintegeroptionalNumber of future steps (alias: prediction_length).
dataobject[]requiredData rows, one object per row.
timestampstringoptionalTimestamp column (inferred when omitted).
quantilesnumber[]optional
item_idstringoptionalColumn identifying several series. Each series is forecast on its own history only.
point_estimatemean | medianoptionalStatistic served in <target>_prediction (defaults to mean).

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

Responses

CodeDescription
200Success
400Series unreadable, target or timestamp missing, or horizon not an integer from 1 to 1000 (VALIDATION_ERROR).
401Authentication required, or invalid token.
403This caller is not allowed to perform this action.

Example

sh
curl -X POST "$SPAVIK_BASE_URL/v1/forecast/backtest" \
  -H 'X-API-Key: sk-spv-api-...' \
  -H 'Content-Type: application/json' \
  -d '{
  "target": "ventes",
  "horizon": 7,
  "data": [
    {
      "date": "2026-07-01",
      "ventes": 100
    },
    {
      "date": "2026-07-02",
      "ventes": 112
    },
    {
      "date": "2026-07-03",
      "ventes": 118
    },
    {
      "date": "2026-07-04",
      "ventes": 121
    },
    {
      "date": "2026-07-05",
      "ventes": 130
    },
    {
      "date": "2026-07-06",
      "ventes": 84
    },
    {
      "date": "2026-07-07",
      "ventes": 72
    },
    {
      "date": "2026-07-08",
      "ventes": 105
    },
    {
      "date": "2026-07-09",
      "ventes": 117
    },
    {
      "date": "2026-07-10",
      "ventes": 123
    },
    {
      "date": "2026-07-11",
      "ventes": 126
    },
    {
      "date": "2026-07-12",
      "ventes": 135
    },
    {
      "date": "2026-07-13",
      "ventes": 89
    },
    {
      "date": "2026-07-14",
      "ventes": 77
    },
    {
      "date": "2026-07-15",
      "ventes": 110
    },
    {
      "date": "2026-07-16",
      "ventes": 122
    },
    {
      "date": "2026-07-17",
      "ventes": 128
    },
    {
      "date": "2026-07-18",
      "ventes": 131
    },
    {
      "date": "2026-07-19",
      "ventes": 140
    },
    {
      "date": "2026-07-20",
      "ventes": 94
    },
    {
      "date": "2026-07-21",
      "ventes": 82
    },
    {
      "date": "2026-07-22",
      "ventes": 115
    },
    {
      "date": "2026-07-23",
      "ventes": 127
    },
    {
      "date": "2026-07-24",
      "ventes": 133
    },
    {
      "date": "2026-07-25",
      "ventes": 136
    },
    {
      "date": "2026-07-26",
      "ventes": 145
    },
    {
      "date": "2026-07-27",
      "ventes": 99
    },
    {
      "date": "2026-07-28",
      "ventes": 87
    }
  ]
}'

POST /v1/models/{id}/predict

Score rows with a trained model

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
rowsobject[]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
401Authentication required, or invalid token.
402Out of predictions: monthly allowance and balance are both empty.
403This caller is not allowed to perform this action.
409Model not trained yet.
413Payload too large.

Example

sh
curl -X POST "$SPAVIK_BASE_URL/v1/models/{id}/predict" \
  -H 'X-API-Key: sk-spv-api-...' \
  -H 'Content-Type: application/json' \
  -d '{
  "rows": [
    {
      "plan": "free",
      "seats": 2,
      "tickets_90d": 7
    }
  ]
}'

GET /v1/models/{id}/predictions

Prediction history of the model

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

Parameters

NameInTypeDescription
limitqueryintegeroptional

Responses

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

Example

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

Part of this documentation is generated from the OpenAPI contract.