# Limits

Part of [Build a custom machine](https://www.ownbox.io/sdk/guide).

Every machine runs under these limits. Each row says what happens past it.

**Its class.** `resources.class` in machine.yaml sets the unit's memory, CPU and processes. A bigger class counts as
more than one machine toward how many an Ownbox runs at once, which its plan sets, so a big machine may wait for room
while others run. An Ownbox refuses a class its memory cannot hold, at the check, with the reason.

| Class | Memory, no swap | CPU, at low priority | Processes and threads | Counts as | Needs an Ownbox with |
|---|---|---|---|---|---|
| `small` (the default) | 256 MB | half of one core | 64 | 1 machine | any memory |
| `standard` | 512 MB | one core | 128 | 2 machines | 2 GB of memory |
| `large` | 1 GB | two cores | 256 | 4 machines | 4 GB of memory |

**The unit**

| What | Limit | Past it |
|---|---|---|
| Memory | its class's | The unit is stopped and restarted. |
| CPU | its class's | It runs slower. |
| Processes and threads | its class's | A new one fails to start. |
| One file it writes | 200 MB | The write fails. |
| Open files | 256 | Opening one more fails. |
| Crashes | 5 an hour, restarted 5 s after each | It stays stopped until the hour passes. |

**The door**

| What | Limit | Past it |
|---|---|---|
| Calls | 120 a minute (`next` aside) | `rate_limited` |
| One request | 2 MB | `too_large` |
| One setting | 64 KB as JSON | `too_large` |
| Settings | 200, and 2 MB in all | `too_many_settings`, `settings_full` |
| Setting key | 1 to 80 of `A-Z a-z 0-9 _ . : -` | `bad_key` |
| Jobs | 20, each every 15 s to every 7 days | `too_many_jobs`, `bad_every` |
| Tools | 20, each with at most 10 arguments | `too_many_tools`, `bad_tool` |
| Proposal kinds | 20 | `too_many_kinds` |
| Proposals waiting | 20 | answered `refused`, `too_many_waiting` |
| Proposal detail | 16,000 characters as JSON | answered `refused`, `too_large` |
| Pages, cards | 20 pages, 10 cards | `too_many_screens`, `too_many_panels` |
| Step key (`key=`) | 1 to 120 characters, remembered for a day | `bad_idem` |
| Notices | 20 a day | `over_cap` |

**The AI**

| What | Limit | Past it |
|---|---|---|
| Calls | its `calls_per_month` (default 300, at most 5,000) | `over_budget` |
| Words | its `chars_per_month` (default 2,000,000) | `over_budget` |
| One prompt | 200,000 characters; a system prompt 50,000 | `bad_prompt` |
| One answer | `max_tokens` up to 4,096 (default 1,024) | `bad_prompt` |
| At once | one call per machine | it waits its turn |

**The web**

| What | Limit | Past it |
|---|---|---|
| Hosts | 20, named in machine.yaml | `host_not_allowed` |
| Fetches | 60 a minute | `rate_limited` |
| Methods | `GET`, `POST`, `PUT`, `PATCH`, `DELETE` | `bad_method` |
| Address | `https://`, port 443, a public host, no user or password | `https_only`, `bad_url`, `not_public` |
| Request body | 1 MB | `too_large` |
| Response body | 4 MB | `too_large` |
| Headers | 30, each at most 8,192 characters | `bad_headers` |
| Time | `timeout` 1 to 30 s (default 20) | `unreachable` |
| Redirects | handed back, never followed | — |

**Sending:** `per_day` for each channel, at most 200; past it, `over_cap` until the day turns. **Pages:** 20 s to
answer, 40 blocks, 64 KB ([Pages and cards](https://www.ownbox.io/sdk/guide/pages-and-cards)). **Tools:** 60 s to answer, 8 KB of words, two at a time
per machine and four per Ownbox.
