# Credits and usage

> How a call is priced, reserved and charged, and where you see what each case and each person spent.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://ai.docs.sypnia.com/usage/credits-and-usage/

For agents: Price of a call = input tokens × model's input price + output tokens × output price (cached input tokens at the model's cached price) in credits (Cloud; prices in the catalog) or provider currency (self-hosted, from the price table). Before: reserve the maximum (input + max_output_tokens) from prepaid credits; 402 insufficient_credits if the balance can't cover it, after the 7 days of grace. After: charge the real tokens, release the rest. Usage views: by product, project, case, task, key, end user, model, day; in App (ledger entries per case), console, ai usage --by …, GET /v1/usage. Exports CSV. Self-hosted: same records, amounts in the provider's currency.

## What a call costs

A model has a price for each million tokens it **reads** and each million it **writes**; some charge less for tokens they read again soon after ([Caching](https://ai.docs.sypnia.com/usage/caching)). A call costs:

> tokens read × read price + tokens written × write price

In Sypnia Cloud the prices are in **credits** and shown in the catalog (`ai models`). Self-hosted, the gateway uses your providers' prices, in their currency, from its price table.

## Reserved first, charged after

1. **Before the call**, the most it could cost (what it reads, plus its longest possible answer, `max_output_tokens`) is **reserved** from your prepaid credits. If your balance cannot cover it, the call still runs during the [7 days of grace](https://ai.docs.sypnia.com/cloud/plans#when-credits-run-out) and is taken from your next top-up; after them it stops with `402 insufficient_credits` and costs nothing.
2. **After the call**, the real tokens are charged and the rest of the reservation returns to your balance at once.

A smaller `max_output_tokens` reserves less, so many calls at the same time fit in the same balance.

## Where you see it

| Where                                        | What it shows                                                                 |
| -------------------------------------------- | ----------------------------------------------------------------------------- |
| **App**, project board and ledger            | AI spending per case, next to the rest of the project's spending              |
| `ai.app.sypnia.com`                          | usage by day, and by case, task, key, person and model, with the month's pace |
| `npx @sypnia/ai usage --by case --since 30d` | the same in your terminal; `--csv` to export                                  |
| `GET /v1/usage?group_by=case`                | the same through the API                                                      |

Usage of La Espiga for one month, by case:

| Case                       | Calls | Tokens read | Tokens written | Share of credits |
| -------------------------- | ----- | ----------- | -------------- | ---------------- |
| `ask-about-a-product`      | 1,840 | 760,000     | 71,000         | 71 %             |
| `publish-bread-of-the-day` | 30    | 5,500       | 1,900          | 4 %              |
| `find-products`            | 2,410 | 96,000      | —              | 25 %             |
