Docs / Models and sandbox / Use a real model
Use a real model
SwarmLabRE talks to any OpenAI-compatible endpoint. The agents never talk to it directly: every request passes a gate on the host that pins the sampling and adds the key.
Point SwarmLabRE at an endpoint#
For llama.cpp, vLLM, Ollama or a hosted API, copy swarmlabre.example.toml to swarmlabre.toml and set the [model] section:
[model] base_url = "http://127.0.0.1:8080/v1" api_key_env = "SWARMLABRE_API_KEY" temperature = 0.0 seed = 1
$ export SWARMLABRE_API_KEY=YOUR_KEY $ python3 -m swarmlabre run sample.elf
SwarmLabRE reads the first of --config, $SWARMLABRE_CONFIG, ./swarmlabre.toml and ~/.config/swarmlabre/swarmlabre.toml that exists, and only reads it. Every key has a default.
| Key | Default | Meaning |
|---|---|---|
base_url | empty | An http or https URL such as http://127.0.0.1:8080/v1. SwarmLabRE appends /models and /chat/completions to it. |
api_key_env | SWARMLABRE_API_KEY | The name of the environment variable that holds the key. The key is never read from the file. With no value in the variable, no Authorization header is sent. |
model | empty | The model to use. Empty means the first model the endpoint lists. |
temperature | 0.0 | Pinned on every request the agents make. |
seed | 1 | Sent with every request. The manifest of a run says whether the server honoured it. |
The keys context_window, max_tokens, reasoning, thinking_toggle, thinking_level and extra_body tell the agent program what the model can do. context_window and max_tokens give pi the size of the context and of one answer. reasoning = true makes pi send its thinking level, which thinking_level sets. extra_body adds fields to the planning request SwarmLabRE itself makes between rounds; the agents' requests are not changed. swarmlabre.example.toml documents them.
What the gate does to a request#
The agents container has no network. pi sends its requests to a loopback address inside the container, a forwarder passes them to a Unix socket, and the gate on the host answers on that socket. The gate takes only GET /v1/models and POST /v1/chat/completions, and only streamed chat requests. It rewrites each request before it forwards it:
| Field | What the gate does |
|---|---|
temperature | sets it to the value in [model], whatever the agent's client sent |
seed | sets it to the value in [model] |
model | sets it to the model of the run, so an agent cannot ask for another one |
n | sets it to 1 when it is anything else |
max_tokens | lowers it, and max_completion_tokens with it, to the cap when it is above it. The cap is max_tokens from [model] or 32768, whichever is higher |
At most max_parallel requests (4 by default, 1 to 6) are with the model at once. The others queue at the gate. A queued request gets an answer at once and a keepalive comment every 15 seconds, so that the agent's idle timeout does not end it. The gate records every request as the SHA-256 of its body and every reply whole in model-trace.jsonl.gz, which is what replay uses. Pinning the sampling removes the noise the agent's client controls; Reproducibility says what it does not remove.
Does the server honour the seed?#
Before a run, run asks the endpoint the same short question twice at temperature 1.0 with the same seed. Equal answers mean the server honours the seed, and different answers mean it ignores it. The result, honoured, ignored or unknown, is written to swarm.json and manifest.json as seed_support, and the command prints seed: honoured, or the other word, to stderr. unknown means a question failed or came back empty.
Where the key goes#
- The key is read from the environment variable by the
runorserveprocess on the host. It is sent only in the Authorization header of requests from the host tobase_url. - It is registered with the scrubber, so log strings hide it, and the configuration file never holds it.
- No container is given it. A run does not start when the
docker inspectoutput of a container, with its environment, arguments and mounts, contains it. - A
base_urlthat starts withhttp://sends the key unencrypted. Usehttps://for any endpoint that is not on this machine.
When there is no model#
| Situation | Result |
|---|---|
no [model] section and no --mock | run prints the first message below to stderr and exits with code 3 |
base_url does not answer, or model is not listed | run prints the second message and exits with code 1 |
serve without a model | the page opens and its launch sheet gives the third message as the reason it cannot start a run |
model: no model: set [model] base_url (or mock) in swarmlabre.toml Cannot start: no model is reachable. No model is configured. Set [model] in swarmlabre.toml.
The live checks used one locally served model. The models tried so far are Qwen3.8 Flash Next, Qwen3.8 27B and CYBER-FROST 3.8. Other endpoints, servers and models are untested. The mock model needs none of this.