# Tokens and billing

> Which texts of a request are billed as tokens, each once: examples for Inola Decider and Cordon, the minimum per request, batches and billed errors.

This page explains which texts of a request are counted as [tokens](https://inola.ai/docs/reference/glossary.md#token) and billed.
Prices are not written here: `GET /v1/models` lists the price of each model on your plan.

**Currency.** Prices, credits, the balance and the spend limit are in euros (EUR). The API gives amounts as plain
numbers, without a currency sign or code: `price.per_million` in `GET /v1/models` and the estimated cost of a batch
in `402 payment_required`.

## What is counted

One rule for every model: the tokens of the texts **you** send, each counted **once**; nothing the service adds.
Cordon takes no text of yours beyond the document, so for Cordon the rule counts the document alone. Each model
counts with its own tokenizer; every response says what was counted in `usage.input_tokens`. Only a `200` answer is
billed; see [Errors](#errors).

### Inola Decider

`usage.input_tokens` of `decider-mini` is the sum of the tokens of:

- the document, `input.state`, once, however many questions you ask. A state sent as a JSON object or array is
  counted as its JSON text;
- for each question: its `instructions`;
- for each question: the text of each criterion or option you give in `criteria`. A `choice` option without a
  description is counted by its name.

Not counted:

- the JSON envelope: keys, braces, `type`, the question keys and the option names that have a description;
- the default wording of a yes/no question (`noul`) asked without `criteria`;
- the service's own text around your document and questions;
- the document read again for each question.

`usage.output_tokens` is always `0`: the model chooses among your options and does not generate text.

### Inola Cordon

`usage.input_tokens` of `cordon-mini` is the tokens of the document, `input.state` (or `input.text`). A
[question](https://inola.ai/docs/models/cordon.md#questions) to Cordon names a kind of detection (`"instructions": "ipi"`) instead of
carrying your text, so it adds no tokens: the same document costs the same with or without `input.questions`.
`usage.output_tokens` is `0`.

## Worked example: Inola Decider

A support ticket and two questions: a yes/no (`noul`) and a choice of three described options (`choice`).

### curl

```bash
curl -sS "https://api.inola.ai/v1/infer" \
  -H "Authorization: Bearer $INOLA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "decider-mini", "input": {"state": "I was charged twice. Please fix this ASAP.", "questions": {"billing": {"type": "noul", "instructions": "Is this ticket about billing?"}, "category": {"type": "choice", "instructions": "What is this ticket about?", "criteria": {"billing": "payments and invoices", "technical": "the product does not work", "other": "anything else"}}}}}'
```

### Python

```python
import os

import requests

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

response = requests.post(
    f"{API_URL}/v1/infer",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={
        "model": "decider-mini",
        "input": {
            "state": "I was charged twice. Please fix this ASAP.",
            "questions": {
                "billing": {"type": "noul", "instructions": "Is this ticket about billing?"},
                "category": {"type": "choice", "instructions": "What is this ticket about?",
                             "criteria": {"billing": "payments and invoices", "technical": "the product does not work", "other": "anything else"}},
            },
        },
    },
    timeout=30,
)
response.raise_for_status()
usage = response.json()["usage"]
print("input tokens", usage["input_tokens"], "tokens counted", usage["tokens"])
```

### JavaScript

```javascript
const API_URL = "https://api.inola.ai";
const response = await fetch(`${API_URL}/v1/infer`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.INOLA_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    model: "decider-mini",
    input: {
      state: "I was charged twice. Please fix this ASAP.",
      questions: {
        billing: { type: "noul", instructions: "Is this ticket about billing?" },
        category: { type: "choice", instructions: "What is this ticket about?",
                    criteria: { billing: "payments and invoices", technical: "the product does not work", other: "anything else" } },
      },
    },
  }),
});
if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${response.status} ${error.code}: ${error.message}`);
}
const { usage } = await response.json();
console.log("input tokens", usage.input_tokens, "tokens counted", usage.tokens);
```

Response:

```json
{
  "id": "req_01JBXQ7M3T8K2V9R4N6PZC5HDA",
  "model": "decider-mini",
  "version": "1.3.0",
  "output_schema_id": "decision.v1",
  "output": {
    "answers": {
      "billing": {"type": "noul", "noul": 0.97},
      "category": {"type": "choice", "choice": "billing", "probabilities": {"billing": 0.95, "technical": 0.03, "other": 0.02}}
    }
  },
  "usage": {"input_tokens": 32, "output_tokens": 0, "tokens": 32, "latency_ms": 62},
  "created_at": "2026-11-16T12:00:00Z"
}
```

The 32 input tokens:

| text | where in the request | tokens |
|---|---|---|
| `I was charged twice. Please fix this ASAP.` | `state` | 10 |
| `Is this ticket about billing?` | `questions.billing.instructions` | 6 |
| `What is this ticket about?` | `questions.category.instructions` | 6 |
| `payments and invoices` | `questions.category.criteria.billing` | 3 |
| `the product does not work` | `questions.category.criteria.technical` | 5 |
| `anything else` | `questions.category.criteria.other` | 2 |
| **total** | `usage.input_tokens` | **32** |

The document is counted once for both questions; the keys, the `type` fields and the rest of the JSON are not
counted. A third question would add only its own texts.

## Example: Inola Cordon

One document checked by Cordon, with a question named `page`:

### curl

```bash
curl -sS "https://api.inola.ai/v1/infer" \
  -H "Authorization: Bearer $INOLA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "cordon-mini", "input": {"state": "Meeting notes, 14 October: the vendor contract renews on 1 March.", "questions": {"page": {"type": "noul", "instructions": "ipi"}}}}'
```

### Python

```python
import os

import requests

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

response = requests.post(
    f"{API_URL}/v1/infer",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={
        "model": "cordon-mini",
        "input": {
            "state": "Meeting notes, 14 October: the vendor contract renews on 1 March.",
            "questions": {"page": {"type": "noul", "instructions": "ipi"}},
        },
    },
    timeout=30,
)
response.raise_for_status()
usage = response.json()["usage"]
print("input tokens", usage["input_tokens"], "tokens counted", usage["tokens"])
```

### JavaScript

```javascript
const API_URL = "https://api.inola.ai";
const response = await fetch(`${API_URL}/v1/infer`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.INOLA_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    model: "cordon-mini",
    input: {
      state: "Meeting notes, 14 October: the vendor contract renews on 1 March.",
      questions: { page: { type: "noul", instructions: "ipi" } },
    },
  }),
});
if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${response.status} ${error.code}: ${error.message}`);
}
const { usage } = await response.json();
console.log("input tokens", usage.input_tokens, "tokens counted", usage.tokens);
```

Response:

```json
{
  "id": "req_01JBXV8M0P2R4T6W8Y0A2C4E6G",
  "model": "cordon-mini",
  "version": "2.2.1",
  "output_schema_id": "decision.v1",
  "output": {"answers": {"page": {"type": "noul", "noul": 0.01, "threshold": 0.5, "verdict": false, "verdicts": {"fpr_1e-03": false, "fpr_1e-04": false}}}},
  "usage": {"input_tokens": 16, "output_tokens": 0, "tokens": 16, "latency_ms": 35},
  "created_at": "2026-11-01T12:00:00Z"
}
```

All 16 input tokens are the document's. The question `page` adds none: without `input.questions` the same document
is answered under `injection` and gives the same `usage`.

## Reading `usage`

Every `POST /v1/infer` response carries `usage`: `input_tokens`, the basis of billing; `output_tokens`, `0` for
`decider-mini` and `cordon-mini`; `tokens`, the input tokens counted against the token limits of your plan;
`latency_ms`, the processing time.

`POST /v1/chat/completions` reports the same counts in the OpenAI form: `usage.prompt_tokens` is `input_tokens`,
`usage.completion_tokens` is `output_tokens`.

Usage by day, model and key is in the console (**Usage**).

## The minimum per request

A real-time request shorter than the model's minimum is billed as the minimum; `usage` still shows the tokens
counted. The minimum, if a model has one, is `price.min_tokens_per_request` in `GET /v1/models`. Batch items have no
minimum.

## Batches

- Items are counted by the same rule and billed at `price.batch_pct` of the real-time price (`GET /v1/models`).
- Only completed items are billed; items in the error file are not.
- When a batch is cancelled, items answered before it are billed; items not started are not run or billed.

## Errors

Only a `200` answer is billed; no error answer is.

| status | codes | billed |
|---|---|---|
| `200` | — | yes: `usage.input_tokens` at the model's price (at least the minimum, if any) |
| `400`, `401`, `402`, `403`, `404`, `410`, `413` | every code | no |
| `429` | every code, among them `overloaded`, `maintenance`, `serverless_cold` | no |
| `500`, `503` | every code | no |

- If the service does not get the model's answer in time, the request ends with `503 unavailable` and is not
  billed.
- A request is not cancelled when your client closes the connection or stops waiting. If the model answers it, it
  is billed as a successful request, even though your client did not receive the answer. Set your client's timeout
  longer than the time the model needs, and retry only after an error answer.

Each code is explained in [Error codes](https://inola.ai/docs/reference/errors.md).

## Credits, allowances and the spend limit

Use beyond the [plan](https://inola.ai/docs/reference/glossary.md#plan) is paid from [credits](https://inola.ai/docs/reference/glossary.md#credits).
Allowances and the [spend limit](https://inola.ai/docs/reference/glossary.md#spend-limit) are in the console
([https://console.inola.ai](https://console.inola.ai), **Billing**). With no credits left, requests return
[`402 payment_required`](https://inola.ai/docs/reference/errors.md#payment_required); at a limit,
[`429 monthly_token_limit`](https://inola.ai/docs/reference/errors.md#monthly_token_limit) or
[`429 spend_limit_reached`](https://inola.ai/docs/reference/errors.md#spend_limit_reached).

## Next steps

- [Inola Decider](https://inola.ai/docs/models/decider.md) — the questions it answers.
- [Inola Cordon](https://inola.ai/docs/models/cordon.md) — the detector and its questions.
- [Limits and retries](https://inola.ai/docs/guides/limits-and-retries.md) — the limits of your plan and the answers when one is reached.
- [Batches](https://inola.ai/docs/guides/batches.md) — large volumes.
- [Glossary](https://inola.ai/docs/reference/glossary.md) — the terms used here.
