Skip to content

Configuration

Environment Variables

The MemoryLayer server is configured through environment variables. Run memorylayer info to print the effective values (see CLI Reference).

Core

VariableDescriptionDefault
MEMORYLAYER_SERVER_HOSTServer bind address127.0.0.1
MEMORYLAYER_SERVER_PORTServer port61001
MEMORYLAYER_DATA_DIRServer data directory~/.config/memorylayer-server
MEMORYLAYER_STORAGE_BACKENDStorage backend (sqlite or turso)sqlite
MEMORYLAYER_SQLITE_STORAGE_PATHSQLite database path (relative to the data directory)memorylayer.db
MEMORYLAYER_SHUTDOWN_GRACE_SSeconds uvicorn waits for in-flight work on shutdown20
MEMORYLAYER_ACCESS_LOG_PROBE_ROLLUP_SCollapse /health probe access-log lines into a periodic summary (0 drops them silently)300

Embeddings

VariableDescriptionDefault
MEMORYLAYER_EMBEDDING_PROVIDEREmbedding provider (hash, embed_server, openai, google, mock)hash
MEMORYLAYER_EMBEDDING_MODELModel name for the active providerprovider default
MEMORYLAYER_EMBEDDING_DIMENSIONSVector width. Must match the model (see Embedding dimensions)384 for hash and embed_server
MEMORYLAYER_EMBEDDING_OPENAI_API_KEYOpenAI API key (for openai)—
MEMORYLAYER_EMBEDDING_GOOGLE_API_KEYGoogle API key (for google)—
MEMORYLAYER_EMBED_SERVER_URLBase URL of the memorylayer-embed-server peerhttp://localhost:61051
MEMORYLAYER_EMBED_SERVER_TIMEOUTRequest timeout for the embed-server peer, in seconds300
MEMORYLAYER_EMBED_TRANSPORTTransport for the embed-server peer (http or aether)http
MEMORYLAYER_EMBED_AETHER_TARGETAether service target when EMBED_TRANSPORT=aethersv::memorylayer-embed::default

Retrieval

VariableDescriptionDefault
MEMORYLAYER_HYBRID_SEARCH_ENABLEDFuse keyword search with vector searchtrue
MEMORYLAYER_RERANKER_PROVIDERReranker (none, rrf, llm, hyde, embed_server)none
MEMORYLAYER_RELATIONAL_RECALL_ENABLEDAllow bounded typed-relation retrieval in recalltrue
MEMORYLAYER_RETRIEVAL_CONFIDENCE_ENABLEDReport deterministic retrieval confidence with recall resultstrue
MEMORYLAYER_RECALL_TOKEN_BUDGET_DEFAULTDefault token budget for recall content (0 = unlimited)0

Sessions and Context Packs

VariableDescriptionDefault
MEMORYLAYER_SESSION_SERVICESession store: persistent (survives restarts, uses the configured storage backend) or in-memorypersistent
MEMORYLAYER_SESSION_IMPLICIT_CREATEAuto-create a session on first usetrue
MEMORYLAYER_WORKSPACE_IMPLICIT_CREATEAuto-create workspaces on first usetrue
MEMORYLAYER_SESSION_TOUCH_TTLSession sliding TTL in seconds3600
MEMORYLAYER_SESSION_TOKEN_BUDGET_TOTALTotal token budget per session before extraction triggers12000
MEMORYLAYER_SESSION_TOKEN_TRIGGER_INITToken threshold that arms the first extraction trigger10000
MEMORYLAYER_SESSION_TOKEN_TRIGGER_GROWTHToken growth between subsequent extraction triggers5000
MEMORYLAYER_SESSION_CHECKPOINT_CAPTURE_ENABLEDEnable durable raw session checkpointstrue
MEMORYLAYER_SESSION_CHECKPOINT_MAX_BYTESMaximum size of a single checkpoint1048576
MEMORYLAYER_CONTEXT_PACK_ENABLEDEnable budgeted context packs and context-delta cursorstrue
MEMORYLAYER_CONTEXT_CURSOR_SECRETSecret used to sign context-delta cursors. Set your own value in production.built-in development value

LLM and Tenancy

VariableDescriptionDefault
MEMORYLAYER_LLM_PROFILE_<NAME>_*LLM profile settings; see LLM Provider Configuration—
MEMORYLAYER_LLM_ASSIGN_<ACTIVITY>Route an activity to a named profile—
MEMORYLAYER_TENANT_IDTenant identifier for this deploymentempty
MEMORYLAYER_LLM_IDENTITY_HEADER_HOSTSAllowlist of first-party hosts that may receive X-Scitrera-* identity headers on LLM calls. Empty means no profile is stamped.empty
MEMORYLAYER_AUTHENTICATION_SERVICEdefault (open auth) or aether (see Aether Transport)default

Use the --verbose / -v CLI flag to enable debug logging.

Embedding Providers

The memorylayer-server core supports five embedding providers:

ProviderPurpose
hash (default)Deterministic lexical feature hashing. Dependency-free and offline, so a bare install works. Texts that share words score as similar, but there is no semantic understanding. The server logs a startup warning naming the upgrade paths.
embed_serverDelegates to a memorylayer-embed-server peer over HTTP (or mTLS via Aether). Use this for self-hosted semantic text embeddings (CPU or GPU) and multi-vector workloads.
openaiOpenAI Embeddings API (works with any OpenAI-compatible endpoint).
googleGoogle GenAI Embeddings API.
mockHashes each whole string into an essentially random vector. For wiring tests only; never use it to judge recall quality.

Removed in v0.1.x: the in-process local (sentence-transformers), colpali (colpali-engine), and qwen3-vl (qwen-vl-utils) providers were removed. Setting any of those names for MEMORYLAYER_EMBEDDING_PROVIDER raises a startup error with migration guidance. All self-hosted and multi-vector workloads now go through the embed_server provider, which proxies to the standalone memorylayer-embed-server.

hash (default)

Terminal window
memorylayer serve

No configuration, network access, or API key required. Good for trying the API and for tests; switch to a semantic provider for real retrieval.

embed_server (self-hosted)

Run memorylayer-embed-server as a peer process or container, then point the core server at it. The peer’s default model, all-MiniLM-L6-v2, is 384-d and runs on CPU:

Terminal window
# CPU peer (container)
docker run -d -p 61051:61051 -e EMBED_SERVER_RUN_SIDECAR=false \
scitrera/memorylayer-embed-server:0.2.0
# On the core server
export MEMORYLAYER_EMBEDDING_PROVIDER=embed_server
export MEMORYLAYER_EMBED_SERVER_URL=http://embed-host:61051
export MEMORYLAYER_EMBEDDING_DIMENSIONS=384
memorylayer serve

The provider probes the peer at startup and logs an actionable error if it is unreachable. For GPU deployments (vLLM, 2048-d by default), set MEMORYLAYER_EMBEDDING_DIMENSIONS to match; see Embed Server. For cross-datacenter or mTLS deployments, set MEMORYLAYER_EMBED_TRANSPORT=aether and MEMORYLAYER_EMBED_AETHER_TARGET=sv::memorylayer-embed::default.

OpenAI

Terminal window
pip install "memorylayer-server[openai]"
export MEMORYLAYER_EMBEDDING_OPENAI_API_KEY="sk-..."
export MEMORYLAYER_EMBEDDING_PROVIDER="openai"
memorylayer serve

Google GenAI

Terminal window
pip install "memorylayer-server[google]"
export MEMORYLAYER_EMBEDDING_GOOGLE_API_KEY="..."
export MEMORYLAYER_EMBEDDING_PROVIDER="google"
memorylayer serve

Mock (wiring tests only)

Terminal window
export MEMORYLAYER_EMBEDDING_PROVIDER="mock"
memorylayer serve

Context Environment

The Context Environment provides server-side Python sandboxes for memory analysis and computation.

VariableDescriptionDefault
MEMORYLAYER_CONTEXT_EXECUTORExecutor backend (smolagents or restricted)smolagents
MEMORYLAYER_CONTEXT_MAX_EXEC_SECONDSTimeout per code execution30
MEMORYLAYER_CONTEXT_MAX_OUTPUT_CHARSMax captured stdout characters50000
MEMORYLAYER_CONTEXT_QUERY_MAX_TOKENSMax tokens for server-side LLM queries8192
MEMORYLAYER_CONTEXT_MAX_MEMORY_BYTESMemory limit per sandbox268435456 (256 MB)
MEMORYLAYER_CONTEXT_RLM_MAX_ITERATIONSMax iterations for RLM loops10
MEMORYLAYER_CONTEXT_RLM_MAX_EXEC_SECONDSTotal timeout for RLM loops120
MEMORYLAYER_CONTEXT_MAX_OPERATIONSMax sandbox operations per execution1000000

Executor Backends

The Context Environment supports two executor backends. The smolagents backend requires the context extra (pip install "memorylayer-server[context]", also included in [all]):

Terminal window
# Use smolagents executor (default, recommended)
export MEMORYLAYER_CONTEXT_EXECUTOR="smolagents"
# Use restricted executor (no imports, AST-based whitelist)
export MEMORYLAYER_CONTEXT_EXECUTOR="restricted"

The smolagents backend provides a more capable execution environment with support for common data science libraries. The restricted backend uses an AST-based whitelist for maximum safety but limited functionality.

Docker

The official Docker image (scitrera/memorylayer-server) installs the core server with the [all] extras and the memorylayer-server-rpg plugin. It pins MEMORYLAYER_EMBEDDING_PROVIDER=embed_server, so it expects a memorylayer-embed-server peer at MEMORYLAYER_EMBED_SERVER_URL. This is deliberate: the container never silently falls back to lexical matching. Override the provider to use openai / google, or hash for a dependency-free smoke test. The repository’s docker-compose.yml runs the server together with a CPU embed-server peer.

Container Defaults

VariableDocker DefaultCode Default
MEMORYLAYER_SERVER_HOST0.0.0.0127.0.0.1
MEMORYLAYER_SERVER_PORT6100161001
MEMORYLAYER_EMBEDDING_PROVIDERembed_serverhash
MEMORYLAYER_DATA_DIR/data~/.config/memorylayer-server

Passing Environment Variables

Use -e flags to configure the container:

Terminal window
docker run -d \
--name memorylayer \
-p 61001:61001 \
-v memorylayer-data:/data \
-e MEMORYLAYER_EMBEDDING_PROVIDER=openai \
-e MEMORYLAYER_EMBEDDING_OPENAI_API_KEY=sk-... \
scitrera/memorylayer-server

LLM Provider Configuration

Some features (reflection, smart extraction, context environment queries) require an LLM provider. LLM providers are configured via profiles:

Terminal window
# OpenAI LLM
-e MEMORYLAYER_LLM_PROFILE_DEFAULT_PROVIDER=openai \
-e MEMORYLAYER_LLM_PROFILE_DEFAULT_API_KEY=sk-...
# Anthropic Claude
-e MEMORYLAYER_LLM_PROFILE_DEFAULT_PROVIDER=anthropic \
-e MEMORYLAYER_LLM_PROFILE_DEFAULT_API_KEY=sk-ant-...
# Google Gemini
-e MEMORYLAYER_LLM_PROFILE_DEFAULT_PROVIDER=google \
-e MEMORYLAYER_LLM_PROFILE_DEFAULT_API_KEY=...
# Fireworks (uses the OpenAI SDK, so install the `openai` extra; base URL defaults to https://api.fireworks.ai/inference/v1)
-e MEMORYLAYER_LLM_PROFILE_DEFAULT_PROVIDER=fireworks \
-e MEMORYLAYER_LLM_PROFILE_DEFAULT_API_KEY=...
# Self-hosted via a memorylayer-embed-server peer
-e MEMORYLAYER_LLM_PROFILE_DEFAULT_PROVIDER=embed_server \
-e MEMORYLAYER_LLM_PROFILE_DEFAULT_MODEL=qwen # must match a profile/alias on the embed server
# Optional per-profile transport overrides (otherwise piggybacks on the embed-server client already wired for embeddings):
-e MEMORYLAYER_LLM_PROFILE_DEFAULT_EMBED_SERVER_URL=http://embed-peer:61051 \
-e MEMORYLAYER_LLM_PROFILE_DEFAULT_EMBED_SERVER_TRANSPORT=http

Each profile is independent: two profiles can point at two different embed-server peers, or mix cloud + self-hosted. Activities route to profiles via MEMORYLAYER_LLM_ASSIGN_<ACTIVITY>=<profile_name>, where the activity is one of EXTRACTION, TIER_GENERATION, ONTOLOGY, REFLECTION, RERANKER, or INFERENCE (for example, MEMORYLAYER_LLM_ASSIGN_REFLECTION=private). Tool calling, structured output, and reasoning_effort are forwarded canonically across the providers. See the LLM Profiles reference for the full schema and recipes.

Identity headers (X-Scitrera-Source, X-Scitrera-Tenant, X-Scitrera-Task-Id) are only sent to LLM profiles whose base_url host is listed in MEMORYLAYER_LLM_IDENTITY_HEADER_HOSTS. The allowlist is empty by default, so no provider receives them unless you configure it.

Without an LLM provider, the server still handles core memory operations (remember, recall, forget, associate) but features that require synthesis or generation will be unavailable.

Data Persistence

Mount a volume to /data to persist the SQLite database across container restarts:

Terminal window
-v memorylayer-data:/data # Named volume
-v /path/on/host:/data # Bind mount

Health Check

The container includes a built-in health check at GET /health (every 30s, 10s startup grace period). Use GET /health/ready for readiness checks that verify storage connectivity.

Storage

SQLite (Default)

The default storage backend is SQLite with sqlite-vec for vector operations.

The SQLite database is a single file that contains all memories, embeddings, associations, and session data.

Database Location

The default storage path is memorylayer.db (relative to the data directory). The data directory defaults to ~/.config/memorylayer-server/ and can be overridden with MEMORYLAYER_DATA_DIR, so the database is typically created at ~/.config/memorylayer-server/memorylayer.db.

Terminal window
# Override the data directory
export MEMORYLAYER_DATA_DIR="/var/lib/memorylayer"
# Or specify an explicit database path
export MEMORYLAYER_SQLITE_STORAGE_PATH="/var/lib/memorylayer/data.db"

Turso / libSQL

Set MEMORYLAYER_STORAGE_BACKEND=turso (requires the turso extra) to use Turso/libSQL, which supports local files, remote databases, and embedded replicas:

VariableDescriptionDefault
MEMORYLAYER_TURSO_MODElocal, remote, or replicalocal
MEMORYLAYER_TURSO_DB_PATHLocal database filememorylayer.db
MEMORYLAYER_TURSO_URLRemote database URL (remote / replica modes)—
MEMORYLAYER_TURSO_AUTH_TOKENRemote auth token (remote / replica modes)—
MEMORYLAYER_TURSO_SYNC_INTERVALReplica sync interval in seconds60
MEMORYLAYER_TURSO_VECTOR_INDEXOpt in to DiskANN vector indexingfalse

PostgreSQL

PostgreSQL storage (with pgvector, Apache AGE, and pg_textsearch) is provided by MemoryLayer Enterprise. See Enterprise installation.