# Models and versions

> Inola models and their versions, real-time and batch availability, how a version is pinned, and the version lifecycle from preview to retired.

This page explains how the Inola API names [models](https://inola.ai/docs/reference/glossary.md#model) and
[versions](https://inola.ai/docs/reference/glossary.md#version), which models answer in real time and which in real time only while they are running, how a
version is pinned, and what happens when a version is deprecated or retired. Listing models needs an
[API key](https://inola.ai/docs/reference/glossary.md#api-key) with the `models:read` permission.

## Models

| model | what it does | real-time | batch | request form |
|---|---|---|---|---|
| `cordon-mini` | detects prompt injection in a text: verdict and score | yes | yes | [Inola Cordon](https://inola.ai/docs/models/cordon.md), [API reference](https://inola.ai/docs/reference/api.md) |
| `decider-mini` | answers questions about a document | while running | yes | [Inola Decider](https://inola.ai/docs/models/decider.md), [API reference](https://inola.ai/docs/reference/api.md) |

Which ways a model is served is set per processing region: a model may be served in real time and through batches,
only through batches, or not at all in your region (the processing region of your organization). A model available
only through batches in your region answers a real-time request with
[`400 batch_only`](https://inola.ai/docs/reference/errors.md#batch_only); a model available only in real time answers
`POST /v1/batches` with [`400 online_only`](https://inola.ai/docs/reference/errors.md#online_only).

A model served in real time in your region may not be running at the moment of a request — it runs on on-demand
capacity, or its regular capacity is down for a while. Its real-time request is then either held while the model
starts — the first request after an idle period can take several minutes, so allow your client a timeout of at least
11 minutes — or answered with [`429 serverless_cold`](https://inola.ai/docs/reference/errors.md#serverless_cold), depending on the
service's setting at the moment. A key of the Free plan never starts a model: its real-time request is answered while
the model is running and gets `429 serverless_cold` at once otherwise. For documents that do not need an answer in
real time use the [Batch API](https://inola.ai/docs/guides/batches.md) where your region offers it.

The documentation describes models, not their state at a given moment: `GET /v1/models` gives the availability of
each model in your region (below).

## Names and versions

A model has a name (`cordon-mini`) and versions (`2.2.1`). The plain name resolves to the current default version of the
model. To use a specific version, `POST /v1/infer` takes the name and a separate field,
`"model": "cordon-mini", "version": "2.2.1"`; the name with the version, `"model": "cordon-mini-2.2.1"`, is accepted too.

The `model` and `version` fields of a response always name the exact version that answered. Every model is called
through the same `POST /v1/infer`: a new model or version needs no new endpoint, only its name in `model`.

## Pinning a version

An organization can [pin](https://inola.ai/docs/reference/glossary.md#pin) a version of a model in the console. Then the plain name
resolves to the pinned version for every key of the organization, and `default_version` in `GET /v1/models` shows
it. A request that names a version explicitly gets that version, pinned or not.

## Version lifecycle

| status | behaviour |
|---|---|
| `preview` | available for testing; may change |
| `active` | stable |
| `deprecated` | still served; responses carry the headers `Deprecation: true` and `Sunset: <date>` (the date the version is retired) |
| `retired` | not served: requests return [`410 version_retired`](https://inola.ai/docs/reference/errors.md#version_retired); the version is no longer listed |

When every version of a model is retired, the model is removed from the catalog: requests that name it return
[`410 model_retired`](https://inola.ai/docs/reference/errors.md#model_retired), and `GET /v1/models` no longer lists it. The
[changelog](https://inola.ai/docs/changelog.md) names the models removed and the ones to use instead.

A deprecated version keeps working until its `Sunset` date. Code that reads the `Deprecation` header can report it
before the version is retired.

## The model list: `GET /v1/models`

`GET /v1/models` lists the models available on your [plan](https://inola.ai/docs/reference/glossary.md#plan) with their versions.
The list is under `data`; `models` holds the same entries, for clients that read the list under that name.
`GET /v1/models/{id}` returns one model.

| field | meaning |
|---|---|
| `data[].id` | the model name, such as `cordon-mini`; `data[].name` repeats it |
| `data[].description` | what the model does; may be empty |
| `data[].release_date` | `YYYY-MM-DD`: the release date of `data[].default_version`; empty when the date is not known |
| `data[].default_version` | the version the plain name resolves to for your organization (the pinned one, if any) |
| `data[].versions[]` | the versions that are not retired |
| `data[].versions[].version` | the version, such as `2.2.1` |
| `data[].versions[].status` | `preview`, `active` or `deprecated` |
| `data[].versions[].retires_at` | when a deprecated version is retired; `null` otherwise |
| `data[].versions[].context_window` | the maximum document length in tokens |
| `data[].versions[].output_schema_id` | the form of `output` in `/v1/infer`, such as `decision.v1` |
| `data[].availability` | in your region: `online` (real-time; batches too unless `POST /v1/batches` answers `online_only`), `batch` (batches only) or `none` (not served in your region at the moment) |
| `data[].versions[].availability` | the same value as `data[].availability`, repeated on every version |
| `data[].price` | the prices of the model on your plan, the minimum billed tokens per real-time request, the batch price; see [Tokens and billing](https://inola.ai/docs/concepts/tokens-and-billing.md) |
| `data[].limits` | the limits of your plan for the model; see [Limits and retries](https://inola.ai/docs/guides/limits-and-retries.md) |

A model with `availability: none` answers real-time requests and `POST /v1/batches` with
[`503 unavailable`](https://inola.ai/docs/reference/errors.md#unavailable) and a `Retry-After` header.

### curl

```bash
curl -sS "https://api.inola.ai/v1/models" -H "Authorization: Bearer $INOLA_API_KEY"
```

### Python

```python
import os
import sys

import requests

API_URL = "https://api.inola.ai"
API_KEY = os.environ["INOLA_API_KEY"]

response = requests.get(f"{API_URL}/v1/models", headers={"Authorization": f"Bearer {API_KEY}"}, timeout=30)
if response.status_code != 200:
    error = response.json()["error"]
    sys.exit(f"{response.status_code} {error['code']}: {error['message']}")

for model in response.json()["data"]:
    for version in model["versions"]:
        default = " (default)" if version["version"] == model["default_version"] else ""
        print(model["id"], version["version"], version["status"], version["availability"], default)
```

### JavaScript

```javascript
const API_URL = "https://api.inola.ai";
const response = await fetch(`${API_URL}/v1/models`, {
  headers: { Authorization: `Bearer ${process.env.INOLA_API_KEY}` },
});
const body = await response.json();
if (!response.ok) {
  console.error(`${response.status} ${body.error.code}: ${body.error.message}`);
  process.exit(1);
}
for (const model of body.data) {
  for (const version of model.versions) {
    const isDefault = version.version === model.default_version ? " (default)" : "";
    console.log(model.id, version.version, version.status, version.availability, isDefault);
  }
}
```

The output lists one line per version, for example:

```text
cordon-mini 2.2.1 active online  (default)
```

## Errors

| status | code | cause |
|---|---|---|
| 400 | [`batch_only`](https://inola.ai/docs/reference/errors.md#batch_only) | a real-time request to a model available only through batches in your region |
| 400 | [`online_only`](https://inola.ai/docs/reference/errors.md#online_only) | `POST /v1/batches` for a model available only in real time in your region |
| 404 | [`model_not_found`](https://inola.ai/docs/reference/errors.md#model_not_found) | no such model, or not on your plan |
| 410 | [`version_retired`](https://inola.ai/docs/reference/errors.md#version_retired) | the version is retired |
| 410 | [`model_retired`](https://inola.ai/docs/reference/errors.md#model_retired) | every version of the model is retired: the model is removed from the catalog |
| 503 | [`unavailable`](https://inola.ai/docs/reference/errors.md#unavailable) | the model is not served at the moment; retry after `Retry-After` |
| 429 | [`serverless_cold`](https://inola.ai/docs/reference/errors.md#serverless_cold) | a real-time request to a model that is not running now (most often a `serverless` one); retry after `Retry-After` or use the Batch API |

## Next steps

- [Verdicts and scores](https://inola.ai/docs/concepts/verdicts-and-scores.md) — what `cordon-mini` returns.
- [Batches](https://inola.ai/docs/guides/batches.md) — the way to use a model available only through batches in your region, or one that is not running at the moment.
- [API reference](https://inola.ai/docs/reference/api.md) — every field of every endpoint.
