Reference

Configuration

Context config, models, and limits.

SurrealDB Agent Memory has two configuration surfaces: server-wide settings (in the server binary or environment) and per-Context configuration (stored in the control plane and patchable at runtime).

Server configuration is provided via environment variables or a TOML configuration file passed at startup. These settings apply to all Contexts unless overridden at the Context level.

Note

Every variable keeps the SPECTRON_ prefix from Spectron, the project name SurrealDB Agent Memory was developed under. These names are part of the shipped interface, so the product renaming leaves them unchanged for now; they will be renamed in a future release.

VariableTypeDefaultDescription
SPECTRON_BINDstring0.0.0.0:8080Listen address and port
SPECTRON_SURREALDB_URLstring-SurrealDB connection URL (required)
SPECTRON_SURREALDB_USERstring-SurrealDB username (required)
SPECTRON_SURREALDB_PASSstring-SurrealDB password (required)
SPECTRON_OBJECT_STOREstringlocal://./dataObject store backend (see below)

Per-stage defaults are cost-tiered for the deployment’s chosen LLM provider (SPECTRON_LLM_PROVIDER / implicit Google). Optional env overrides:

VariableDescription
SPECTRON_LLM_MODELGlobal model override when a stage has no per-Context selection
SPECTRON_MODEL_EMBEDDINGMust be gemini-embedding-2 (3072-dim). Embedding is fixed per deployment - not a free per-Context choice

The embedding model is fixed per deployment - it is not a per-Context override. Context config rejects any models.embedding value other than the deployment default. Changing the server embedding model requires a reindex so vectors and HNSW indexes stay in the same embedding space.

Cross-encoder reranking for /documents/query when use_reranker=true:

VariableDescription
SPECTRON_RERANKER_URLPOST endpoint for the reranker service. Unset ⇒ no provider; requests fall through to bi-encoder ordering.
SPECTRON_RERANKER_MODELRequired when URL is set. Boot error if URL is set without a model.
SPECTRON_RERANKER_API_KEYOptional bearer token (Authorization: Bearer …).

HTTP OCR, CLIP, and speech-to-text for document ingestion (read by the worker role). An HTTP provider takes precedence over the built-in local fallback for the same modality. Misconfigured URLs fail at boot.

VariableDescription
SPECTRON_OCR_URLPOST endpoint for OCR. Unset ⇒ built-in or local Tesseract (when enabled).
SPECTRON_OCR_MODELRequired when OCR URL is set.
SPECTRON_OCR_API_KEYOptional bearer token.
SPECTRON_CLIP_URLPOST endpoint for visual embeddings. Output must match the 3072-dim image_chunk width (same space as gemini-embedding-2 when using Gemini CLIP).
SPECTRON_CLIP_MODELRequired when CLIP URL is set.
SPECTRON_CLIP_API_KEYOptional bearer token.
SPECTRON_STT_URLPOST endpoint for speech-to-text.
SPECTRON_STT_MODELRequired when STT URL is set.
SPECTRON_STT_API_KEYOptional bearer token.

See Multimodal content.

VariableDescription
SPECTRON_PROVIDER_OPENAI_API_KEYOpenAI key available to Contexts and stages
SPECTRON_PROVIDER_ANTHROPIC_API_KEYAnthropic key available to Contexts and stages
SPECTRON_PROVIDER_GOOGLE_API_KEYGoogle (Gemini) key; also used when Gemini is the implicit request-path default
SPECTRON_LLM_PROVIDERExplicit default provider for unset stages: openai \| anthropic \| google. Unset ⇒ a present Google key makes Gemini the implicit default on /chat and /facts?infer=full
SPECTRON_EMBEDDINGS_API_KEYGemini Developer API key for embeddings (gemini-embedding-2, 3072-dim). Embeddings are Gemini-only
BackendSPECTRON_OBJECT_STORE formatNotes
Local filesystemlocal:///path/to/dataDevelopment and single-node deployments
Amazon S3s3://bucket-name/prefixRequires AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY or instance role
Google Cloud Storagegcs://bucket-name/prefixRequires GOOGLE_APPLICATION_CREDENTIALS
Azure Blob Storageazure://container/prefixRequires AZURE_STORAGE_ACCOUNT + AZURE_STORAGE_ACCESS_KEY

Cross-origin browser calls to the API are off by default. Enable an origin allowlist when a web client (for example SurrealDB Studio against a Cloud-brokered access token) calls the user API from a different origin than the API host.

ServiceVariableCLI flag
User APISPECTRON_CORS_ALLOWED_ORIGINS--cors-allowed-origins
Management APISPECTRON_MANAGEMENT_CORS_ALLOWED_ORIGINS--cors-allowed-origins

Comma-separated origins. Entries are trimmed, lower-cased, and normalised (trailing / stripped). Exact entries match the Origin header verbatim; entries containing * are anchored globs on both sides (bare * or https://* are rejected). Allowed origins are echoed in Access-Control-Allow-Origin; credentials are not used - callers authenticate with Authorization, not cookies. Preflight mirrors request headers so SDK headers (api-version, X-Spectron-Context, Idempotency-Key, and others) pass without a fixed allowlist.

The management API is normally server-side only; CORS is optional there for operator tooling.

Each Context stores a config object in the control plane. This is updated via PATCH /api/v1/contexts/{id} and applies immediately to new requests.

{
  "config": {
    "token_limit": 1000000,
    "models": {
      "extraction": { "provider": "google", "model": "gemini-2.5-flash" },
      "synthesis": { "provider": "google", "model": "gemini-2.5-pro" },
      "elaboration_consolidation": { "provider": "google", "model": "gemini-2.5-flash" },
      "embedding": "gemini-embedding-2"
    },
    "providers": {
      "google": "…",
      "openai": "sk-…",
      "anthropic": "sk-ant-…"
    }
  }
}
FieldTypeDescription
token_limitinteger (optional)Soft monthly token cap for metering and billing. Does not reject requests while enforcement_blocked is false. null = no cap.
ingestion_profilestringDocument ingest dial: TextOnly, TextPlusKeyword, StandardMultimodal, or MultimodalFull (default). See Multimodal content.
models.extraction{provider, model}LLM for turn and document extraction.
models.reconciliation{provider, model} (optional)LLM assist when structural entity merge is inconclusive.
models.synthesis{provider, model}LLM for /chat and /reflect.
models.elaboration_consolidation{provider, model}LLM for worker elaboration and consolidation.
models.embeddingstringMust be gemini-embedding-2 when set (3072-dim; deployment-fixed).
providers.googlestringGoogle (Gemini) API key for this Context.
providers.openaistringOpenAI API key for this Context. Overrides the server-wide default.
providers.anthropicstringAnthropic API key for this Context.

Provider API keys are write-only on the API surface. The read projection for a Context replaces the key values with a providers_configured summary - names of providers for which this Context stores its own key:

{
  "config": {
    "providers_configured": ["google", "openai", "anthropic"]
  }
}

This is not the same as GET /api/v1/{context_id}/providers, which lists providers reachable via a global deployment key or a per-Context key and includes selectable model ids. The two surfaces are not derivable from each other.

The raw key values never appear in read responses.

These fields live on the Context record itself, not inside the config object. A PATCH that only updates config cannot change them.

FieldTypeDefaultDescription
enforcement_blockedbooleanfalseWhen true, gated LLM-backed requests return 429 regardless of the soft token_limit. When false, usage may exceed token_limit (pay-as-you-go).

Send only the fields you want to change. Unset fields are left unchanged (deep merge):

PATCH /api/v1/contexts/acme-prod
Content-Type: application/json
Authorization: Bearer mgmt-...

{
  "config": {
    "token_limit": 2000000,
    "models": {
      "reflection": "anthropic/claude-opus-4-7"
    }
  }
}

Additional per-Context settings control extraction behaviour:

FieldTypeDefaultDescription
llm_extraction_enabledbooleanfalseWhether typed-node extraction runs at all. With it off, documents and turns are still stored and searchable, but produce no entities, attributes, or relations
pii_redaction_enabledbooleanfalseRedact detected personal data during ingest
reconciliation.confidence_floorfloat0.7Posterior-confidence floor for auto-supersession. Below it, a conflicting assertion records an uncertainty instead of replacing the prior value
ingestion_profilestring-Which pipeline steps run during document ingest
chunking_strategystring-How document text is split before embedding

There is no setting that constrains which entity types, attribute keys, or relation labels extraction may produce. Entity types come from a fixed vocabulary; keys and labels converge through reuse. See Extraction vocabulary.

FieldTypeDefaultDescription
response_cache.enabledbooleantrueMaster switch. With it false, every /chat and /reflect call skips the cache tier
response_cache.similarity_thresholdfloat0.92Cosine-similarity floor a prior query must score against the new one before its answer is reused
response_cache.freshness_window_secondsinteger3600Soft cap on how old a reusable response may be
FieldTypeDefaultDescription
allow_self_service_keysbooleantrueWhen false, members cannot mint keys via POST /{ctx}/keys; use Cloud-brokered access tokens only.
max_token_ttl_secondsinteger (optional)noneMaximum TTL clamp applied to every key mint (management, broker, self-service). null = no clamp.

Every data-plane API key must be bound to a principal. Keys with no principal binding are rejected with 401 - there is no unscoped passthrough mode. Mint keys under a principal (management API or self-service POST /{ctx}/keys).

Operator-tunable ceilings (env vars, read at process start):

VariableDefaultCaps
SPECTRON_DEFAULT_PAGE_SIZE100Default limit when listing session turns and omitted elsewhere
SPECTRON_MAX_LIST_LIMIT500Maximum rows per list response (list_turns, traces, audit)
SPECTRON_MAX_QUERY_K50Maximum limit / k on /query, /context, document query, and MCP recall / context. Clamp-down only - the env var can lower the ceiling but never raise it above 50. Default answer size k / limit is 10.
SPECTRON_RETRIEVAL_POOL_SIZE256Internal candidate-pool breadth for fused retrieval. Decoupled from k - k only truncates the fused answer; raising k does not widen the search pool.
SPECTRON_RETRIEVAL_SECTION_EXPANSIONtrueWhen on (default), pull same-section sibling passages into contextHits after ranking so synthesis sees section bodies, not only heading/pointer chunks. Opt out with 0 / false. Does not change ranked hits. See Section expansion.
SPECTRON_DB_WS_MAX_MESSAGE_BYTES134217728 (128 MiB)Client-side WebSocket per-message cap for pooled SurrealDB connections. Raise in lockstep with the server's SURREAL_WEBSOCKET_MAX_MESSAGE_SIZE when large document persists fail with Message too long.
SPECTRON_TRACE_FEATURE_TTL_SECS60TTL (seconds) for the in-process per-(Context, scope) trace-features cache in the fused ranker - how long prior retrieval outcomes re-weight candidates before recomputation. Process-local; 0 or invalid values fall back to the default.

Requests above the query ceiling return 400 Bad Request.

FieldTypeDefaultDescription
reconciliation.confidence_floorfloat0.7Minimum confidence required for same-provenance supersession

When a per-Context field is not set, the server-wide default applies. The effective configuration for a Context is always visible at:

GET /api/v1/contexts/{id}

The response includes the config object with all effective values merged - Context-level overrides where set, server-wide defaults elsewhere.

Was this page helpful?