# Limits

> Request sizes, quotas and fit lifetimes.

## Per request

| Time series | |
|---|---|
| Series | 256 |
| Points per series | 32,768 |
| Points per request (with covariates) | 8,000,000 |
| Horizon | 2,048 steps |
| Targets and covariates per series | 256 |
| Quantile levels | 32 |
| Sample paths | 1,000 per series; 2,000,000 values (samples x horizon x series) per request |

| Tables | |
|---|---|
| Rows | 200,000 per call (a one-shot predict counts training and predicted rows together) |
| Columns | 2,000 |
| A direct fit or one-shot predict | `fast`: up to 100,000 training rows x 100 columns; `medium` and `pro`: up to 25,000 x 100. Larger tables run as an [async job](https://yhatlabs.com/models/docs/api/jobs) |
| Cells (training rows x columns) in an async job | 50,000,000 |
| A comparison with standard models | up to 100,000 training rows x 100 columns |
| Request size | 64 MB (gzip-compressed bodies are accepted and count at their inflated size) |
| Uploaded table | 1 GB, 1,000,000 rows, 100,000,000 cells ([uploads](https://yhatlabs.com/models/docs/api/uploads)); a call that uses it is held to the limits above |
| Quantile levels | 32 |

Past its preset's direct size, a direct table call answers HTTP 413 with error type `async_required`: send it again with
`"async": true`. Past the caps above it answers `request_too_large`. The Python library splits large forecasting inputs into
several requests, and sends a table past the direct size as a job and waits for it. `GET /v1/limits` (or
`yh.server_limits()`) returns the current values; the direct sizes are under `tabular.direct`.

## Tunes

A [tune](https://yhatlabs.com/models/docs/time-series/tuning) takes the series of one request and at most 1,000 steps; every series needs at
least `2 x horizon + 64` values. It is kept for `ttl_days` after its last use (30 by default, 365 at most).

## Fits

A stored fit is kept for `ttl_days` after its last use: 30 by default, 365 at most; every prediction from it starts the count
again. Change it with `PATCH /v1/table/fits/{id}`, or delete the fit earlier with `DELETE /v1/table/fits/{id}` or
`model.delete()`.

## Rate and concurrency

| Per key | |
|---|---|
| Requests to the models | 120 a minute |
| Calls running at once | 8 forecasts, 2 tabular calls, 4 uploads |
| Uploaded tables kept | 200, 10 GB in all |

Over a limit, a call gets HTTP 429 with error type `rate_limited` and a `Retry-After` header saying how many seconds to wait.
The Python library waits and retries on its own. An uploaded table is deleted after a period without use; the library uploads
it again when needed.

## Pricing

Calls are counted in tokens, as an LLM API counts them, from the work the model does. Your organization pays in credits, at its
rate per million tokens (1 credit per 1M tokens by default), and every call pays at least a small minimum. Credits are shown
with decimals, to three places, so a small call costs a few hundredths of a credit (`0.02`).

| Call | Tokens |
|---|---|
| Forecast | per item: (history points, at most 2,048, + horizon) x (target columns + covariate columns) |
| Feature columns | count in full up to 100; each column past 100 counts 0.05 (a 725-column table is priced as 131.25 columns) |
| Fit | training rows x feature columns x preset (`fast` 1, `medium` 3, `pro` 8), plus 100,000 for a regression (its prediction distribution) |
| Predict from a fit | the fit's training cells x 0.5 + predicted rows x feature columns; x2 with ranges (`quantiles`) |
| One-shot predict | the fit, plus predicted rows x feature columns (x2 with ranges) |
| Importance | the fit's training cells x 2 |
| Compare with standard models | training rows x feature columns x 0.5 + predicted rows x feature columns |
| Tune | steps x 8 windows x (1,024 + horizon) x (1 + known covariate columns), plus a forecast of every series |

Every reply states `usage.tokens` and `usage.credits`. `POST /v1/estimate` prices a call before you make it, for free:

```sh
curl https://api.yhatlabs.com/v1/estimate -H "Authorization: Bearer $YHAT_API_KEY" -H "Content-Type: application/json" \
  -d '{"call": "fit", "train_rows": 100000, "features": 50, "preset": "medium"}'
# {"tokens": 15000000, "credits": 15, "credits_per_m_tokens": 1, "min_tokens": 20000}
```

`GET /v1/limits` publishes the rules and your organization's rates under `pricing`. A call that fails on our side costs nothing.
Predicting from a saved model is charged on its training table's size (0.5 x its cells) as well as the predicted cells, so
scoring a few rows from a large fit still costs a share of the fit. Forecasts are counted in credits for keys of an
organization (`fc.usage` in Python); keys we issued directly (for example for a benchmark) count forecasts in series against
their own quota.
