Inference Server
Deploy fine-tuned models as an OpenAI-compatible API server.
Transformers Backend
pip install "soup-cli[serve]"
soup serve --model ./output --port 8000Simple HTTP API using HuggingFace Transformers. Good for testing and low-traffic use.
vLLM Backend
Upstream's documentation describes it as 2 to 4 times the throughput of the transformers backend; Soup publishes no measurement of that on any card, so measure your own load.
Install
[serve-fast]in a different environment from[train]. Their accelerator stacks can resolve differenttorchbuilds:pip install vllminto a training environment can silently replace thetorchSoup was installed against, producing an environment outside the bounds Soup declares, with no warning at install time. Since v0.73.3,soup env checkcatches that after the fact, exit 3, without needing a lock file. Not creating it is cheaper.
pip install "soup-cli[serve-fast]"
soup serve --model ./output --backend vllm
# Multi-GPU with tensor parallelism
soup serve --model ./output --backend vllm --tensor-parallel 2
# Control GPU memory usage
soup serve --model ./output --backend vllm --gpu-memory 0.8
# Cap the context vLLM reserves KV cache for (v0.73.0, vLLM only)
soup serve --model ./output --backend vllm --max-model-len 8192Recommended for production. Uses PagedAttention for high throughput. --max-model-len is the knob to reach for when vLLM refuses to start because the model's declared context window would need more KV cache than the card has: lower it and the engine reserves less. A value below 1 exits 1, and on any other backend the flag prints a warning and is ignored. The [serve-fast] extra floors vllm>=0.4.3 since v0.76.0 (#892): the backend now hands the engine a token-id mapping, which vLLM accepts as the first argument only from 0.4.3 on.
KV-cache type
The KV cache is usually the second-largest thing in VRAM while serving, after the weights, and it grows with context length rather than with model size.
soup serve --model ./output --kv-cache-type bf16 # or f16, q8_0 (fp8 is accepted by the config but cannot be served)bf16andf16set the cache dtype and need no extra dependency.q8_0is an 8-bit cache through the HQQ backend:pip install hqq. With neitherhqqnoroptimum-quantoinstalled the command exits 2 with the install hint rather than falling back quietly. With onlyoptimum-quantoinstalled the server starts anyway, and the cache it asks transformers for is still HQQ's (what a request then returns was not checked).fp8is accepted by the config and cannot be served today: the transformers backend has no fp8 KV-cache path, and the vLLM / SGLang routing that would provide one is not wired, so it raises either way. The Hopper SM 9.0 check only picks which error you see.
Transformers backend only. Routing this flag through vLLM and SGLang is still open upstream: with --backend vllm, sglang or mii, --kv-cache-type exits 2 with a message ending Use --backend transformers.
SGLang Backend
pip install "soup-cli[sglang]"
soup serve --model ./output --backend sglang
# Multi-GPU
soup serve --model ./output --backend sglang --tensor-parallel 2Alternative high-throughput backend with RadixAttention. It serves /v1/chat/completions, /v1/models and /health; the Anthropic-shaped /v1/messages endpoint is served by the transformers and vLLM backends, not by SGLang.
A LoRA adapter passed as --model is applied since v0.77.0 (#1732). The adapter is served on its base model (read from adapter_config.json, or --base) and registered in the engine under the name adapter, and every request names it, streaming or not; a full model's requests name no adapter and are unchanged. SGLang applies an adapter only to requests that name it, and through v0.76.1 Soup registered the adapter at startup but never named it, so every answer came from the base model while /v1/models and each response reported the adapter (#1724). If you evaluated or shipped an adapter through --backend sglang, those answers were the base model's: run them again. The backend now needs SGLang 0.5.1 or later, which the [sglang] extra installs (sglang>=0.5.1; it was >=0.2.0) and soup doctor checks: older releases refuse to start an engine with a LoRA adapter unless its radix cache is turned off, which Soup does not do.
v0.74.0 ported the two vLLM repairs that were still standing here. The prompt goes through the model's own chat template rather than a third hand-rolled copy, so a served model no longer sees a format it was never trained on, and finish_reason reports length on a truncated response instead of a hardcoded stop, on both the sync and streaming paths. (At v0.74.0, live verification of that port against a real SGLang runtime on Linux was an open follow-up. Since v0.76.0 this backend also posts token ids instead of a string when a chat template rendered the prompt; upstream's changelog reports that change measured end to end on SGLang 0.5.9. See Prompt encoding.)
Warning:Breaking in v0.74.0: this backend now obeys
--trust-remote-code. It had hardcoded it on at both runtime call sites, so a custom-code model executed its own repository code on this backend whether or not you opted in. The warning panel said so, but a notice is not a gate. A custom-code model now fails to load here without the flag, which is the same default-deny every other backend has had since v0.36. The same release also gave this backend the model's own chat template instead of a hand-rolledUser:/Assistant:prompt, and a realfinish_reasonoflengthwhen a response hitsmax_tokensinstead of a hardcodedstop.
A page you visit cannot drive your server (v0.75.1)
Until v0.75.1, on the default loopback bind with no token at all, /v1/tools/python, /v1/tools/bash, /v1/tools/web_search and /v1/thumbs checked neither the Host header nor Origin (0.53.7 to 0.75.0), and the adapter activate and deactivate routes could be driven by a cross-site request from any page (0.30.0 to 0.75.0). A web page the operator merely visited could therefore reach them through DNS rebinding. A token nobody was asked to set is not a control. Everything in this section describes the default transformers backend. Through v0.77.1 the vLLM, SGLang and MII backends had none of these checks; since v0.77.2 their generation routes have the Origin half and nothing else, as set out in Binding to a non-loopback host.
The check that shipped has two tiers, and the difference is deliberate:
| Routes | Check | Refusal |
|---|---|---|
Tool routes, /v1/thumbs, /v1/feedback, adapter activate, deactivate and load | Host must name the bound address, and any Origin must name the same | 421 for a foreign or missing Host (not on a wildcard bind, see below), 403 for a foreign Origin |
/v1/chat/completions, /v1/messages, GET /v1/adapters | Origin only | 403 for a foreign Origin |
/health, /metrics, /v1/models | none, by choice | they carry no generation cost and list no adapters (/health does report the name of the active one) |
POST /v1/feedback has one more rule (v0.78.0). It also answers 403 to a request that carries an Origin header unless that origin is the server's own (http:// or https:// plus the request's Host, nothing after it), so a page served by another site, another port or Origin: null cannot post feedback. A request with no Origin at all, which means curl, an SDK or a desktop application, is allowed. See Feedback.
The table describes the transformers backend. On vLLM, SGLang and MII only the second row's Origin rule applies, and only to the generation routes those apps have (since v0.77.2; see the end of Binding to a non-loopback host).
One exception, and it is the bind people use to reach the server from another machine. On a wildcard bind (--host 0.0.0.0 or ::) there is no single name to compare Host against, so the Host check is skipped and only Origin is tested, which must equal the request's own Host. A page that rebinds its own hostname to your server sends exactly that pair, so on a wildcard bind this check does not stop DNS rebinding. It still refuses a cross-site request whose Origin names a different site from its Host. Bind to the specific address you serve on to get the full check, and on any non-loopback bind treat the bearer token as the real control for the routes it covers.
Why the generation routes get only the narrower half: an inference route is the one a reverse proxy legitimately fronts under some other hostname, so refusing a foreign Host there would refuse every proxied deployment. A request carrying no Origin at all, which means curl, the OpenAI and Anthropic SDKs, and any proxy, is unaffected. What the Origin check buys is that a page the operator visits cannot drive generation or enumerate loaded adapters, which CORS alone does not prevent: CORS stops that page reading the reply, not sending the request.
The limit is stated upstream rather than left to be discovered, and it is worth repeating: none of this covers a non-browser client, which sends no Origin and can name the bind address in Host. For such a client the bearer token (--tool-auth-token) is the only protection, and it covers only the tool, thumbs, feedback and adapter routes (since v0.78.0 /v1/feedback and the fourth adapter route, POST /v1/adapters/load; before it, the tool routes, /v1/thumbs and three /v1/adapters routes). Generation (/v1/chat/completions, /v1/messages), /v1/models, /health and /metrics check no token on any backend, so a non-loopback bind publishes the model to whoever can reach the port. Put an authenticating reverse proxy in front of it, or keep it on loopback.
Two changes ride along. The tool token is now compared in constant time rather than with !=. And GET /v1/adapters, activate and deactivate now require that token too, with the check running before the 404 branches, so an unauthenticated probe cannot learn which adapter names are loaded from an "unknown adapter" reply. Through v0.75.0 those three routes ignored the token even when one was set (only the tool routes and /v1/thumbs checked it), so on a non-loopback bind anyone who could reach the port could list your adapters and switch the one being served. One disclosed consequence: soup loop's deploy step posts without an authorization header, so against a token-protected endpoint it now fails closed. (Since closed in v0.77.0: soup loop watch --tool-auth-token or SOUP_TOOL_AUTH_TOKEN sends the token, #1184; see soup loop.)
Binding to a non-loopback host (v0.74.0)
soup serve --model ./output --host 0.0.0.0 --tool-auth-token "$TOKEN"Here $TOKEN is a value that follows the token rule. Without the token that command now exits 2, where it used to print a warning and start anyway. The reason is that the endpoint the token protects changed underneath it: /v1/tools/bash was re-enabled behind real operating-system namespace and sandbox isolation, so it actually executes code now, and a warning is not a sufficient control over an executing endpoint reachable from the network. Where strict isolation is unavailable, Windows included, the endpoint fails closed with HTTP 501 rather than falling back to something weaker. It is not a filesystem sandbox, and the docs say so rather than implying one: the isolation cuts the network, and the code still runs as the server's user (see Tool endpoints: what bounds them).
The exit-2 rule applies to any --host other than 127.0.0.1, localhost or ::1, a LAN address included, and it runs before the backend is chosen. Only the transformers backend reads the token and has the Host check above. The vLLM, SGLang and DeepSpeed-MII backends read no token and check no Host, and the tool, thumbs, feedback and adapter routes do not exist on them. So --backend vllm --host 0.0.0.0 --tool-auth-token "$TOKEN" starts, and the token protects nothing, because no route on that app reads it. For those backends the network is the only boundary for a client that is not a browser: keep them on loopback or behind an authenticating proxy.
Since v0.77.2 their generation routes check Origin (#2329). The vLLM, SGLang and DeepSpeed-MII servers answer a generation request whose Origin names another site with 403, as the transformers server does: /v1/chat/completions on all three and /v1/messages on vLLM. It is the Origin-only rule of the second table row above (a request with no Origin, which means curl, the SDKs and a proxy, is served as before), so a page you visit cannot drive these servers from your browser. /v1/models, /health and /metrics still check nothing, and CORS on these apps is still loopback-only. Upstream lists this check as covered by tests, not exercised by hand before the release (the pre-release smoke run was on CPU), so treat it as new.
Since v0.76.0 the server says this at startup. On any bind beyond loopback it prints a yellow Note:. On the transformers backend it reads that --tool-auth-token is checked on the tool, thumbs, feedback and adapter routes only (since v0.78.0; through v0.77.2 the list read "tool, thumbs and adapter routes"), and that /v1/chat/completions, /v1/messages, /v1/models, /health and /metrics answer every client that can reach the port without a token; on a wildcard bind a second line adds that the Host header is not compared. On vLLM, SGLang and MII the note says that no route checks the token, generation included. The --host help string was updated to say the same. Nothing about which routes the token covers changed: the notice describes what this page already described. Since v0.77.2 the first line of the note also ends with a plain-HTTP sentence: soup serve has no TLS of its own, so requests travel in the clear (on the transformers backend, "the bearer token included"), and the note says to terminate TLS in a proxy in front. Since v0.77.0 the --tool-auth-token help string matches the guard: without the token, it says, /v1/tools/python and /v1/tools/bash answer 401 on every bind and a non-loopback --host is refused; since v0.77.2 it also names /v1/thumbs and the three adapter routes, as this page does, and states the token rule below (#2268, #2329); since v0.78.0 it names /v1/feedback as well (the --host help names it too), and the --adapter-dir help says that POST /v1/adapters/load needs the token. (Through v0.76.1 it still said "Strongly recommended" for a non-loopback host.) A token given through SOUP_TOOL_AUTH_TOKEN passes the same host guard and the same token rule as the flag.
The code routes need the token on every bind (v0.77.0)
Since v0.77.0 /v1/tools/python and /v1/tools/bash need --tool-auth-token on every bind, loopback included (#2174). A server started without a token answers both with 401 before the request's content is used, and the reply names the fix: Authentication required: /v1/tools/python and /v1/tools/bash need a token on every bind. Start soup serve with --tool-auth-token <secret> (or set SOUP_TOOL_AUTH_TOKEN) and send 'Authorization: Bearer <secret>'. A server that has a token answers a missing or wrong one with 401 Invalid or missing bearer token. Since v0.77.1 every 401 from the tool, thumbs and adapter routes carries a WWW-Authenticate: Bearer header, and at the v0.78.0 tag the same holds for the 401s of /v1/feedback, POST /v1/adapters/load and the X-Soup-Internal header: soup serve has six places that send a 401 and all six set it (it had three at v0.77.1). --tool-auth-token also reads SOUP_TOOL_AUTH_TOKEN, which keeps the token off the command line and out of the shell history:
export SOUP_TOOL_AUTH_TOKEN="$(python -c 'import secrets; print(secrets.token_urlsafe(32))')"
soup serve --model ./output
curl -X POST http://127.0.0.1:8000/v1/tools/python \
-H "Authorization: Bearer $SOUP_TOOL_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"code": "print(1)"}'The token must follow one rule (v0.77.2)
Since v0.77.2 (#2329) soup serve checks --tool-auth-token (or SOUP_TOOL_AUTH_TOKEN) with the rule soup ui and soup mcp serve use: 16 to 128 characters from A-Z, a-z, 0-9, _ and -. Through v0.77.1 soup serve accepted any non-empty value. A value outside the rule exits 2 before the model loads, on every bind, loopback included, whether it came from the option or from the environment variable; the message names the rule and never prints the value. All three commands match the whole value, so a token with a trailing newline is refused too. An empty value counts as no token, so the non-loopback check above answers instead. Generate a valid one with python -c "import secrets; print(secrets.token_urlsafe(32))" and send the same value as Authorization: Bearer <token>. A server you started on v0.77.1 with a shorter token does not start on v0.77.2 until you change it, and a soup loop watch --tool-auth-token that talks to it needs the new value too.
soup serve still starts without a token on loopback, and the other routes keep their rule: /v1/tools/web_search, /v1/thumbs, /v1/feedback and the adapter routes GET /v1/adapters, activate and deactivate take a token on a loopback bind only when the server has one (always on a non-loopback bind), and generation, /v1/models, /health and /metrics take none on any bind. POST /v1/adapters/load is the third route that needs the token on every bind, loopback included (v0.78.0): without one it answers 401 Authentication required: POST /v1/adapters/load needs a token on every bind. Start soup serve with --tool-auth-token <secret> (or set SOUP_TOOL_AUTH_TOKEN) and send 'Authorization: Bearer <secret>'., before it says whether the route is enabled (see Loading adapters at runtime). This is the transformers backend; the vLLM, SGLang and MII apps have no tool routes. The isolation the two routes now require (see Tool endpoints) cuts the network, but the code still runs as the server's user, so use a long random token. Through v0.76.1 both code routes answered a tokenless loopback request.
Device selection (v0.76.0)
soup serve --model ./output --device cuda:1
soup serve --model ./output --device cpu--device takes cuda, cuda:<index>, mps or cpu, in any case (mlx is also accepted and loads like cpu). Any other value exits 2 and names the accepted ones before the model loads. This is soup serve: soup infer --backend mlx (v0.77.1) takes no --device at all, and any value exits 1 (see Native MLX generation). On the transformers backend the base model, a merged model and the speculative draft model all follow the same rule:
--device | Placement | Dtype |
|---|---|---|
cpu | Pinned to the CPU | float32 |
cuda:<index>, mps | Pinned to that device | float16 |
cuda | device_map="auto" | float16 |
An explicit --kv-cache-type bf16 or f16 still sets the load dtype on every device. Through v0.75.2 the argument never reached the loader, so --device cpu still placed the model on a visible GPU and cuda:N was accepted and ignored.
This changes the default on a machine with no GPU. The device is auto-detected when you do not pass --device, so the rule applies without the flag: on a CPU-only host the model now loads in float32 pinned to the CPU, which doubles its RAM use. Upstream's changelog gives a 7B model as about 28 GB instead of 14 GB. The placement rules above are the transformers backend's, as the flag's own help says.
Speculative decoding
# Transformers backend
soup serve --model ./output --speculative-decoding small-draft-model --num-speculative-tokens 5
# vLLM backend
soup serve --model ./output --backend vllm --speculative-decoding small-draft-modelA smaller draft model proposes tokens the target verifies in one pass, keeping the target's exact output. Whether that is actually faster depends on the pair, so measure it rather than assume: soup draft measure reports the real acceptance rate and plain-vs-assisted throughput, and on the pair we validated it came out at 0.55 to 0.64x, a net slowdown. A high acceptance rate does not settle it either: upstream's documentation cites a Llama-3.1-8B target with a Llama-3.2-1B draft on one H100, where 81.3% acceptance still ran at 0.48x of plain decoding. Since v0.76.0 measure also reports a break-even acceptance rate and a best draft length.
--auto-quant is refused (v0.76.0)
soup serve --auto-quant exits 2. Soup cannot compare GGUF, AWQ, GPTQ, FP8 and an unquantized baseline before a serving engine has loaded them, and through v0.75.2 the flag timed three calls to a stub that returned a constant, so its choice came from timer noise. On vLLM that choice could force AWQ, GPTQ or FP8 on a checkpoint that did not declare it. vLLM now follows the checkpoint's own quantization metadata. If you served with --auto-quant on vLLM before, check which quantization the engine actually loaded. To serve a quantized model, quantize the checkpoint explicitly (see Model Export) and serve that without the flag.
Batch inference, CUDA graphs and benchmarks (v0.76.0)
soup infer takes --batch-size N to generate several prompts together, and an experimental --cuda-graphs that replays CUDA graphs for decoding on a resident, unquantized Qwen2 or Llama model. soup bench is now a command group with infer and train. Details, and what each flag refuses, are on the soup bench page. Upstream's record for --cuda-graphs: on one RTX 5070 Laptop, unpinned, Qwen2.5-1.5B FP16, the slowest run with graphs decoded 2.9x faster than the fastest run without (benchmarks/gate-v0.76.0-cuda-graph-decode.md). soup serve has no --cuda-graphs flag.
Multi-Adapter Serving (v0.22.0+)
Serve multiple LoRA adapters on a single base model:
soup serve --model ./base --adapters chat=./adapters/chat --adapters code=./adapters/codeSelect an adapter per request with an adapter field in the request body. It is not the model field: model is ignored for selection, so "model": "chat" quietly runs whichever adapter is active, or the base model.
{"adapter": "chat", "messages": [{"role": "user", "content": "Hello!"}]}A request with no adapter uses the one chosen with POST /v1/adapters/activate/<name>, or the base model if none is active, and an unknown name is a 404. --adapters needs --backend transformers, and every adapter path must sit under the working directory. --adapter-dir is its runtime counterpart: it lets a running server load more adapters without a restart (see Loading adapters at runtime).
Canary routing (v0.76.0). Through v0.75.2 soup loop canary recorded a canary adapter and its traffic share in .soup/loop.yaml and soup serve never read them, so no request was ever routed. Since v0.76.0 the transformers backend hashes a request's conversation key (conversation_id in the body, or an X-Conversation-Id header) and sends it to the canary adapter or to the stable model at the recorded share. It does so only when the canary adapter was loaded with --adapters (since v0.78.0 also with POST /v1/adapters/load), the request names no adapter of its own (an explicit choice is honoured), and the request carries a key; any other request follows normal activation. Since v0.78.0 the stable side is the promoted production adapter, or the served base model before any promotion, even when another adapter was activated by hand. Each routed generation's outcome is buffered and flushed to disk after 64 outcomes or two seconds, so the stats soup loop watch reads can lag traffic by up to that window. See soup loop.
Response ids, feedback and traces (v0.78.0)
These three parts of the transformers backend are the server half of the continual-learning loop. They also work without it: any application can read the ids, post feedback and read the trace file.
Response ids
Every answer to /v1/chat/completions and /v1/messages gets a fresh UUID in lowercase canonical form, returned as the body field response_id and as the X-Response-Id header (the header is in the CORS exposed headers). The id field of a chat completion (chatcmpl-...) is unchanged. A streamed chat completion carries the header and puts response_id in every data: chunk; a streamed /v1/messages reply carries the header and message.response_id in message_start. A request whose generation fails (HTTP 500) gets no id and writes no record. The ids exist whether or not --trace-log is set, and X-Conversation-Id and X-User-Id reach /v1/messages generation as they do on /v1/chat/completions.
--feedback-log and POST /v1/feedback (v0.78.0)
export SOUP_TOOL_AUTH_TOKEN="$(python -c 'import secrets; print(secrets.token_urlsafe(32))')"
soup serve --model ./output --trace-log traces/serve.jsonl --feedback-log feedback.jsonl--feedback-log <path> turns on POST /v1/feedback; without the flag the route answers 404 feedback recording not enabled; start soup serve with --feedback-log. The path must stay under the working directory, the file is JSONL and append-only, and it is created owner-only (0600) on POSIX. It is never rotated: at 256 MiB the route answers 507 naming the file and appends nothing (a constant, not a flag). The body is a JSON object of at most 64 KiB (413 above that):
| Field | Meaning |
|---|---|
response_id | Required. An id this server process issued. The server remembers the last 100,000 in memory, so feedback for an answer given before a restart is 404 unknown response_id. |
kind | Required. thumb (value 1, -1 or null to clear), rating (value 1 to 5 or null), edit (edited_text, a non-empty string; null withdraws an earlier edit) or comment (comment, a non-empty string of at most 10,000 characters). |
comment, user_ref | Optional on every kind: free text (at most 10,000 characters) and an opaque reference of 1 to 256 characters that your application chooses for the person. edited_text (at most 20,000 characters) is read for edit only; the server drops it on any other kind. |
The server adds schema_version, id, ts and source: "soup-serve", and masks credential shapes before the line is written: Hugging Face tokens, OpenAI-style keys, GitHub tokens, AWS access keys, Slack tokens, Bearer tokens, JWTs, PEM private keys and api_key=, secret=, password: and token= assignments. The masking is pattern-based and best-effort, so read a log before you share it. The answers: {"status": "ok", "id": "<uuid>"}; 400 Invalid request: <field> naming the field and never the value; 403 for a foreign Origin; 404 as above; 413; 507; and 500 when the line cannot be written, never ok. The latest line per (response_id, kind) wins for thumbs, ratings and edits, and comments accumulate. The format is defined in upstream's Loop data formats.
Feedback is training data. The edits that reach the loop through this route are trained on as they are, and the loop's verdict checks a candidate against them. On a loopback server started without --tool-auth-token, every local user and process can post to it: the Host and Origin checks keep web pages out, not local programs. On a shared machine start soup serve with a token and give it only to the application that collects feedback. The loop does not judge whether an edit is right or well meant.
What --trace-log writes now
--trace-log takes the path of a JSONL file, not a directory: a directory starts the server and records nothing (run). Each answer is one version-1 conversation record per line:
| Field | Meaning |
|---|---|
schema_version | 1. |
id | The answer's response_id. |
conversation_id | The body field, else the X-Conversation-Id header, else null (also null when the header is empty or longer than 512 characters). |
ts | ISO 8601 UTC string. It was epoch seconds before. |
model, adapter, canary_bucket | The model as served, the adapter that answered (null for the base model), and stable, canary or null when no canary split was active. |
version | Always null from soup serve, which does not know the loop's versions. |
messages, response, prompt | The whole conversation without the answer, the answer, and the last user message, kept at the top level so readers of the old line keep working. |
finish_reason, latency_ms | Why generation stopped, and request to answer. (The loop format defines an optional options object for generation parameters; soup serve does not write it.) |
tokens | An object {"prompt": n, "completion": n}, each null when the engine did not report it. It was one integer before. |
source | soup-serve. |
The old stream key is gone. Credential shapes are masked in messages, response and prompt. A request whose messages use a role outside system, developer, user, assistant and tool is answered but not logged. A streamed answer is logged when generation has finished, before the last held-back words and the final chunk are sent, so the record exists by the time the client has the whole answer and its response_id; a client that disconnects mid-stream leaves a record with finish_reason: "client_disconnected" holding the text actually sent and null token counts (read in the code at the tag; not run against a live server). Rotation is unchanged: 100 MB by default (--trace-log-cap-mb, 1 to 10,000), one backup serve.jsonl.1, and soup loop reads rotated files too, oldest first.
Migration. A script of your own that reads ts as epoch seconds or tokens as one integer has to read both shapes. soup data from-traces and soup loop read both, and a line whose schema_version is not 1 is skipped by both, not guessed at. A line with no schema_version is version 0, the old shape, read as a single user message.
Loading adapters at runtime (--adapter-dir, v0.78.0)
soup serve --model ./base --adapter-dir .soup-loops/adapters --tool-auth-token "$TOKEN"
curl -X POST http://127.0.0.1:8000/v1/adapters/load \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"name": "v2", "path": ".soup-loops/adapters/run1"}'--adapter-dir <dir> (transformers backend only) switches on POST /v1/adapters/load; without the flag the route answers 404, and only to a caller that sent the token. The body is {"name": ..., "path": ...} and a success is {"name": "v2", "status": "loaded"}. The rules:
- The route needs the token on every bind (see above).
- The path must be inside
--adapter-dirafter symlinks are resolved:.., a symlink out of the directory, and a Windows UNC or drive-relative path answer 403. A directory withoutadapter_config.jsonis a 400, and pickle weights (adapter_model.bin) are refused: use safetensors. - A name matches
^[a-zA-Z0-9][a-zA-Z0-9-]*$and has at most 64 characters; a name that is already loaded is a 409. - Loading does not activate. Use
POST /v1/adapters/activate/<name>or theadapterfield of a request. - At most 16 adapters can be loaded at runtime (those from
--adaptersdo not count). The 17th load unloads the oldest runtime adapter that is not the active one, the production or rollback-target adapter or the canary named inloop.yaml, and answers409 runtime adapter limit reached (16)only when none can be unloaded. A failed load is a 400adapter could not be loaded, and the cause stays in the server log. --adapter-direxits 2 before the model loads, and before the[serve]extra is checked (so also on a core install), with a non-transformers backend, with--mole, for a directory that does not exist, and for a filesystem root. Only a valid--adapter-diron a core install reachesFastAPI/uvicorn not installed.and exit 1 (run on a core install).
Known limit, in upstream's words: after a server restart a promoted adapter is not loaded again (soup loop does not replay loop.yaml), so the stable side is the base model until the loop deploys the next version or you load the adapter by hand.
The loop's own check request (X-Soup-Internal)
POST /v1/chat/completions honours X-Soup-Internal: loop-check only with a valid tool token, on every bind. The request is then answered normally but writes no conversation record (a streamed answer included), writes no thumbs, is never routed to a canary bucket (conversation_id and X-Conversation-Id are ignored for routing), is not counted in the canary statistics, and the response echoes X-Soup-Internal: loop-check; that echo is how the loop tells an older server that would have recorded the call. The header with no or a wrong token is a 401, on a server started without a token it is a 401 Authentication required: X-Soup-Internal is honoured only with a valid tool token..., any other value with a valid token is a 400 Unknown X-Soup-Internal value: the only one is 'loop-check'., and /v1/messages ignores the header. The loop uses it for the paraphrase step; you do not need it.
--trace-log, --record-thumbs and --feedback-log are refused on other backends
With --backend vllm, sglang or mii, each of the three exits 2 naming the flag: --trace-log requires --backend transformers (the vllm backend does not support it, so the flag would be silently ignored). Through v0.77.2 they were accepted and did nothing. (Since closed in v0.78.0: the flags are refused instead of ignored.) The check runs after the [serve] extra check, so on a core install the missing-extra message and exit 1 come first, and it runs before --max-tokens is read.
API Endpoints
Every backend exposes the same OpenAI-compatible core:
POST /v1/chat/completions— chat completions (streaming supported, except on the DeepSpeed-MII backend; on the transformers backend every answer also carries aresponse_idand anX-Response-Idheader since v0.78.0)GET /v1/models— list available modelsGET /health— health check (the DeepSpeed-MII backend has none)
Beyond that core the backends differ. POST /v1/messages and GET /metrics are served by the transformers and vLLM backends only, and /metrics answers whether or not --dashboard is passed; on SGLang and MII --dashboard prints a warning and collects nothing. The adapter, tool, thumbs and feedback routes exist on the transformers backend only.
What the transformers server reports (v0.77.2). On the transformers backend and the MoLE runtime a reply that was cut at max_tokens without an end-of-sequence token now ends with finish_reason: "length" on /v1/chat/completions and stop_reason: "max_tokens" on /v1/messages, in the JSON reply and in the final streamed event (#2380, #2361). A reply that ends on an end token, even one that lands exactly on the budget, still reports stop / end_turn. Through v0.77.1 these two backends always reported stop. The vLLM backend has reported length since v0.73.0 (#333) and the SGLang and DeepSpeed-MII backends since v0.74.0, so nothing changed for them. Through v0.77.1 the converter behind POST /v1/messages dropped the request's temperature and top_p on the transformers and vLLM servers, so every such request was sampled at the server defaults whatever it sent, temperature: 0 included. POST /v1/messages also applies the temperature (0 to 2) and top_p (0 to 1) of the request (#2388); when a field is omitted the server defaults (0.7 and 0.9) apply, and a value outside the range, null, a boolean or a string is a 400 Invalid request. The vLLM backend's /v1/messages converts the request with the same function, so it takes the same two fields.
Streaming on the transformers backend (since v0.78.0). A stream: true request is sent while the model generates, word by word, so the first chunk leaves before generation ends (#2508, #2514, #2515, #2630). generate() runs on a worker thread and each finished word goes out as it is produced; a word still being written is held back, and a Chinese (Han) character is sent at once (the test is transformers' own TextStreamer._is_chinese_char); text in other scripts is released word by word, split on spaces and newlines. The chunk fields, the final chunk, [DONE] and finish_reason are the same as for a reply generated in full, and the joined deltas equal the non-streamed reply, unless a tokenizer's decode of the finished reply differs from the text already sent: then what was sent stays and nothing more is added. /v1/messages with "stream": true follows the same rules, with the event sequence the Anthropic SDKs expect: message_start, content_block_start, one content_block_delta per piece, content_block_stop, message_delta (stop_reason, stop_sequence, output_tokens) and message_stop. content_block_start and content_block_stop were missing before, and a failure after the stream has started is an error event. Once the server closes the stream, generation stops after the current token. On Windows a client disconnect may not reach the server's generator promptly, so generation can run on until the reply ends (upstream's rider). The streaming itself was read in the code at the tag; no model was loaded here, so no first-chunk latency is given.
Four kinds of request are still generated in full and sent afterwards: one served with --reasoning-parser (the parser needs the whole reply, so it applies before the first chunk leaves), with a draft model (--speculative-decoding) or n-gram lookup, with MoLE routing, and to a model whose generation config sets beam search (num_beams above 1) or several return sequences. --structured-output is a logits processor handed to generate(), so it constrains a streamed reply token by token and is not on that list. (Since closed in v0.78.0: through v0.77.2 every streamed reply was generated in full first and then cut into words on spaces, which is why the constraint and the parser applied to the whole reply before the first chunk left. Since v0.76.0 a streamed request honoured both (#1607); through v0.75.2 it skipped them, so a streamed reply ignored the output constraint and carried the reasoning block.) Use --backend vllm for token streaming together with speculative decoding. --reasoning-parser is read by the transformers backend only: on vLLM, SGLang and MII the flag is accepted and nothing reads it.
stop and stop_sequences (since v0.78.0, #2549, #2630). On the transformers backend /v1/chat/completions takes the OpenAI stop (a string, a list of at most four strings, or null) and /v1/messages takes stop_sequences (a list of at most four strings; a bare string is refused). Every string must be non-empty and at most 256 characters, and an empty list means no stop. Anything else is a 400 whose message names the field and the rule and never repeats the value, for example stop[1] must not be an empty string or stop accepts at most 4 stop strings, got 5. The reply is cut before the first stop string that completes, in a streamed reply too: the stop string is not returned, whitespace left before the cut is dropped, and finish_reason is stop (stop_reason: "stop_sequence" on /v1/messages, with stop_sequence holding the match) even when the reply also used its whole max_tokens. The /v1/messages reply now always carries a stop_sequence field, null when nothing matched. A streamed reply holds back the last characters that could start a stop string and any trailing whitespace, and sends the held text when the reply ends without a match. On the plain path generation ends at the match; with --reasoning-parser, a draft model, n-gram lookup, MoLE routing or beam search the full reply is generated and then cut. The vLLM, SGLang and DeepSpeed-MII backends do not forward the field, so their replies are not cut. (Through v0.77.2 stop was dropped on every backend: a client that sent "stop": ["\nUser:"] got the text after the stop string.)
Prompt encoding. Since v0.75.0 the transformers backend encodes a rendered chat template with no tokenizer special tokens, so a Llama-3, Gemma or Mistral template no longer sends a doubled BOS. Since v0.76.0 the vLLM, SGLang and DeepSpeed-MII backends do the same (#867, #890, #891): when the model's chat template rendered the prompt, Soup encodes it itself and hands the engine token ids instead of a string, so the engine cannot add a second BOS in front of the one the template already rendered.
- vLLM receives
{"prompt_token_ids": [...]}. - SGLang receives the ids as
input_idson its/generateendpoint. This path useshttpx, which the[sglang]extra now declares. - DeepSpeed-MII receives a prompt object that carries the ids, through a tokenizer wrapper. If the engine reports a prompt length different from the one Soup encoded, the server logs a warning naming both numbers.
usage.prompt_tokens drops by one on a template that renders its own BOS. A model with no chat template falls back to a generic User: / Assistant: prompt and the server says so at startup; a template that fails to render falls back the same way for that request and logs a warning; that fallback carries no special tokens of its own and is still sent to the engine as a string, which the engine tokenizes as it always did. For vLLM and SGLang, upstream's changelog reports the change checked against a running engine; the MII path is covered by a test against MII's tokenizer contract. Through v0.75.2, on a template that renders its own BOS, these three engines ran on the doubled-BOS prompt, so a verdict, benchmark or usage number taken through them on an earlier release was measured on a prompt that differed from training by one token. See what changed for soup ship.
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "output",
"messages": [{"role": "user", "content": "Hello!"}]
}'Compatible with OpenAI SDK:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="unused")
response = client.chat.completions.create(
model="output",
messages=[{"role": "user", "content": "Hello!"}],
)Note:
max_tokensis capped at 16,384 per request. Error details are never exposed in HTTP responses.
soup serve --max-tokens (default 512) is the value used for a request that omits max_tokens. A value below 1 or above 16,384 exits 2 before any backend loads, with --max-tokens: must be between 1 and 16384 (got 20000)., with the same text on every backend. (Since v0.78.0, #2730 for a value below 1 and #2898 for one above 16,384: through v0.77.2 the option was not checked at all. Upstream's note on the change says a server started with 0 or a negative value failed every request that omitted max_tokens with a 500, and that a value above 16,384 gave such a request more than the per-request cap allows; neither was run here.) As with the --trace-log, --record-thumbs and --feedback-log refusals above, a core install without the [serve] extra exits 1 on the missing extra first; the --adapter-dir refusals are checked before it.
Tool endpoints: what bounds them
The transformers backend also serves POST /v1/tools/python (body {"code": "..."}), POST /v1/tools/bash (body {"command": "..."}) and POST /v1/tools/web_search, behind the bearer-token and Origin/Host checks described above. On the code routes the order is: the Host and Origin check (421 or 403), then the token (401), then the payload (400), then the isolation rule below (501), so without a token the reply is 401 even on a host where the route would answer 501. A body that is not a JSON object is answered 422 by FastAPI before the token check, and one that is not valid JSON gets 422 before the Host check too. At v0.77.2 every request to /v1/tools/web_search that passes the auth (401) and payload (400) checks answers 403 web_search disabled (empty domain allowlist): no flag or config key sets its domain allowlist, and the search backend behind it returns nothing unless Python code replaces app.state.web_search_backend. A code or command longer than 65,536 characters is a 400. The Python and bash routes run in the same sandbox code as the RLVR code reward, with the same limits:
| Limit | Value |
|---|---|
| Wall clock | 5 seconds. A timeout returns timed_out: true and exit_code: 124 with no output, on both routes (through v0.77.0 the Python route reported timed_out: true for any failure). |
| Output | 10,000 bytes of stdout and stderr combined. Past that the process is killed and the call returns exit code 1, timed_out: false and sandbox output exceeded limit in stderr, on both routes (through v0.77.0 the Python route returned an empty stderr). |
| Memory and CPU (POSIX) | 512 MB of address space and 5 seconds of CPU time. |
| Other POSIX limits | 10 MB largest file, no core dumps, 256 open files, 64 processes. |
| Working directory | A fresh temporary directory per call. |
| Environment | A minimal allowlist (PATH, LANG, LC_ALL, TMPDIR, TERM, TZ and the Windows runtime variables), so tokens and API keys in the server's environment are not passed to the child. |
| Concurrency | At most 4 sandboxed processes at a time, shared by both routes. |
What isolates the process depends on the platform, and since v0.77.0 both code routes refuse to run without it (#2166; the bash route has done so since v0.74.0). The Python route answers 501 python sandbox requires OS-level isolation without running anything, and since v0.77.2 the bash route answers 501 bash sandbox requires OS-level isolation the same way when its sandbox cannot start (each route has one fixed sentence; the cause, an errno string or a path, stays in the server's debug log and is not sent to the caller, #2329):
- Linux: new user, network and PID namespaces through
os.unshare, which exists only in Python 3.12 and later, and the kernel has to allow unprivileged user namespaces. On Python 3.11, the oldest Python v0.77.0 supports, the strategy isbest-effort, so both routes answer 501, and a kernel or container that refuses the namespaces gives a 501 on both routes too. - macOS: the code or command runs under
/usr/bin/sandbox-exec, the only location Soup runs it from (since v0.77.1; asandbox-execelsewhere onPATHis not used), with a default-deny profile that blocks the network and limits writes to/tmp,/private/tmpand/var/folders. - Windows: both routes answer 501.
Through v0.76.1 /v1/tools/python still ran where the bash route refused: on Windows, on Linux with Python 3.10 or 3.11, and where the namespaces could not be created. There it ran inside the same RLVR sandbox code, with the timeout, the output cap, the environment allowlist and, on POSIX, the memory and CPU limits, plus a Python-level socket patch that its own source called bypassable, but without OS-level isolation. The RLVR code reward keeps that best-effort sandbox; only the two serving routes changed (see RLVR).
None of this is a filesystem jail. The isolation cuts the network, and the code runs as the server's user with a scrubbed environment: on Linux it can read and write every file that user can and send signals to that user's processes; on macOS the profile allows reading every file, writing only in the temporary directories and signalling only the run itself. In upstream's words the token is the only thing between a caller and code execution as the server's user, so use a long random one, keep the server on loopback or behind a proxy that terminates TLS (the Bearer header crosses plain HTTP in clear text), and run soup serve in a container, a VM or under a dedicated unprivileged account for any caller you do not fully trust. Since v0.77.1 (#2204, closing #2194) the Python route reports what happened: the process's own stdout, stderr and exit_code, with timed_out: true only for a timeout (exit_code: 124, no output). A non-zero exit keeps its code and reports timed_out: false, an exception leaves its traceback in stderr, and an output overflow is exit_code: 1 with sandbox output exceeded limit in stderr. Since v0.77.2 (#2329) the code is compiled under the file name <code>, so a traceback carries your own line numbers (an error on the second line you sent is reported as line 2 of <code>); through v0.77.1 the lines counted the six-line network guard that is put in front of your code, so the first line you sent was reported as line 7. Through v0.77.0 stderr was always empty and timed_out was true for any failed run (a non-zero exit or an output overflow), so a caller that treated every non-success as a timeout will now see timed_out: false for ordinary failures. Since v0.77.0 a launch failure is a 501 instead, like a missing isolation. The new mapping was checked for this page at the function the route calls, not over HTTP: the route answers 501 on Windows.
Soup is free and Apache-2.0. If it saved you a training run, starring the repo costs nothing and helps most. You can also fund the GPU time behind the work a 4 GB laptop cannot reach.