Configuration
Environment Variables
The MemoryLayer server is configured through environment variables. Run memorylayer info to print the effective values (see CLI Reference).
Core
| Variable | Description | Default |
|---|---|---|
MEMORYLAYER_SERVER_HOST | Server bind address | 127.0.0.1 |
MEMORYLAYER_SERVER_PORT | Server port | 61001 |
MEMORYLAYER_DATA_DIR | Server data directory | ~/.config/memorylayer-server |
MEMORYLAYER_STORAGE_BACKEND | Storage backend (sqlite or turso) | sqlite |
MEMORYLAYER_SQLITE_STORAGE_PATH | SQLite database path (relative to the data directory) | memorylayer.db |
MEMORYLAYER_SHUTDOWN_GRACE_S | Seconds uvicorn waits for in-flight work on shutdown | 20 |
MEMORYLAYER_ACCESS_LOG_PROBE_ROLLUP_S | Collapse /health probe access-log lines into a periodic summary (0 drops them silently) | 300 |
Embeddings
| Variable | Description | Default |
|---|---|---|
MEMORYLAYER_EMBEDDING_PROVIDER | Embedding provider (hash, embed_server, openai, google, mock) | hash |
MEMORYLAYER_EMBEDDING_MODEL | Model name for the active provider | provider default |
MEMORYLAYER_EMBEDDING_DIMENSIONS | Vector width. Must match the model (see Embedding dimensions) | 384 for hash and embed_server |
MEMORYLAYER_EMBEDDING_OPENAI_API_KEY | OpenAI API key (for openai) | — |
MEMORYLAYER_EMBEDDING_GOOGLE_API_KEY | Google API key (for google) | — |
MEMORYLAYER_EMBED_SERVER_URL | Base URL of the memorylayer-embed-server peer | http://localhost:61051 |
MEMORYLAYER_EMBED_SERVER_TIMEOUT | Request timeout for the embed-server peer, in seconds | 300 |
MEMORYLAYER_EMBED_TRANSPORT | Transport for the embed-server peer (http or aether) | http |
MEMORYLAYER_EMBED_AETHER_TARGET | Aether service target when EMBED_TRANSPORT=aether | sv::memorylayer-embed::default |
Retrieval
| Variable | Description | Default |
|---|---|---|
MEMORYLAYER_HYBRID_SEARCH_ENABLED | Fuse keyword search with vector search | true |
MEMORYLAYER_RERANKER_PROVIDER | Reranker (none, rrf, llm, hyde, embed_server) | none |
MEMORYLAYER_RELATIONAL_RECALL_ENABLED | Allow bounded typed-relation retrieval in recall | true |
MEMORYLAYER_RETRIEVAL_CONFIDENCE_ENABLED | Report deterministic retrieval confidence with recall results | true |
MEMORYLAYER_RECALL_TOKEN_BUDGET_DEFAULT | Default token budget for recall content (0 = unlimited) | 0 |
Sessions and Context Packs
| Variable | Description | Default |
|---|---|---|
MEMORYLAYER_SESSION_SERVICE | Session store: persistent (survives restarts, uses the configured storage backend) or in-memory | persistent |
MEMORYLAYER_SESSION_IMPLICIT_CREATE | Auto-create a session on first use | true |
MEMORYLAYER_WORKSPACE_IMPLICIT_CREATE | Auto-create workspaces on first use | true |
MEMORYLAYER_SESSION_TOUCH_TTL | Session sliding TTL in seconds | 3600 |
MEMORYLAYER_SESSION_TOKEN_BUDGET_TOTAL | Total token budget per session before extraction triggers | 12000 |
MEMORYLAYER_SESSION_TOKEN_TRIGGER_INIT | Token threshold that arms the first extraction trigger | 10000 |
MEMORYLAYER_SESSION_TOKEN_TRIGGER_GROWTH | Token growth between subsequent extraction triggers | 5000 |
MEMORYLAYER_SESSION_CHECKPOINT_CAPTURE_ENABLED | Enable durable raw session checkpoints | true |
MEMORYLAYER_SESSION_CHECKPOINT_MAX_BYTES | Maximum size of a single checkpoint | 1048576 |
MEMORYLAYER_CONTEXT_PACK_ENABLED | Enable budgeted context packs and context-delta cursors | true |
MEMORYLAYER_CONTEXT_CURSOR_SECRET | Secret used to sign context-delta cursors. Set your own value in production. | built-in development value |
LLM and Tenancy
| Variable | Description | Default |
|---|---|---|
MEMORYLAYER_LLM_PROFILE_<NAME>_* | LLM profile settings; see LLM Provider Configuration | — |
MEMORYLAYER_LLM_ASSIGN_<ACTIVITY> | Route an activity to a named profile | — |
MEMORYLAYER_TENANT_ID | Tenant identifier for this deployment | empty |
MEMORYLAYER_LLM_IDENTITY_HEADER_HOSTS | Allowlist of first-party hosts that may receive X-Scitrera-* identity headers on LLM calls. Empty means no profile is stamped. | empty |
MEMORYLAYER_AUTHENTICATION_SERVICE | default (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:
| Provider | Purpose |
|---|---|
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_server | Delegates 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. |
openai | OpenAI Embeddings API (works with any OpenAI-compatible endpoint). |
google | Google GenAI Embeddings API. |
mock | Hashes 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), andqwen3-vl(qwen-vl-utils) providers were removed. Setting any of those names forMEMORYLAYER_EMBEDDING_PROVIDERraises a startup error with migration guidance. All self-hosted and multi-vector workloads now go through theembed_serverprovider, which proxies to the standalonememorylayer-embed-server.
hash (default)
memorylayer serveNo 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:
# 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 serverexport MEMORYLAYER_EMBEDDING_PROVIDER=embed_serverexport MEMORYLAYER_EMBED_SERVER_URL=http://embed-host:61051export MEMORYLAYER_EMBEDDING_DIMENSIONS=384memorylayer serveThe 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
pip install "memorylayer-server[openai]"export MEMORYLAYER_EMBEDDING_OPENAI_API_KEY="sk-..."export MEMORYLAYER_EMBEDDING_PROVIDER="openai"memorylayer serveGoogle GenAI
pip install "memorylayer-server[google]"export MEMORYLAYER_EMBEDDING_GOOGLE_API_KEY="..."export MEMORYLAYER_EMBEDDING_PROVIDER="google"memorylayer serveMock (wiring tests only)
export MEMORYLAYER_EMBEDDING_PROVIDER="mock"memorylayer serveContext Environment
The Context Environment provides server-side Python sandboxes for memory analysis and computation.
| Variable | Description | Default |
|---|---|---|
MEMORYLAYER_CONTEXT_EXECUTOR | Executor backend (smolagents or restricted) | smolagents |
MEMORYLAYER_CONTEXT_MAX_EXEC_SECONDS | Timeout per code execution | 30 |
MEMORYLAYER_CONTEXT_MAX_OUTPUT_CHARS | Max captured stdout characters | 50000 |
MEMORYLAYER_CONTEXT_QUERY_MAX_TOKENS | Max tokens for server-side LLM queries | 8192 |
MEMORYLAYER_CONTEXT_MAX_MEMORY_BYTES | Memory limit per sandbox | 268435456 (256 MB) |
MEMORYLAYER_CONTEXT_RLM_MAX_ITERATIONS | Max iterations for RLM loops | 10 |
MEMORYLAYER_CONTEXT_RLM_MAX_EXEC_SECONDS | Total timeout for RLM loops | 120 |
MEMORYLAYER_CONTEXT_MAX_OPERATIONS | Max sandbox operations per execution | 1000000 |
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]):
# 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
| Variable | Docker Default | Code Default |
|---|---|---|
MEMORYLAYER_SERVER_HOST | 0.0.0.0 | 127.0.0.1 |
MEMORYLAYER_SERVER_PORT | 61001 | 61001 |
MEMORYLAYER_EMBEDDING_PROVIDER | embed_server | hash |
MEMORYLAYER_DATA_DIR | /data | ~/.config/memorylayer-server |
Passing Environment Variables
Use -e flags to configure the container:
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-serverLLM Provider Configuration
Some features (reflection, smart extraction, context environment queries) require an LLM provider. LLM providers are configured via profiles:
# 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=httpEach 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:
-v memorylayer-data:/data # Named volume-v /path/on/host:/data # Bind mountHealth 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.
# Override the data directoryexport MEMORYLAYER_DATA_DIR="/var/lib/memorylayer"
# Or specify an explicit database pathexport 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:
| Variable | Description | Default |
|---|---|---|
MEMORYLAYER_TURSO_MODE | local, remote, or replica | local |
MEMORYLAYER_TURSO_DB_PATH | Local database file | memorylayer.db |
MEMORYLAYER_TURSO_URL | Remote database URL (remote / replica modes) | — |
MEMORYLAYER_TURSO_AUTH_TOKEN | Remote auth token (remote / replica modes) | — |
MEMORYLAYER_TURSO_SYNC_INTERVAL | Replica sync interval in seconds | 60 |
MEMORYLAYER_TURSO_VECTOR_INDEX | Opt in to DiskANN vector indexing | false |
PostgreSQL
PostgreSQL storage (with pgvector, Apache AGE, and pg_textsearch) is provided by MemoryLayer Enterprise. See Enterprise installation.