Reference: HTTP API
The endpoints of
rzb serve, the fields each one accepts, refuses or ignores, and what it answers. Error bodies and status codes are in the errors reference; the server's options in the command-line reference and the configuration reference.
The examples use mlx-community/Qwen3-4B-4bit as chat model and BAAI/bge-small-en-v1.5 as embedding model, both pulled beforehand with rzb models pull. The compatibility suite runs every curl example of this page against a real server (scripts/compat.sh).
General rules
| Rule | Value |
|---|---|
| Base URL | http://<host>:<port>/v1, by default http://127.0.0.1:7920/v1 |
| Request body | JSON (Content-Type: application/json), at most 16 MiB (larger: 413) |
| Response body | JSON, compact, keys sorted; streams are Server-Sent Events |
| Authentication | Authorization: Bearer <key> on every route except /health, when the server has an API key (--api-key-env); none otherwise |
| CORS | Off, unless --cors-origin / server.cors_origin is set |
| Unknown fields | Ignored, as OpenAI does, unless listed as refused below |
| Connections | Generation endpoints answer with Connection: close (the server watches the connection to stop a generation whose client has left) |
| Concurrency | One generation at a time per model; other requests for that model wait in a queue (limits) |
Endpoints
| Method and path | Purpose |
|---|---|
GET /health |
Liveness check, no authentication |
GET /v1/models |
Models the server can serve |
GET /v1/models/{id} |
One of them ({id} may contain /) |
POST /v1/chat/completions |
Chat answer, plain or streamed, with structured output, tools and reasoning |
POST /v1/completions |
Legacy text completion: the prompt is continued as raw text |
POST /v1/embeddings |
Embedding vectors |
Any other path answers 404 with code unknown_url.
GET /health
curl -s http://127.0.0.1:7920/health
Answer: {"status":"ok"}, status 200, whenever the process is up.
GET /v1/models
curl -s http://127.0.0.1:7920/v1/models
Answer: {"object": "list", "data": [<model>, …]}. The list holds, in this order: the models declared in the configuration (under their id), then the loadable models of the Hugging Face cache, then models loaded by their Hugging Face id that are neither.
Field of <model> |
Type | Value |
|---|---|---|
id |
string | The name to put in "model" |
object |
string | "model" |
created |
integer | The server's start time (Unix seconds) |
owned_by |
string | "razorbill" |
loaded |
boolean | razorbill extension: in memory now |
kind |
string | razorbill extension: chat or embedding. A cached model that is not declared is reported as chat (the cache does not record the kind) |
GET /v1/models/{id} answers one <model>, or 404 model_not_found.
Model names
The "model" of a request is, in this order of lookup:
- the
idof a model declared in the configuration; itskindmust match the endpoint (chat for completions, embedding for embeddings), otherwise 400; - a Hugging Face repository id,
org/nameororg/name@revision, of a model in MLX format. It is downloaded on its first use if it is not in the cache, and taken to be of the endpoint's kind. A repository the cache shows without.safetensorsweights (GGUF, for instance) is refused with 400model_not_supported.
Anything else is a 404 model_not_found.
POST /v1/chat/completions
curl -s http://127.0.0.1:7920/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "mlx-community/Qwen3-4B-4bit",
"messages": [
{"role": "system", "content": "Answer in one sentence."},
{"role": "user", "content": "What is MLX?"}
],
"temperature": 0.2,
"max_tokens": 200
}'
Request fields
| Field | Type | Default | Description |
|---|---|---|---|
model |
string | required | See model names |
messages |
array | required, not empty | See messages |
temperature |
number, 0–2 | configuration, else 0.6 |
Sampling temperature |
top_p |
number, >0–1 | configuration, else 1.0 |
Nucleus sampling |
max_tokens |
integer ≥ 1 | configuration, else 1024 |
Most tokens generated, reasoning included |
max_completion_tokens |
integer ≥ 1 | — | Same as max_tokens; wins when both are sent |
stop |
string or array of ≤ 4 strings | none | The answer ends before the first occurrence; finish_reason is then stop |
seed |
integer | random | Sampler seed: same seed and settings, same answer |
presence_penalty |
number, −2–2 | none | Penalises tokens present among the last 20 tokens (prompt included) |
frequency_penalty |
number, −2–2 | none | Penalises tokens by their frequency among the last 20 tokens (prompt included) |
top_k |
integer ≥ 0 | configuration, else 0 (off) |
Extension (vLLM, llama-server, Ollama, mlx-lm): sample among the top_k most likely tokens only |
min_p |
number, 0–1 | configuration, else 0 (off) |
Extension: drop tokens less likely than min_p × the most likely one |
repetition_penalty |
number > 0 | configuration, else none | Extension: divides the score of tokens seen in the last repetition_context_size tokens (prompt included); above 1 discourages repeats |
repetition_context_size |
integer ≥ 1 | configuration, else 20 |
Extension (mlx-lm's name): how many recent tokens repetition_penalty looks at |
stream |
boolean | false |
Stream the answer as Server-Sent Events (streaming) |
stream_options.include_usage |
boolean | false |
Add a last chunk with usage |
response_format |
object | {"type": "text"} |
text, json_object or json_schema; see structured output |
tools |
array | none | Functions the model may call; see tools |
tool_choice |
string or object | auto with tools, none without |
none, auto, required, or {"type": "function", "function": {"name": "…"}} |
parallel_tool_calls |
boolean | true; false for a forced call |
false: at most one call |
reasoning_effort |
string | configuration | none and minimal turn thinking off; low, medium, high turn it on (all three alike) |
chat_template_kwargs.enable_thinking |
boolean | — | vLLM's switch; wins over reasoning_effort |
thinking_budget |
integer ≥ 0 | configuration | razorbill extension: most tokens of reasoning before the model must answer |
include_reasoning |
boolean | configuration, else true |
OpenRouter's switch: false leaves out reasoning_content (the model still thinks) |
The configuration's locked values win over the request: temperature, top_p, top_k, min_p, repetition_penalty, repetition_context_size, thinking and show_reasoning are imposed, max_tokens and thinking_budget are ceilings (configuration reference).
Refused fields
These fields answer 400 naming the field, rather than being silently ignored:
| Field | Refused when |
|---|---|
n |
other than 1 |
logprobs |
true |
a message with role other than system, developer, user, assistant, tool |
always |
a content part of type other than text (images, audio…) |
always |
response_format combined with a forced tool call |
tool_choice is required or names a function, or a tool is strict |
Messages
| Role | Fields | Notes |
|---|---|---|
system, developer |
content |
developer is treated as system |
user |
content |
|
assistant |
content (may be null), tool_calls |
Previous answers, with the calls the model made |
tool |
content, tool_call_id, name |
The result of a call |
content is a string or an array of {"type": "text", "text": "…"} parts, joined with a line break. In tool_calls, function.arguments must be a JSON object encoded as a string, as OpenAI sends it.
The conversation is rendered with the model's own chat template. The server keeps no state between requests.
Response
{
"id": "chatcmpl-…",
"object": "chat.completion",
"created": 1764096042,
"model": "mlx-community/Qwen3-4B-4bit",
"choices": [{
"index": 0,
"message": {"role": "assistant", "content": "…", "reasoning_content": "…", "tool_calls": […]},
"logprobs": null,
"finish_reason": "stop"
}],
"usage": {"prompt_tokens": 20, "completion_tokens": 9, "total_tokens": 29,
"completion_tokens_details": {"reasoning_tokens": 120}}
}
| Field | Present | Value |
|---|---|---|
id |
always | chatcmpl- and 24 hexadecimal digits |
model |
always | The "model" of the request, as sent |
message.content |
always | The answer; null when the model only called tools |
message.reasoning_content |
when the model thought and reasoning is shown | The reasoning, without the <think> tags |
message.tool_calls |
when the model called tools | [{"id", "type": "function", "function": {"name", "arguments"}}], arguments a JSON string |
finish_reason |
always | stop, length (token limit) or tool_calls |
usage.prompt_tokens_details.cached_tokens |
when part of the prompt was reused | Prompt tokens taken from the KV cache of the previous request instead of being read again; included in prompt_tokens (why) |
usage.completion_tokens_details.reasoning_tokens |
when the model thought | Pieces of reasoning received (about one per token), also counted when reasoning is hidden |
When a stop sequence ends the answer, the engine is interrupted before it reports its counts: usage then counts one token per piece of text and prompt_tokens is 0.
Structured output
response_format |
Effect |
|---|---|
{"type": "text"} |
No constraint |
{"type": "json_object"} |
The answer is one JSON object |
{"type": "json_schema", "json_schema": {"name": "…", "schema": {…}, "strict": true}} |
The answer is one JSON value valid against schema |
- The constraint is enforced while tokens are generated (constrained decoding, on macOS with MLX); a reasoning model thinks freely first, and the constraint applies after its reasoning.
- The server adds one instruction to the system message (a system message is created if there is none):
Answer with a single JSON object.forjson_object;Answer with a single JSON object that follows this JSON Schema:followed by the schema forjson_schema. - Object properties are generated in the order the schema lists them.
- With
"strict": true, a schema that uses a keyword the decoder cannot enforce is refused with 400 naming it and where it is:not,if,then,else,dependentRequired,dependentSchemas,multipleOf,uniqueItems,contains,minContains,maxContains. Withoutstrict, such keywords are ignored.
curl -s http://127.0.0.1:7920/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "mlx-community/Qwen3-4B-4bit",
"messages": [{"role": "user", "content": "Describe Lyon."}],
"response_format": {"type": "json_schema", "json_schema": {"name": "city", "strict": true,
"schema": {"type": "object", "additionalProperties": false, "required": ["name", "country"],
"properties": {"name": {"type": "string"}, "country": {"type": "string"}}}}},
"reasoning_effort": "none"
}'
Tools
tools[i] field |
Type | Rules |
|---|---|---|
type |
string | "function" |
function.name |
string | 1–64 letters, digits, _ or -; unique |
function.description |
string | Optional |
function.parameters |
object | A JSON Schema object; default {"type": "object", "properties": {}} |
function.strict |
boolean | true: the arguments are generated under the schema (same keyword limits as strict structured output) |
tool_choice |
Effect |
|---|---|
none |
Tools are not offered to the model; it answers in text |
auto |
The model decides; its calls are parsed from its output |
required |
The answer is tool calls only, generated under a grammar |
{"type": "function", "function": {"name": "f"}} |
The answer is one call to f, generated under a grammar |
- Forced calls (
required, a named function, or astricttool) are only possible for models whose tool-call syntax is<tool_call>{"name": …, "arguments": …}</tool_call>(Qwen, Hermes and similar). For other families (Llama 3, Mistral, Gemma…) they answer 400;autoworks for every family mlx-swift-lm can parse. - A forced call produces one call, unless
parallel_tool_callsistrue. - With
parallel_tool_calls: false, calls after the first are dropped.
curl -s http://127.0.0.1:7920/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "mlx-community/Qwen3-4B-4bit",
"messages": [{"role": "user", "content": "What is the weather in Lyon?"}],
"tools": [{"type": "function", "function": {"name": "get_weather",
"description": "Current weather for a city",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}}],
"tool_choice": "required",
"reasoning_effort": "none"
}'
POST /v1/completions
The legacy text-completion endpoint. The prompt is tokenized as is and continued: no chat template, no thinking, no tool-call parsing.
curl -s http://127.0.0.1:7920/v1/completions \
-H "Content-Type: application/json" \
-d '{"model": "mlx-community/Qwen3-4B-4bit", "prompt": "The capital of France is", "max_tokens": 8, "temperature": 0}'
| Field | Type | Default | Description |
|---|---|---|---|
model |
string | required | A chat model (model names) |
prompt |
string, or array of one string | required | The text to continue |
max_tokens |
integer ≥ 1 | configuration, else 1024 (OpenAI's default is 16) |
Most tokens generated |
temperature, top_p, stop, seed, presence_penalty, frequency_penalty, top_k, min_p, repetition_penalty, repetition_context_size |
As for chat completions | ||
echo |
boolean | false |
Put the prompt before the completion in text |
stream, stream_options.include_usage |
false |
As for chat completions |
Refused with 400: suffix (no fill-in-the-middle), logprobs above 0, n or best_of other than 1, several prompts, token arrays.
Response: {"id": "cmpl-…", "object": "text_completion", "created", "model", "choices": [{"text", "index": 0, "logprobs": null, "finish_reason"}], "usage"}. A stream sends objects of the same shape, each with a piece of text; with echo, the first one holds the prompt.
POST /v1/embeddings
curl -s http://127.0.0.1:7920/v1/embeddings \
-H "Content-Type: application/json" \
-d '{"model": "BAAI/bge-small-en-v1.5", "input": ["The cat sits on the mat.", "A feline rests on a rug."]}'
| Field | Type | Default | Description |
|---|---|---|---|
model |
string | required | An embedding model (model names) |
input |
string or array of 1–2048 strings | required | Texts to embed; none may be empty. Token arrays are refused |
encoding_format |
float or base64 |
float |
base64: each vector as little-endian float32 bytes, Base64-encoded |
dimensions |
integer ≥ 1 | the model's size | Keep the first dimensions values and renormalise (for Matryoshka models); larger than the model's size: 400 |
Response: {"object": "list", "data": [{"object": "embedding", "index": i, "embedding": […]}], "model", "usage": {"prompt_tokens", "total_tokens"}}. Vectors are L2-normalised. A text longer than the model accepts is a 400 naming input[i] and the limit. Inputs are embedded in batches of 32. Pooling follows the model's sentence-transformers configuration.
Streaming
With "stream": true, the answer is text/event-stream:
data: {"id":"chatcmpl-…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}],…}
data: {…"choices":[{"index":0,"delta":{"content":"Hel"},…}]…}
data: {…"choices":[{"index":0,"delta":{},"finish_reason":"stop"}]…}
data: [DONE]
- Chat chunks: a first chunk with
delta.role, then pieces indelta.content,delta.reasoning_contentordelta.tool_calls(each call whole, with itsindex), then an empty delta withfinish_reason. - With
stream_options.include_usage, every chunk has"usage": nulland a last chunk with emptychoicescarries theusage. - While the model produces nothing (loading, long prompt), a comment line
: keep-aliveis sent every 5 seconds; SSE clients ignore it. - An error after the stream started is sent as one last event
data: {"error": {…}}, without[DONE]. - When the client disconnects, the generation stops and the model is freed for the next request.
curl -sN http://127.0.0.1:7920/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "mlx-community/Qwen3-4B-4bit", "messages": [{"role": "user", "content": "Count to 5."}],
"stream": true, "stream_options": {"include_usage": true}, "reasoning_effort": "none"}'
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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|