bots-garden/razorbillpublic Fork
⑂ main
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/razorbill.git
git clone ssh://git@rickub.com/bots-garden/razorbill.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP
configuration.md · 143 lines · 7.6 KBmarkdown
Blame HistoryOpen raw

Reference: server configuration file

Every key of the YAML file given to rzb serve --config <file>, its type, default and checks. Check a file without starting the server with rzb config validate <file>. A commented example is in examples/server.yaml.

The preferences of rzb tui have a file of their own: see the rzb tui reference.

Every section is optional; an empty file, or no file at all, is a valid configuration. Unknown keys are errors. Every problem of a file is reported at once, with its key path and line number; the exit code is then 2.

server:
  host: 127.0.0.1
  port: 7920
  api_key_env: RZB_API_KEY
defaults:
  temperature: 0.6
  max_tokens: 2048
locked:
  max_tokens: 8192
models:
  - id: qwen3
    source: mlx-community/Qwen3-4B-4bit
    defaults: { thinking: true, thinking_budget: 512 }
  - id: embed
    source: BAAI/bge-small-en-v1.5
    kind: embedding
    preload: true
limits:
  max_loaded_models: 2
  keep_alive: 10m
  max_queue: 16

Top-level keys

Key Type Description
server mapping Network settings (server)
defaults mapping Generation settings every model starts from (defaults and locked)
locked mapping Generation settings clients cannot change or exceed
models list Models declared by name (models)
limits mapping Memory and queue limits (limits)

server

Command-line options win over these keys (rzb serve).

Key Type Default Description
host string, not empty 127.0.0.1 Address to listen on; 0.0.0.0 for every interface
port integer, 1–65535 7920 TCP port
api_key_env string, not empty RZB_API_KEY Name of the environment variable holding the API key. The key itself never goes in the file. When the variable is set and not empty, every route except /health needs Authorization: Bearer <key>
cors_origin string, not empty none (CORS off) Origin allowed to call the API from a browser; * for any origin

Warnings at start-up: listening on a non-loopback address without an API key; cors_origin: "*" without an API key.

defaults and locked

The same keys, in the top-level defaults / locked and in each model's defaults / locked.

Key Type Built-in default In locked
temperature number, 0–2 0.6 imposed
top_p number, >0–1 1.0 imposed
top_k integer ≥ 0 0 (off) imposed
min_p number, 0–1 0 (off) imposed
repetition_penalty number > 0 none imposed
repetition_context_size integer ≥ 1 20 imposed
max_tokens integer ≥ 1 1024 ceiling (a smaller request is kept)
thinking boolean false imposed
thinking_budget integer ≥ 0, smaller than max_tokens of the same block none (no limit) ceiling
show_reasoning boolean true imposed
  • thinking: whether a reasoning model (Qwen3…) thinks before answering. Models that do not reason ignore it.
  • thinking_budget: most tokens of reasoning; the model is then made to answer. Refused at request time (400) for models with no known reasoning protocol.
  • top_k, min_p, repetition_penalty, repetition_context_size: the sampling settings mlx-swift-lm implements beyond OpenAI's, with the meaning given in the HTTP API reference. Some model cards recommend values (Qwen3: top_k: 20); they are not read from the model.
  • show_reasoning: send the reasoning to clients (reasoning_content). With false, the model still thinks and reasoning_tokens still counts it.

The settings of a request are computed in this order, each step replacing the previous values it sets: built-in defaults → top-level defaults → the model's defaults → the request's fields → top-level locked → the model's locked. Models used by their Hugging Face id (not declared) get only the top-level blocks.

models

A list of entries. Clients may also use any Hugging Face id in MLX format without declaring it.

Key Type Default Description
id string, not empty, unique required The name clients send as "model"
source string one of source / path required Hugging Face id, org/name
revision string main Branch, tag or commit of source; not allowed with path
path string — Directory of a model on disk (config.json, tokenizer, *.safetensors); ~ is expanded, a relative path starts at the configuration file's folder
kind chat or embedding chat Which endpoints the model serves
preload boolean false Load at start-up instead of on the first request
defaults mapping none Generation defaults for this model (keys)
locked mapping none Locked settings for this model

limits

Key Type Default Description
max_loaded_models integer ≥ 1 1 Models kept in memory at once; beyond it, the least recently used idle model is unloaded
keep_alive duration (30s, 10m, 1h) 10m An idle model is unloaded after this long
max_queue integer ≥ 1 16 Requests waiting for one model; more get a 429

Besides these limits, the weights loaded at once may not exceed 75 % of the Mac's memory: a model that cannot fit after unloading idle models gets a 503.

Reloading

A running server reads its file again on POST /rzb/config/reload or SIGHUP. A file with problems changes nothing.

Key On reload
models Applies to the next request. A loaded model no declared id points to anymore is unloaded at once, or when its last request ends; a newly declared preload model starts loading
defaults, locked Apply to the next request, for every model
limits.max_queue Applies to the next request that has to wait
limits.max_loaded_models Applies to the next load; loaded models stay until then
limits.keep_alive Applies from the next idle sweep
server.host, server.port, server.api_key_env, server.cors_origin Ignored until the server restarts; listed in restart_required when changed, unless the matching command-line option is set

Errors

Problems are printed together, then rzb exits with code 2:

error: invalid configuration server.yaml
  - line 3: server.port: must be between 1 and 65535
  - line 9: models[0].kind: must be one of: chat, embedding
Message (after line N: <key path>:) Cause
unknown key (expected one of: …) Misspelt or unsupported key
must be between 1 and 65535 server.port out of range
must be between 0 and 2, must be above 0 and at most 1, … Value out of range
must be smaller than max_tokens (N) thinking_budget not below the max_tokens of the same block
must be a duration such as 30s, 10m or 1h Unreadable keep_alive
must be a list (lines starting with -) models is not a list
is required (the name clients send as "model") Model entry without id
duplicate id <id> Two entries with the same id
is required (a Hugging Face id, or path:) Neither source nor path
give either source or path, not both Both given
only applies to source revision with path
must be one of: chat, embedding Unknown kind
not valid YAML: … Syntax error
cannot read the file Missing or unreadable file
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Reference: server configuration file

> Every key of the YAML file given to `rzb serve --config <file>`, its type, default and checks. Check a file without starting the server with `rzb config validate <file>`. A commented example is in [`examples/server.yaml`](../../../examples/server.yaml).

The preferences of `rzb tui` have a file of their own: see the [`rzb tui` reference](tui.md#preferences-file-tuiyaml).

Every section is optional; an empty file, or no file at all, is a valid configuration. Unknown keys are errors. Every problem of a file is reported at once, with its key path and line number; the exit code is then 2.

```yaml
server:
  host: 127.0.0.1
  port: 7920
  api_key_env: RZB_API_KEY
defaults:
  temperature: 0.6
  max_tokens: 2048
locked:
  max_tokens: 8192
models:
  - id: qwen3
    source: mlx-community/Qwen3-4B-4bit
    defaults: { thinking: true, thinking_budget: 512 }
  - id: embed
    source: BAAI/bge-small-en-v1.5
    kind: embedding
    preload: true
limits:
  max_loaded_models: 2
  keep_alive: 10m
  max_queue: 16
```

## Top-level keys

| Key | Type | Description |
| --- | --- | --- |
| `server` | mapping | Network settings ([server](#server)) |
| `defaults` | mapping | Generation settings every model starts from ([defaults and locked](#defaults-and-locked)) |
| `locked` | mapping | Generation settings clients cannot change or exceed |
| `models` | list | Models declared by name ([models](#models)) |
| `limits` | mapping | Memory and queue limits ([limits](#limits)) |

## server

Command-line options win over these keys ([`rzb serve`](cli.md#rzb-serve)).

| Key | Type | Default | Description |
| --- | --- | --- | --- |
| `host` | string, not empty | `127.0.0.1` | Address to listen on; `0.0.0.0` for every interface |
| `port` | integer, 1–65535 | `7920` | TCP port |
| `api_key_env` | string, not empty | `RZB_API_KEY` | Name of the environment variable holding the API key. The key itself never goes in the file. When the variable is set and not empty, every route except `/health` needs `Authorization: Bearer <key>` |
| `cors_origin` | string, not empty | none (CORS off) | Origin allowed to call the API from a browser; `*` for any origin |

Warnings at start-up: listening on a non-loopback address without an API key; `cors_origin: "*"` without an API key.

## defaults and locked

The same keys, in the top-level `defaults` / `locked` and in each model's `defaults` / `locked`.

| Key | Type | Built-in default | In `locked` |
| --- | --- | --- | --- |
| `temperature` | number, 0–2 | `0.6` | imposed |
| `top_p` | number, >0–1 | `1.0` | imposed |
| `top_k` | integer ≥ 0 | `0` (off) | imposed |
| `min_p` | number, 0–1 | `0` (off) | imposed |
| `repetition_penalty` | number > 0 | none | imposed |
| `repetition_context_size` | integer ≥ 1 | `20` | imposed |
| `max_tokens` | integer ≥ 1 | `1024` | ceiling (a smaller request is kept) |
| `thinking` | boolean | `false` | imposed |
| `thinking_budget` | integer ≥ 0, smaller than `max_tokens` of the same block | none (no limit) | ceiling |
| `show_reasoning` | boolean | `true` | imposed |

- `thinking`: whether a reasoning model (Qwen3…) thinks before answering. Models that do not reason ignore it.
- `thinking_budget`: most tokens of reasoning; the model is then made to answer. Refused at request time (400) for models with no known reasoning protocol.
- `top_k`, `min_p`, `repetition_penalty`, `repetition_context_size`: the sampling settings mlx-swift-lm implements beyond OpenAI's, with the meaning given in the [HTTP API reference](http-api.md#request-fields). Some model cards recommend values (Qwen3: `top_k: 20`); they are not read from the model.
- `show_reasoning`: send the reasoning to clients (`reasoning_content`). With `false`, the model still thinks and `reasoning_tokens` still counts it.

The settings of a request are computed in this order, each step replacing the previous values it sets: built-in defaults → top-level `defaults` → the model's `defaults` → the request's fields → top-level `locked` → the model's `locked`. Models used by their Hugging Face id (not declared) get only the top-level blocks.

## models

A list of entries. Clients may also use any Hugging Face id in MLX format without declaring it.

| Key | Type | Default | Description |
| --- | --- | --- | --- |
| `id` | string, not empty, unique | required | The name clients send as `"model"` |
| `source` | string | one of `source` / `path` required | Hugging Face id, `org/name` |
| `revision` | string | `main` | Branch, tag or commit of `source`; not allowed with `path` |
| `path` | string | — | Directory of a model on disk (`config.json`, tokenizer, `*.safetensors`); `~` is expanded, a relative path starts at the configuration file's folder |
| `kind` | `chat` or `embedding` | `chat` | Which endpoints the model serves |
| `preload` | boolean | `false` | Load at start-up instead of on the first request |
| `defaults` | mapping | none | Generation defaults for this model ([keys](#defaults-and-locked)) |
| `locked` | mapping | none | Locked settings for this model |

## limits

| Key | Type | Default | Description |
| --- | --- | --- | --- |
| `max_loaded_models` | integer ≥ 1 | `1` | Models kept in memory at once; beyond it, the least recently used idle model is unloaded |
| `keep_alive` | duration (`30s`, `10m`, `1h`) | `10m` | An idle model is unloaded after this long |
| `max_queue` | integer ≥ 1 | `16` | Requests waiting for one model; more get a 429 |

Besides these limits, the weights loaded at once may not exceed 75 % of the Mac's memory: a model that cannot fit after unloading idle models gets a 503.

## Reloading

A running server reads its file again on [`POST /rzb/config/reload`](http-api.md#post-rzbconfigreload) or `SIGHUP`. A file with problems changes nothing.

| Key | On reload |
| --- | --- |
| `models` | Applies to the next request. A loaded model no declared `id` points to anymore is unloaded at once, or when its last request ends; a newly declared `preload` model starts loading |
| `defaults`, `locked` | Apply to the next request, for every model |
| `limits.max_queue` | Applies to the next request that has to wait |
| `limits.max_loaded_models` | Applies to the next load; loaded models stay until then |
| `limits.keep_alive` | Applies from the next idle sweep |
| `server.host`, `server.port`, `server.api_key_env`, `server.cors_origin` | Ignored until the server restarts; listed in `restart_required` when changed, unless the matching command-line option is set |

## Errors

Problems are printed together, then `rzb` exits with code 2:

```
error: invalid configuration server.yaml
  - line 3: server.port: must be between 1 and 65535
  - line 9: models[0].kind: must be one of: chat, embedding
```

| Message (after `line N: <key path>:`) | Cause |
| --- | --- |
| `unknown key (expected one of: …)` | Misspelt or unsupported key |
| `must be between 1 and 65535` | `server.port` out of range |
| `must be between 0 and 2`, `must be above 0 and at most 1`, … | Value out of range |
| `must be smaller than max_tokens (N)` | `thinking_budget` not below the `max_tokens` of the same block |
| `must be a duration such as 30s, 10m or 1h` | Unreadable `keep_alive` |
| `must be a list (lines starting with -)` | `models` is not a list |
| `is required (the name clients send as "model")` | Model entry without `id` |
| `duplicate id <id>` | Two entries with the same `id` |
| `is required (a Hugging Face id, or path:)` | Neither `source` nor `path` |
| `give either source or path, not both` | Both given |
| `only applies to source` | `revision` with `path` |
| `must be one of: chat, embedding` | Unknown `kind` |
| `not valid YAML: …` | Syntax error |
| `cannot read the file` | Missing or unreadable file |