Part V · Contracts · Plate 01

Thalamus HTTP API

On this page

1. Thalamus HTTP Relay Contract (node-d:18000)

Illustrative deployment: node names, ports, model ids and seed-service counts in this section describe an example topology, not a live inventory or required hardware. Configure actual endpoints and discover available models through the documented interfaces. Wire formats and endpoint-resolution rules are the contract; the example fleet is not a default configuration.

1.1 Endpoint Resolution Order (THALAMUS_URL)

Every CNS organ (Engram, Axon, Soma, Cortex) requires an explicit endpoint. There is no default endpoint and no default model name in any organ. Cortex's direct route exists only when CORTEX_FALLBACK_* is configured. The precedence chain is:

  1. Explicit tool/organ override environment variable (ENGRAM_EMBEDDING_ENDPOINT, ENGRAM_RERANKER_ENDPOINT, AXON_EMBED_URL, AXON_RERANK_URL).
  2. Explicit manifest/CLI configuration (retrieval.embedding_endpoint, retrieval.reranker.endpoint, --embed-url, --rerank-url).
  3. THALAMUS_URL environment variable ({THALAMUS_URL}/v1/embeddings, {THALAMUS_URL}/v1/rerank, {THALAMUS_URL}/v1/systemone, {THALAMUS_URL}/v1/chat/completions), for example http://thalamus.example:18000.

With none of these set, a remote provider is an error that names the missing setting (Engram, Axon) or an unrouted route that makes no request (Cortex); local providers (local-hash, Axon auto/local) never leave the machine. The address of the Thalamus this deployment uses is this deployment's configuration and lives under deploy/fleet/.

No implicit fallback. Soma (§5.2), cns and the Pi extension require the operator's explicit relay configuration. With THALAMUS_URL unset:

cns init and cns curate: axon anchors embed runs only when THALAMUS_URL or AXON_EMBED_URL is set; otherwise they print embed: not configured.

cns init renders .engram/ote.toml from harnesses/pi/ote.example.toml, never copying template endpoints:

1.2 Data-Plane Endpoints

Endpoint Plane Target Models & Nodes Request / Response Contract
POST /v1/chat/completions Plane::Intelligence (system2) Qwen/Qwen3.8-Flash-Next on node-a, node-b, node-c (:8000) OpenAI-compatible JSON or SSE stream. Supports x-session-id / x-agent-session-id header or deterministic prompt-prefix SHA-256 session pinning. Emits x-thalamus-node, x-thalamus-sticky-hit, x-thalamus-work-stolen, and x-thalamus-queue-wait-ms response headers.
POST /v1/systemone (alias /v1/system1/decide) Plane::Verification (system1) clef-flash on node-d:8000 Stateless rubric evaluation. Request: {"model": "clef-flash", "state": "<diff or context>", "questions": {"q1": {"type": "noul" \| "choice" \| "score", "question": "<rubric>"}}}. Response: {"model": "clef-flash", "answers": {"q1": {"type": "noul", "noul": 0.0001}}, "usage": {...}}.
POST /v1/embeddings Plane::Knowledge (retrieval) qwen3-embedding-8b on node-d:8001 OpenAI-compatible batch embedding request: {"model": "qwen3-embedding-8b", "input": ["..."]}. Returns 4096-dim (or caller-sliced/L2-normalized) float vectors in data[].embedding.
POST /v1/rerank (alias /rerank) Plane::Knowledge (retrieval) qwen3-reranker-8b on node-d:8002 Cross-encoder scoring: {"model": "qwen3-reranker-8b", "query": "...", "documents": ["..."]}. Returns {"results": [{"index": 0, "relevance_score": 0.9805, ...}]}.

1.3 Control-Plane Endpoints

1.4 Durable Request Telemetry ($THALAMUS_STATE_DIR/telemetry.db, S8)

Writer: thalamus serve (one row per completed request, written off the routing path). Reader: thalamus replay --since <ts> [--node <name>] [--json], which reads the file directly and works while Thalamus is down. Routing never reads this data.

Column Type Meaning
ts INTEGER Completion time, unix milliseconds.
node / plane TEXT Member that served the request; intelligence, verification or knowledge.
session_fp TEXT First 16 hex chars of SHA-256 of the session id; NULL on stateless planes. The id itself is never stored.
ttft_ms / latency_ms REAL Time to first token (NULL when unknown) and total latency.
prompt_tokens / completion_tokens INTEGER From the upstream usage block; NULL for streamed responses.
kv_hit INTEGER 1 if prompt_tokens_details.cached_tokens > 0, 0 if it was zero, NULL when the upstream reported nothing.
error TEXT http_<status> for status >= 400, else NULL.
stolen INTEGER 1 if contention-aware work stealing moved the session.

Retention: --telemetry-retention-days (default 30), applied at startup and hourly against the wall clock. Rows stamped in the future are kept and counted in /health (telemetry_detail.future_dated_rows). replay exit codes: 0 ok, 1 unreadable, 2 bad arguments, 3 absent (no telemetry.db).