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)

Remote use requires an explicitly configured endpoint; there is no built-in relay address. Endpoint precedence is organ-specific, not one shared environment-over-CLI rule:

Consumer Resolution, highest priority first
Engram embeddings ENGRAM_EMBEDDING_ENDPOINT, OTE retrieval.embedding_endpoint, then ${THALAMUS_URL}/v1/embeddings.
Engram reranking ENGRAM_RERANKER_ENDPOINT, OTE retrieval.reranker.endpoint, then ${THALAMUS_URL}/v1/rerank.
Axon remote embeddings --embed-url, AXON_EMBED_URL, then THALAMUS_URL. Explicit URL flags require a remote provider.
Axon remote reranking --rerank-url, explicit embedding URL, AXON_EMBED_URL, then THALAMUS_URL. AXON_RERANK_URL is not consumed by the reviewed implementation.
Soma rubric Explicit THALAMUS_URL; verification model discovery and the shared timeout budget are described in §5.2.
Cortex Configured catalog routes and Thalamus discovery; direct routing requires explicit CORTEX_FALLBACK_* configuration. See the route reference.

Missing remote configuration is an error naming the setting (Engram, Axon), an unrouted route (Cortex), or not evaluated for the requested Soma rubric. Explicit local providers remain local. Axon's auto provider can select remote embeddings when endpoint environment configuration is present; use local to require isolation. Endpoint selection alone does not enable an Engram remote provider or reranker. See the Engram and Axon references before authorizing source/query material to leave the machine; what leaves your machine summarises, per consumer above, what a configured endpoint receives and the documented transport of each client.

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)

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