Skip to content
Opod

Core reference

Worker API

The HTTP routes a worker serves to its leader, how the leader authenticates to them, their bodies and errors, and what the register and heartbeat carry.

In short

Each worker serves an HTTP API on port 8081 (or OPOD_ADVERTISE_ADDR) that only its leader calls, signed with HMAC. You need it only for debugging or to write a manager. /healthz and /readyz need no signature.

curl -s http://192.0.2.51:8081/readyz

A worker serves an HTTP API on its address: port 8081 on its LAN address, or OPOD_ADVERTISE_ADDR, which is also where it binds unless OPOD_BIND_ADDR names another address. Only its leader calls it. You do not call it in normal operation; this page is for debugging and for people writing a manager. The typed shapes are in core's pkg/nodeapi.

The server sets a 30-second limit on reading request headers. A trace context (traceparent) from the leader is continued into the worker's call to its engine; the worker exports no spans of its own.

Authentication

Every route except /healthz and /readyz needs one of:

  • An HMAC signature from the leader, in the X-Opod-Auth header:

    X-Opod-Auth: v=1,id=<node id>,ts=<unix seconds>,sig=<hex>

    sig is hex HMAC-SHA256, keyed by the worker's token, over these four lines joined by \n:

    v1
    <method, in upper case>
    <path, no query string>
    <ts>

    ts must be within 5 minutes of the worker's clock, so keep the clocks in sync. The body is not signed: uploads stream many gigabytes, and the trust model is a private network. A bad signature answers 401 unauthorized (hmac): <reason>.

  • The worker's token as a bearer, Authorization: Bearer <token>, unless the worker runs with OPOD_REJECT_BEARER=1. Then it answers 401 unauthorized (HMAC required; bearer disabled).

The token is the join token the worker presented, or, for a worker that joined with a certificate only, the random sk-orc-cb-… secret it minted. The leader received it at register. A worker with no token answers every keyed route 401 worker has no token configured.

Routes

PathMethodPurpose
/healthzGET200 ok. No key. The process is up.
/readyzGETNo key. 200 ok when the worker is joined and its engine answers. From core v0.4.3 the engine must also have answered one generation since it started (a one-token warm-up request the worker sends itself): until then 503 engine warming up: …. Otherwise 503 with not joined: <reason> or engine: <error>. ?join=only skips the engine check (a worker whose engine starts only on a load).
/v1/modelsGETWhat the engine has, as {"object":"list","data":[{"id":"…","object":"model"}]}.
/v1/chat/completionsPOSTChat, forwarded to the engine. Streams when the body asks.
/v1/embeddingsPOSTEmbeddings, forwarded to the engine. The OpenAI body: model and input (one string or a list).
/v1/rerankPOSTRerank, forwarded to the engine: {"model", "query", "documents"} (a list of strings). 501 rerank_not_supported where the engine has none.
/v1/sampling-defaultsGETThe served model's own sampling defaults, from its generation config.
/v1/loadGETFrom core v0.4.3 (feature load_pull). The engine's load sample (kv_used_pct, queue_depth, … and sampled_at_ms), for the leader and front doors to rank on. ?maxAgeMs=N: a sample younger than N ms (at least 100) is served from the worker's cache, so many routers cost the engine one scrape. 501 when the engine reports no load.
/v1/tokenizePOSTTokenize a prompt with the served model's tokenizer: model plus messages or prompt, optional max_tokens → {"tokens": [...]}. The leader has no tokenizer and asks a worker, for prefix-cache routing (feature kv_block_events). 501 when the engine cannot.
/v1/model/loadPOSTPull and load a model on this worker (below).
/v1/model/unloadPOSTThe counterpart (below).
/v1/model/sleepPOSTSleep tier: the engine drops its GPU working set and keeps the process (vLLM sleep mode, OPOD_SLEEP_MODE=1). No body. → {"status":"sleeping","engine":"…"}.
/v1/model/resumePOSTWake from sleep. → {"status":"resumed","engine":"…"}. Both answer 501 with "status":"unsupported" and a reason on an engine with no sleep mode.
/v1/adaptersGETThe LoRA adapters this worker holds.
/v1/adapters/loadPOST{"base", "name", "source", "rank"}: load an adapter into the engine serving base; it is served as <base>:<name>. base is required; rank must not be negative. → {"status":"ready","model":"<base>:<name>"}. 409 when the engine must restart to take it, 502 when the load fails.
/v1/adapters/unloadPOST{"base", "name"}, both required → {"status":"unloaded","model":"<base>:<name>"}.
/v1/process/startPOSTStart a supervised process (a gang part, a coordinator, a Ray node). Body: ProcessSpec. → 202 with ProcessInfo; 502 with {"error", "info"} when it cannot start. From core v0.4.7, "KVEvents": true marks a gang head's engine that publishes KV events here: a worker started with OPOD_KV_EVENTS=1 then subscribes.
/v1/process/getGET?id= → ProcessInfo. The leader polls it for readiness after a 202.
/v1/process/listGETEvery supervised process: []ProcessInfo.
/v1/process/logsGET?id=&lines= → the last lines of its output, text/plain.
/v1/process/stopPOST{"id": "…"} → 204.
/v1/process/fileHEAD?name=&sha256= → 200 with header X-File-Path when a GGUF with that SHA-256 is present, else 404.
/v1/process/uploadPOST?name=&sha256=, raw body → {"path","sha256","size"}. Streams a GGUF to this worker and checks its SHA-256. The leader uses it to distribute a split model's weights.

Load and unload

POST /v1/model/load:

{"id": "llama-3.2-3b", "ollama_name": "llama3.2:3b", "repo": "bartowski/Llama-3.2-3B-Instruct-GGUF", "file": "Llama-3.2-3B-Instruct-Q4_K_M.gguf", "path": "", "pin": false}

id is required: the catalog id, and the name the model is served under. The worker picks what its engine needs: an Ollama tag, a GGUF to fetch (from repo and file, or path when the file is already cached), or a Hugging Face repo for a safetensors engine. For vLLM, SGLang, llama.cpp and TensorRT-LLM the load starts the engine process with the model. It answers {"status": "ready", "model": "<engine-native name>"} once the engine serves.

POST /v1/model/unload takes the same identifying fields (id, ollama_name, repo, path) and answers:

StatusBody statusMeaning
200unloadedThe engine unloaded the model, or the worker stopped the engine process it launched for it.
200noopNothing to do: the model was not loaded. The call is idempotent.
409—A gang part or an adapter of the model is still held.
501unsupportedThe engine cannot unload. reason says why.

Supervised processes

ProcessSpec fields (capitalised on the wire): ID (unique on the worker), Command, Args, Env (added to the worker's environment, on top of the device pin and the VRAM budget), WorkDir, HealthPort and HealthHost (readiness probes this TCP port; host default 127.0.0.1), HealthPath (an HTTP readiness path), ReadyTimeout, LogLines (ring-buffer size), Restart, MaxRestarts, RestartBackoff.

ProcessInfo fields: id, command, args, pid, started_at, status, exit_err, address, restarts.

Register and heartbeat

The worker calls the leader, with both an HMAC signature and its token as a bearer:

  • POST /admin/v1/nodes/register once at start: node id, hostname, OS, architecture, RAM, address, hardware (CPU cores, GPUs and their memory, engine id, role, KV tier, plan revision, devices given), and a new boot id. A changed boot id under the same node id tells the leader the old process died: its placements and gang rows are dropped (node.reincarnated).

  • POST /admin/v1/nodes/heartbeat every 5 seconds:

    FieldMeaning
    id, boot_idWho is speaking.
    loaded_modelsWhat the engine answers requests for, as catalog ids. From core v0.4.3 it is [] until the engine has answered the worker's one-token warm-up generation, so a worker whose engine lists a model before it can generate (TensorRT-LLM: about 70 s) gets no requests yet; a sleeping engine is not warmed. null = the engine did not answer within 2 seconds: no report, which changes no placement. [] = a definite "nothing" (nothing listens where the engine would).
    resident_modelsFor an engine that loads on first request (Ollama): which of those are in memory now.
    sleepingThe engine is asleep.
    load, and, from vLLM's NIXL connector, kv_xfer_bytes_total, kv_xfer_seconds_total, kv_xfers_total, kv_fetch_waiting_to_start, kv_fetch_in_progress and kv_fetch_loaded (arrives in the core release after v0.4.8)The engine's load sample: kv_used_pct, queue_depth, tokens_per_s, prefix_hit_pct, sampled_at, and when the engine states them kv_capacity_tokens, kv_used_tokens, preemptions_total, evictions_total, the prefix-cache counters prefix_hit_tokens_total and prefix_query_tokens_total (vLLM; from core v0.4.1), the host KV tier counters (tier_*) and engine_ttft_p50_ms.
    slotsHow many requests the engine serves at once: the engine's own word, else the number on its launch line. Omitted when neither is known.
    engineThe engine process state: starting, serving, crash-looping, restarting or stopped. crash-looping = the worker restarted the process more than once in its lifetime, even if the current attempt is up: the leader does not count it as capacity, and a gang part in this state is checked as possibly down. The state comes with restarts, since and detail, and, from core v0.4.1, the engine's own version once it serves (vLLM /version, SGLang /server_info, llama-server /props build_info).
    kv_blocksWith OPOD_KV_EVENTS=1: prefix-cache block hashes stored and removed since the last beat (seq, block_size, stored, removed, cleared). From core v0.4.0 (feature kv_cpu_tier_hits), cpu_stored and cpu_removed say the same for the engine's host-memory tier below the card (vLLM CPU offloading); cleared forgets that tier too. Omitted when the worker has no such tier or its engine does not describe it.

A heartbeat is also sent at once, out of turn, when the engine process changes state, so a crash or a restart reaches the leader well before the next timed beat.

When the engine stays silent (no report) past the heartbeat bound, the node becomes engine-silent and gets no new work.

Heartbeats and the router

Drag when the worker stops and when it returns

Last heartbeat at 20 s. From 50 s the router sends this worker no new request; it gets traffic again with its first heartbeat at 70 s. Lower max age reacts faster but drops a worker on one slow beat; 0 turns the router check off.
heartbeat (every 5 s)heartbeat after it joins againheartbeat_max_age_seconds
Leader answerWorker reaction
200 {"status":"ok"}Next beat in 5 seconds.
404The leader forgot the node: register again.
401 / 403Register again with the same token; exit after 6 refused re-registers in a row.
network error, 5xxBack off: 10 s, then 20 s.

On shutdown the worker sends a goodbye heartbeat (loaded_models: [], engine stopped, detail worker shutting down) so the leader takes it out of rotation at once, then drains for OPOD_DRAIN_SECONDS. See opod join.

Last updated · Source: content/docs/core-reference/worker-api.mdx · View as Markdown