How to call Spectron, how models plug in, and how security properties attach to stored state.
Ingest and read (HTTP)
Two ingest families and one read family over a unified graph (same reconciler, same retrieval stack):
| Verb | Purpose |
|---|---|
POST /api/v1/{ctx}/facts | Text or triples, with infer: "full" \| "triples" \| "preview" \| "none". |
POST /api/v1/{ctx}/facts/batch | Bulk conversation ingest (messages: [{ role, content, ts }, …]). Idempotent with Idempotency-Key. |
POST /api/v1/{ctx}/documents | Byte ingest into the multi-modal pipeline (async). |
POST /api/v1/{ctx}/query | Unified read over facts and passages. Accepts optional labels, lens (scope paths to read within), and scope_view (strict, merged, or crossTeam) to control how broadly results are folded within what the caller is already allowed to see. |
POST /api/v1/{ctx}/chat | Recall + LLM synthesis; SSE when streaming. |
POST /api/v1/{ctx}/context and the MCP recall / context tools accept the same read parameters as /query.
Trace listing: GET /api/v1/{ctx}/traces and GET /api/v1/{ctx}/traces/{id}. See Traces and memory evolution and REST API.
Integrations
Generated SDKs – Python (
surrealdb-spectron) and TypeScript (@surrealdb/spectron), both produced from Spectron’s OpenAPI specification so types track the server surface.MCP over HTTP – tools wrapping the same handlers; shared
API-KEYauth. See MCP server.Harness adapters – LangChain, Claude Code hook, OpenAI Agents, Vercel AI SDK, n8n – flush conversations into
/facts/batch.
Model configuration (five hooks)
LLMs and embedders appear in five pipeline roles – each configurable per Context and per call, with model and cost recorded on traces:
Extraction – turns and chunks → entities, attributes, relations.
Embedding – vectors for entities, attributes, chunks.
Reconciliation – optional disambiguation when signals conflict.
Synthesis –
/chatand/reflectgeneration.Elaboration / consolidation – background passes.
Spectron supports OpenAI-compatible endpoints plus first-class Anthropic and Google clients. The embedding model at write time must match read time within a Context (or schedule re-embed).
Security and privacy
Encryption – In transit: terminate TLS at your reverse proxy or load balancer (typical deployments run Spectron on HTTP behind the proxy). At rest: configure encryption on your SurrealDB storage backend and object-store bucket (for example KMS on S3 or GCS); Spectron inherits whatever those backends provide.
Graph-resident audit – writes emit
decision_trace; reads emitretrieval_trace;/chatand/reflectemitresponse_trace. Together these record which caller asked what, against which scope, with which key, and which records were considered or returned.Operational audit events – alongside the trace graph, Spectron emits structured audit events for reads, destructive operations (
forget), scope changes, background jobs, and denied authorisation attempts so refused access is on the record even when no trace record is written.Prompt-injection handling – ingest-time scanning on uploads and batched turns;
spectron fsck --check injectionfor sweeps.Right to be forgotten –
forgetsoft-deletes or purges per policy; supersession history optional for audit.
Inspectability and operational signals
Operators can derive:
Cost – tokens, model, latency from
response_trace.Cache hit rate – responses with
reused_fromset (tier 2 — fewer tokens spent).Contradiction rate –
uncertaintyrecords per volume of writes, by source kind.Source distribution – attributes by
source.kindover time.Supersession churn –
decision_trace.supersededper entity.Retrieval quality – candidate sizes and per-signal agreement from
retrieval_trace.
See Self-hosting observability for more details.