Quick start
Run the whole stack locally with Docker, create a user, and send a first conversation through the proxy.
- 1Copy the environment file.terminal
cp .env.example .env - 2Set a database password and an extraction provider. Leave
ENGRAM_SERVICE_KEYand the Clerk keys empty for a self-hosted start..envPOSTGRES_PASSWORD=replace_with_a_strong_password EXTRACTION_PROVIDER=openai OPENAI_API_KEY=your_key_here
- 3Start the stack.terminal
docker compose up -d - 4Create a user. Save the returned
api_key. It is shown once; Engram stores only a hash.terminalcurl -X POST http://localhost:8000/users \ -H "Content-Type: application/json" \ -d '{"external_id": "test_user_1"}'
- 5Send the first conversation through the proxy.terminal
curl -X POST http://localhost:8000/v1/chat \ -H "Content-Type: application/json" \ -H "X-Engram-Key: <api_key>" \ -H "X-Engram-User-ID: test_user_1" \ -H "X-Engram-Provider: openai" \ -d '{"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "I prefer FastAPI for backend development."}]}'
- 6Review what it learned. After a few seconds, new memories wait in the pending queue.terminal
curl 'http://localhost:8000/memories?status=pending' \ -H "X-Engram-Key: <api_key>"
- 7Approve a memory before expecting the proxy to retrieve it.terminal
curl -X PATCH http://localhost:8000/memories/<memory_id> \ -H "Content-Type: application/json" \ -H "X-Engram-Key: <api_key>" \ -d '{"status": "approved"}'
Dashboard login
The dashboard uses Clerk for sign-in. Set the same ENGRAM_SERVICE_KEY on the api and dashboard services; the dashboard uses it server-side to issue an Engram key for the signed-in user without exposing it to the browser.
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_... CLERK_SECRET_KEY=sk_test_... ENGRAM_SERVICE_KEY=generate_a_long_random_value
Without Clerk, paste an ek_… key in Settings. The browser keeps it in local storage, and every dashboard page uses it.
Proxy
Send chat requests to POST /v1/chat, or the OpenAI-compatible POST /v1/chat/completions, with your Engram key and a provider header. Engram retrieves, injects, forwards, and returns the provider's response immediately; extraction happens afterwards.
| Header | Purpose |
|---|---|
X-Engram-Key | Your workspace API key (ek_…) |
X-Engram-User-ID | Whose memories to use |
X-Engram-Provider | openai, anthropic, gemini or ollama |
X-Engram-Namespace | The project to read and write; defaults to default |
Set stream: true for server-sent events. Tokens flow as they arrive, and extraction starts once the stream closes.
curl -N -X POST http://localhost:8000/v1/chat \ -H "Content-Type: application/json" \ -H "X-Engram-Key: ek_your_key_here" \ -H "X-Engram-User-ID: test_user_1" \ -H "X-Engram-Provider: openai" \ -d '{"model":"gpt-4o-mini","stream":true, "messages":[{"role":"user","content":"What stack should I use?"}]}'
Memories API
| Route | Does |
|---|---|
GET /memories?status=pending | List memories waiting for review |
POST /memories/search | Search; the response includes context, the exact block the proxy would inject |
PATCH /memories/{id} | Edit or approve a memory |
GET /memories/{id}/history | Every revision of a fact |
GET /memories/{id}/source | The conversation it came from |
DELETE /memories/{id} | Forget it; saved retrieval text is redacted |
GET /memories/export | Export everything |
GET /logs/{id} | One retrieval: the query, the memories, their scores |
MCP server
The engramd package on npm runs an MCP server with seven tools, scoped to one project at a time. It speaks stdio by default; --transport http serves Streamable HTTP at POST /mcp on port 3000.
{ "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engramd"], "env": { "ENGRAM_API_KEY": "ek_your_key_here" } } } }
claude mcp add engram -e ENGRAM_API_KEY=ek_your_key_here -- npx -y engramdSet ENGRAM_API_URL to point at your own API, and ENGRAM_NAMESPACE to pick a project.
search_memories | add_memory | list_memories |
update_memory | delete_memory | capture_conversation |
get_retrieval_log |
Auto capture
capture_conversationlets an assistant store memories without you saying "remember this". It sends the latest user message and reply, and Engram extracts only durable facts: preferences, projects, skills and corrections. Greetings, one-off questions and the assistant's own claims are skipped. Add an instruction like this to your client:
Before answering when user context may matter, search Engram for relevant memories. After each meaningful exchange, call capture_conversation with the user message, assistant response, source client name, and session id.
Projects & orgs
Namespaces split one user's memories into projects. Pass X-Engram-Namespace on proxy requests and ?namespace= on REST calls; the default is default. Organizations group users with owner, admin and member roles; memories tagged with an org_id are visible to every member.
# create an org (you become the owner) curl -X POST http://localhost:8000/orgs \ -H "X-Engram-Key: ek_..." \ -H "Content-Type: application/json" \ -d '{"name":"Acme"}' # add a member by external_id curl -X POST http://localhost:8000/orgs/<org_id>/members \ -H "X-Engram-Key: ek_..." \ -H "Content-Type: application/json" \ -d '{"external_id":"teammate_42","role":"member"}'
Retrieval
Engram builds a query from up to six recent user messages, embeds it with BAAI/bge-small-en-v1.5, and scores approved memories in the user's workspace and namespace in one SQL query.
| Setting | Default | Effect |
|---|---|---|
RETRIEVAL_KEYWORD_WEIGHT | 0.3 | Full-text rank, so exact names count |
RETRIEVAL_RECENCY_HALF_LIFE_DAYS | 30 | Light boost for recent facts |
RETRIEVAL_THRESHOLD | 0.3 | Skip weaker memories unless pinned |
RETRIEVAL_RELATIVE_CUTOFF | 0.08 | Inject only near the top score |
Run python -m api.eval.retrieval_eval before changing a weight. On the golden set it scores recall@5 0.969 and precision 0.745, injecting 1.8 memories per query.
Extraction
Extraction runs as a Postgres-backed job with bounded retries. When a new fact lands near an existing memory (cosine above RECONCILE_THRESHOLD, default 0.6), one extra model call decides: add it, propose an update, flag a conflict, or discard it as redundant. Updates and conflicts need approval. Disable with ENABLE_RECONCILIATION=false.
Deploy
API
Run the FastAPI image on any container host. Set DATABASE_URL, CORS_ORIGINS, ENGRAM_SERVICE_KEY and ENGRAM_PROVIDER_KEY_ENCRYPTION_KEY. Hosted users save their own provider key per workspace.
Database
PostgreSQL with the vector extension. Local Docker Postgres and Supabase both work; the schema applies on API startup.
Dashboard
Deploy dashboard/ to Vercel with NEXT_PUBLIC_API_URL pointing at the API, and add its origin to the API's CORS_ORIGINS.
Supabase
Enable the vector extension, put the connection string in DATABASE_URL, and apply the schema. Prefer the Session pooler; with the Transaction pooler on port 6543, set DATABASE_STATEMENT_CACHE_SIZE=0.
docker compose -f docker-compose.supabase.yml run --rm api python -m api.apply_schemaLimits
Hosted workspaces have fixed limits; requests over one return 429 with X-Engram-Quota-* headers. Self-hosters can raise them freely.
| Setting | Default |
|---|---|
WORKSPACE_MEMBER_LIMIT | 5 |
WORKSPACE_MEMORY_LIMIT | 2,000 |
WORKSPACE_MONTHLY_RETRIEVAL_LIMIT | 10,000 |
Troubleshooting
| Symptom | Check |
|---|---|
| The dashboard says the key is invalid | The browser saved the same ek_… key as your client, and the API's CORS_ORIGINS includes the dashboard origin. |
| The MCP server shows no tools | Restart the client and check that ENGRAM_API_KEY is set in its MCP config. |
| No memories appear | New facts wait as pending. Approve them on the review screen, or add one by hand. |
| The proxy fails provider requests | Check the provider key in Settings and that X-Engram-Provider matches it. |
| Streaming hangs behind a reverse proxy | Disable response buffering. Engram already sends X-Accel-Buffering: no for nginx. |