The Forecasting Company Logo
Forecasting API

API Reference

Perform forecasts with foundation models over a timeseries family.


Run a forecast query

POST
https://api.retrocast.com
/v1/forecast

Perform forecasts with foundation models. The input series may first be aggregated across dimensions and hierarchies.

Run a forecast query › query Parameters

model
​string · required

The forecasting model to use, such as t0-alpha.

Run a forecast query › Request Body

A forecast request: your data and what its columns mean (input), which columns to forecast (targets), which series and at what level of aggregation (selector), and when and how far ahead to forecast (cutoff, prediction_length and the other time settings).

​Input · required

A timeseries family written out in full: where its rows come from, plus what its columns mean.

targets
​array | null · minItems: 1

The columns to forecast. Omit to forecast every column the schema declares with the "target" kind.

Default: null
​Selector

Which series to forecast, and at what level of aggregation. Omit it to forecast every series at the finest level the data has; {} forecasts a single series, the total over everything. Cannot be combined with selectors.

Default: null
​Selector[] · minItems: 1

Several selectors, to forecast more than one level of aggregation in one request, such as per store and per city. The response holds the series of every selector. No two selectors may name the same levels. Cannot be combined with selector.

Default: null
​CrossInference

Forecast timeseries jointly, letting the model learn across them (cross-learning, at inference time). Omit it to forecast each timeseries from its own data alone.

With it, timeseries are forecast in groups. Within a group, the model reads every timeseries side by side: the targets' history, plus any historical and future covariates. A pattern in one timeseries can then inform the forecast of another, such as a demand shift seen in several stores of one city. Each timeseries still gets its own forecast.

  • group_by: the identifier levels that form groups. Timeseries that share a value at every listed level are grouped together. ["city"] groups each city's stores, and [] puts all selected timeseries in one group. Each level must be a selected identifier level or one of its ancestors in a hierarchy. With selectors, each selector's timeseries are grouped separately.
  • Same end time: timeseries are grouped only when they are forecast from the same cutoff instant, meaning their histories end at the same time. With an explicit cutoff date, every timeseries shares it. With latest, a timeseries whose last observation comes earlier than the others' is forecast on its own. In a backtest, each cutoff forms its own groups, so a forecast never sees another timeseries past its own cutoff.
  • No splitting: a group is never split. A group larger than the model can read fails.

Output: the response gains a cross_inference_group column, or a per-timeseries field. Forecasts with the same value were made together. A timeseries forecast on its own has null. Ids are only meaningful within one response.

Default: null
​object
Default: {}
​array | null · minItems: 1 · unique

Quantile levels to forecast for every target, as numbers in [0, 1]; include "mean" to also request the mean. Defaults to [0.1, 0.5, 0.9, "mean"].

Default: null
​MetricsRequest

Score the forecast against the actuals the request carries, and report the scores under metrics in the response. A cutoff is scored when its forecast window lies inside the data and observes some target; missing actuals are skipped. The point scores use the 0.5 quantile when quantiles includes it, and the mean otherwise; when this is set the mean is forecasted whether or not quantiles asks for it.

true scores with the default settings and false does not score. An object scores with the settings it gives: crps picks how the CRPS weighs the quantile levels, "trapezoid" (the default) or "mean_quantile_loss". The response does not say which was used.

Default: false
return_actuals
​boolean

Return each target's actuals over every forecast window under actuals in the response, aligned with the forecast values. These are the values the model reads, after aggregation and gap filling; a step without a value is null.

Default: false
model_config
​

Options for the model named by the model query parameter, passed to it as given. Each model defines which options it takes and rejects the ones it does not know.

Default: null
​Cutoff[] · minItems: 1

A non-empty array of information cutoffs. For example ["latest"], an explicit date ["2025-01-31"], or a recurring schedule [{ "every": "3d" }].

Default: ["latest"]
​LeadTime

Time to skip between the cutoff and the first forecast value. Defaults to 0: the forecast starts at the step right after the cutoff. With daily data and a cutoff on Monday, a lead_time of "2d" starts the forecast on Thursday.

Default: 0
​Context

How much history before each cutoff the model sees, such as "90d". Leave it out to send all the history before the cutoff.

Default: null
​PredictionLength

How far ahead to forecast, such as "28d" or 28 steps. Defaults to 1: one step of the time grid.

Default: 1
​Span

Time each forecast value covers. Only one step of the time grid is supported, the default 1. To forecast weekly or monthly totals, select a coarser time level instead: "selector": { "weekly": "any" }.

Default: 1

Run a forecast query › Responses

The forecast, in the format the Accept header asks for:

  • application/json (the default): the whole forecast as one long-format table, in columnar form.
  • application/x-ndjson: one series forecast per line, each sent as soon as it is ready.
  • application/vnd.msgpack: the same series forecasts as MessagePack maps, back to back.
  • application/vnd.apache.parquet: the long-format table as one Parquet file.
  • application/x-tar: a tar archive of two Parquet files: forecast.parquet, the long-format table, and materialization.parquet, the rows the forecast read, after aggregation and gap filling.

The two streamed formats send one record per series and cutoff, in no particular order. If a failure cuts a stream short, its last record is {"error": …}, a problem document.

The Parquet file, like the archive's forecast.parquet, has one row per series, cutoff and step, in the same order as the JSON table. Its columns:

  • time, cutoff: UTC timestamps.
  • lead_time, span: ISO 8601 durations, as strings.
  • identifiers: one field per identifier column, null on rows aggregated above it. Left out when the data has no identifier column.
  • targets: one field per target, each holding quantiles (one value per requested level, named by its label, such as "0.5"), mean (when requested, or when compute_metrics is set), actual (when return_actuals is set; null where the target has no actual) and window_metrics (when compute_metrics is set: crps, scaled_crps, mae, mape, wape and scaled_bias for the row's whole forecast window, repeated on each of its rows; null where the window was not scored).
​ForecastTable · required

The forecast as a long-format table in columnar form: every field is a column, and row i of the table is entry i of each column. There is one row per series, cutoff and forecast step.

​array | null

Accuracy metrics, one entry per series and cutoff whose forecast window lies inside the actuals and observes some target. Present only when the request set compute_metrics.