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:

the configuration file
[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.

KeyDefaultMeaning
base_urlemptyAn http or https URL such as http://127.0.0.1:8080/v1. SwarmLabRE appends /models and /chat/completions to it.
api_key_envSWARMLABRE_API_KEYThe 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.
modelemptyThe model to use. Empty means the first model the endpoint lists.
temperature0.0Pinned on every request the agents make.
seed1Sent 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#

Agentpi in the agents container. Itsends requests to a loopbackaddress and holds no key.GateOn the host. It setstemperature, seed and model,limits n and the output tokens,queues requests and adds thekey.ModelYour OpenAI-compatibleendpoint. It gets the key inthe Authorization header.model-trace.jsonl.gzevery request as its hash,every reply whole Agentpi in the agents container. It sends requests to aloopback address and holds no key.GateOn the host. It sets temperature, seed and model,limits n and the output tokens, queues requestsand adds the key.ModelYour OpenAI-compatibleendpoint. It gets thekey in theAuthorization header.model-trace.jsonl.gzevery request as itshash, every replywhole
A request on its way to the model. The gate sits between the two: no key reaches the agent, and the sampling is pinned before a request leaves the host.

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:

FieldWhat the gate does
temperaturesets it to the value in [model], whatever the agent's client sent
seedsets it to the value in [model]
modelsets it to the model of the run, so an agent cannot ask for another one
nsets it to 1 when it is anything else
max_tokenslowers 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 run or serve process on the host. It is sent only in the Authorization header of requests from the host to base_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 inspect output of a container, with its environment, arguments and mounts, contains it.
  • A base_url that starts with http:// sends the key unencrypted. Use https:// for any endpoint that is not on this machine.

When there is no model#

SituationResult
no [model] section and no --mockrun prints the first message below to stderr and exits with code 3
base_url does not answer, or model is not listedrun prints the second message and exits with code 1
serve without a modelthe page opens and its launch sheet gives the third message as the reason it cannot start a run
messages
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.

SwarmLabRE alpha 0.1.0Edit this page on GitHub