# Limits

> Requests and tokens per minute, and caps in credits, for the project, each key, each task and each person.

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

For agents: Limit scopes: project, key, task (route limits), case, end user. Kinds: requests_per_minute, tokens_per_minute, credits_per_day, credits_per_month (+ requests_per_day for end users). Errors: 429 rate_limited (per-minute, with retry-after), 402 budget_exceeded (a cap of yours, names the scope), 402 spending_limit_reached (organization/project/product limit set in App), 402 insufficient_credits. Notices at 80 % and 100 % of every cap. Set in sypnia.toml ([ai.limits] for project/keys/cases, limits inside each [ai.tasks.<name>]), console, CLI ai limits set. Days and months in the organization's time zone. Cloud plan limits for requests/tokens per minute are published with the plans.

## Who a limit applies to

| Scope                  | Example at La Espiga            | Set in                               |
| ---------------------- | ------------------------------- | ------------------------------------ |
| **Project**            | all of the project's AI         | `ai.limits.project` in `sypnia.toml` |
| **Key**                | the key used by the morning job | `ai keys create … --credits-per-day` |
| **Task**               | `allergen-answer`               | the route's `limits`                 |
| **Use case**           | `ask-about-a-product`           | `ai.limits.cases` in `sypnia.toml`   |
| **Person of your app** | each customer who asks          | the route's `limits.end_user`        |

## What a limit counts

| Kind                                   | Meaning                             | When it is reached                      |
| -------------------------------------- | ----------------------------------- | --------------------------------------- |
| `requests_per_minute`                  | calls started in a minute           | `429 rate_limited`, with `retry-after`  |
| `tokens_per_minute`                    | tokens read and written in a minute | `429 rate_limited`, with `retry-after`  |
| `requests_per_day`                     | calls in a day (people of your app) | `429 end_user_limit`                    |
| `credits_per_day`, `credits_per_month` | credits spent                       | `402 budget_exceeded`, naming the scope |

`sypnia.toml`

```toml
[ai.limits]
project = { credits_per_month = 20000 }
cases = { ask-about-a-product = { credits_per_day = 400 } }

[ai.tasks.allergen-answer]
limits = { requests_per_minute = 120, end_user = { requests_per_day = 40, credits_per_day = 10 } }
```

The numbers are La Espiga's own choices.

## Notices

At **80 %** and **100 %** of every cap in credits, the project's owners and admins get a notice in App and an e-mail. Days and months follow the calendar, in your organization's time zone.

## Limits above yours

- **Your organization's spending limits**, set in [App](https://app.docs.sypnia.com/) for the organization, a project or a product, also apply: past them, `402 spending_limit_reached`. **\[Cloud]**
- **Your plan** sets how many requests and tokens per minute a project can reach; the values are published with the plans. **\[Cloud]**
