---
title: "Worker API"
description: "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."
url: "https://opod.io/docs/core-reference/worker-api/"
markdown_url: "https://opod.io/docs/core-reference/worker-api.md"
section: "Core reference"
last_updated: "2026-11-08"
---

# 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.

```bash
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`](https://github.com/opod-io/opod-core/tree/main/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:

  ```text
  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`:

  ```text
  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

| Path                    | Method | Purpose                                                                                                                                                                                                                                                                                                                                                                                                       |
| ----------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/healthz`              | `GET`  | `200 ok`. No key. The process is up.                                                                                                                                                                                                                                                                                                                                                                          |
| `/readyz`               | `GET`  | No 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/models`            | `GET`  | What the engine has, as `{"object":"list","data":[{"id":"…","object":"model"}]}`.                                                                                                                                                                                                                                                                                                                             |
| `/v1/chat/completions`  | `POST` | Chat, forwarded to the engine. Streams when the body asks.                                                                                                                                                                                                                                                                                                                                                    |
| `/v1/embeddings`        | `POST` | Embeddings, forwarded to the engine. The OpenAI body: `model` and `input` (one string or a list).                                                                                                                                                                                                                                                                                                             |
| `/v1/rerank`            | `POST` | Rerank, forwarded to the engine: `{"model", "query", "documents"}` (a list of strings). `501 rerank_not_supported` where the engine has none.                                                                                                                                                                                                                                                                 |
| `/v1/sampling-defaults` | `GET`  | The served model's own sampling defaults, from its generation config.                                                                                                                                                                                                                                                                                                                                         |
| `/v1/load`              | `GET`  | From 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/tokenize`          | `POST` | Tokenize 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/load`        | `POST` | Pull and load a model on this worker (below).                                                                                                                                                                                                                                                                                                                                                                 |
| `/v1/model/unload`      | `POST` | The counterpart (below).                                                                                                                                                                                                                                                                                                                                                                                      |
| `/v1/model/sleep`       | `POST` | Sleep 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/resume`      | `POST` | Wake from sleep. → `{"status":"resumed","engine":"…"}`. Both answer `501` with `"status":"unsupported"` and a `reason` on an engine with no sleep mode.                                                                                                                                                                                                                                                       |
| `/v1/adapters`          | `GET`  | The LoRA adapters this worker holds.                                                                                                                                                                                                                                                                                                                                                                          |
| `/v1/adapters/load`     | `POST` | `{"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/unload`   | `POST` | `{"base", "name"}`, both required → `{"status":"unloaded","model":"<base>:<name>"}`.                                                                                                                                                                                                                                                                                                                          |
| `/v1/process/start`     | `POST` | Start 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/get`       | `GET`  | `?id=` → `ProcessInfo`. The leader polls it for readiness after a `202`.                                                                                                                                                                                                                                                                                                                                      |
| `/v1/process/list`      | `GET`  | Every supervised process: `[]ProcessInfo`.                                                                                                                                                                                                                                                                                                                                                                    |
| `/v1/process/logs`      | `GET`  | `?id=&lines=` → the last lines of its output, `text/plain`.                                                                                                                                                                                                                                                                                                                                                   |
| `/v1/process/stop`      | `POST` | `{"id": "…"}` → `204`.                                                                                                                                                                                                                                                                                                                                                                                        |
| `/v1/process/file`      | `HEAD` | `?name=&sha256=` → `200` with header `X-File-Path` when a GGUF with that SHA-256 is present, else `404`.                                                                                                                                                                                                                                                                                                      |
| `/v1/process/upload`    | `POST` | `?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`:

```json
{"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:

| Status | Body `status` | Meaning                                                                                     |
| ------ | ------------- | ------------------------------------------------------------------------------------------- |
| `200`  | `unloaded`    | The engine unloaded the model, or the worker stopped the engine process it launched for it. |
| `200`  | `noop`        | Nothing to do: the model was not loaded. The call is idempotent.                            |
| `409`  | —             | A gang part or an adapter of the model is still held.                                       |
| `501`  | `unsupported` | The 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:

  | Field                                                                                                                                                                                                                           | Meaning                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
  | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `id`, `boot_id`                                                                                                                                                                                                                 | Who is speaking.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
  | `loaded_models`                                                                                                                                                                                                                 | What 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_models`                                                                                                                                                                                                               | For an engine that loads on first request (Ollama): which of those are in memory now.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
  | `sleeping`                                                                                                                                                                                                                      | The 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`.                                                                                                                          |
  | `slots`                                                                                                                                                                                                                         | How many requests the engine serves at once: the engine's own word, else the number on its launch line. Omitted when neither is known.                                                                                                                                                                                                                                                                                                                                                                                        |
  | `engine`                                                                                                                                                                                                                        | The 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_blocks`                                                                                                                                                                                                                     | With `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.

**Figure: Heartbeats and the router.** A timeline of worker heartbeats, the age of the last one, and when the router stops and resumes sending new requests as the worker stops and returns. The interactive figure is on the web page: <https://opod.io/docs/core-reference/worker-api/>

| Leader answer           | Worker reaction                                                                 |
| ----------------------- | ------------------------------------------------------------------------------- |
| `200` `{"status":"ok"}` | Next beat in 5 seconds.                                                         |
| `404`                   | The leader forgot the node: register again.                                     |
| `401` / `403`           | Register again with the same token; exit after 6 refused re-registers in a row. |
| network error, `5xx`    | Back 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`](https://opod.io/docs/core-cli/join/#stopping).
