Description
n8n-nodes-memori-community



An n8n community node that exposes a Memori Chat Model sub-node for the AI Agent.
Memori is an open-source memory layer for LLMs. When fronted as an OpenAI-compatible proxy it partitions knowledge per entity (end-user), process (application) and session — but only if the client attaches those identifiers on every request. n8n’s built-in OpenAI Chat Model has no UI for that, so this package ships a drop-in replacement that does.
What it does
Behaves like the built-in OpenAI Chat Model sub-node, plus three required fields — Entity ID, Process ID, Session ID — which are injected into every outgoing chat completion request as a top-level memori_attribution object.
Request shape
Outgoing requests carry the attribution in both the body (as memori_attribution) and as HTTP headers (X-Memori-*), so a self-hosted Memori build can read whichever channel it prefers:
POST /v1/chat/completions HTTP/1.1
Authorization: Bearer
Content-Type: application/json
X-Memori-Entity-Id:
X-Memori-Process-Id: myn8nagent
X-Memori-Session-Id: {
"model": "gpt-4o-mini",
"messages": [
{ "role": "system", "content": "..." },
{ "role": "user", "content": "..." }
],
"temperature": 0.7,
"stream": false,
"memori_attribution": {
"entity_id": "",
"processid": "myn8n_agent",
"session_id": ""
}
}
Your Memori proxy reads attribution from whichever channel it prefers, records/retrieves memory for that partition, and forwards the (possibly memory-augmented) request to the upstream model.
Prerequisites
You need a self-hosted Memori instance with the OpenAI-compatibility layer enabled. This node is only the client side — it sends memori_attribution-stamped requests to an OpenAI-compatible endpoint, but the endpoint itself is yours to run.
Your Memori build must expose at least:
POST /v1/chat/completions— OpenAI-compatible chat completions (withAuthorization: Bearerauth, and acceptance of the top-levelmemori_attributionobject).GET /v1/models— the model-list endpoint used to populate the Model dropdown at edit time.- Chat Trigger with Response Mode = “Streaming” → the AI Agent calls
model.stream(...), OpenAI SDK flips tostream: true, Memori streams SSE back, n8n forwards tokens to the client. ✅ - Webhook → AI Agent → Respond to Webhook (default) → non-streaming; agent collects the full completion and returns it in one shot.
- Body —
modelKwargs.memori_attributionon LangChain.jsChatOpenAIserializes as a top-level key in the JSON body. - Headers —
configuration.defaultHeadersaddsX-Memori-Entity-Id/X-Memori-Process-Id/X-Memori-Session-Idto every request.
For the OpenAPI schema Memori actually serves, hit /docs on your running instance (e.g. http://).
> Not a target: hosted Memori Cloud. The public Memori product at memorilabs.ai is an SDK-wrapper architecture (Memori().llm.register(client)), plus an MCP server at https://api.memorilabs.ai/mcp/ that uses X-Memori-API-Key auth. It does not expose the OpenAI-compatible chat-completions proxy this node points at. MemoriLabs is building the official n8n MCP integration for that path.
Self-hosting a Memori proxy
This node speaks OpenAI-compatible HTTP, but the upstream MemoriLabs/Memori project is a Python SDK, not a server. To bridge them you run a small FastAPI app that wraps the SDK. A starter gist is available with five files (main.py, requirements.txt, Dockerfile, docker-compose.yml, .env.example):
👉 gist.github.com/mheland/550e5263cd33558ff1acdadf54870abc
1. Clone the gist into an empty directory.
2. Provision a Postgres 14+ database; put its URL into .env as MEMORIPOSTGRESURL. Memori auto-creates its schema on first run.
3. Set the rest of .env: MEMORIPROXYAPIKEY (any long random string — clients send this as Authorization: Bearer …), OPENAIAPIKEY, and UPSTREAMBASE_URL if you’re routing through something other than OpenAI direct.
4. docker compose up -d --build.
5. curl -s http://localhost:8012/health → {"status":"healthy"}.
6. In n8n, install n8n-nodes-memori-community, create a Memori API credential with Base URL http:// and the proxy key, and add a Memori Chat Model to your Agent.
The starter is intentionally minimal — within-session memory only. Cross-session fact recall, post-stream augmentation, and gpt-5 / o-series param compat are layered on top in production deployments.
Install
In self-hosted n8n: Settings → Community Nodes → Install → enter n8n-nodes-memori-community → Install.
> Note: This package depends on @langchain/openai, which makes it ineligible for n8n Cloud’s community-node verification. It targets self-hosted n8n.
Configure
1. Create a Memori API credential (installed by this package). Fill:
– API Key — whatever your Memori instance expects on Authorization: Bearer
– Base URL — must point at the OpenAI-compatible root on your Memori instance and include the version segment, e.g. https://.
2. Add an AI Agent node. Click the language-model socket and pick Memori Chat Model.
3. Fill the fields:
| Field | Example | Notes |
|——————|——————————————————–|——————————————————-|
| Model | pick from dropdown | Loaded live from {baseUrl}/models. Switch to ID mode for aliases not in the list. |
| Entity ID | ={{$json.userId}} | Usually the end-user. Expressions supported. |
| Process ID | myn8nagent | Logical app/process name. Static per workflow is fine.|
| Session ID | ={{ $json.sessionId ?? $json.userId + '_web' }} | Conversation identifier. Expressions supported. |
| Enable Thinking | off (default) / on | Sent as chattemplatekwargs.enable_thinking. Recognised by vLLM/SGLang-served models (GLM, Qwen3, DeepSeek-R1); ignored otherwise. The Memori proxy strips it cleanly when routing to OpenAI. |
| Incognito | Boolean (default false), or Expression | When truthy, the Memori proxy bypasses recall + augmentation + DB writes for that turn. Switch to Expression to wire from an incoming webhook payload (e.g. ={{ $json.body.incognito }}). Lenient parsing on the node side keeps true / 1 / yes / on truthy for non-boolean expression results. Requires Memori proxy ≥ v10. |
Optional fields under Options: Base URL override, Sampling Temperature, Maximum Number of Tokens, Timeout, Max Retries.
Streaming
The node doesn’t hard-code stream. Whether stream: true is sent to Memori depends on how the AI Agent invokes the model:
How it works
The three attribution values ride on two channels so a self-hosted Memori build can read whichever it prefers:
new ChatOpenAI({
apiKey, model,
configuration: {
baseURL,
defaultHeaders: {
'X-Memori-Entity-Id': entityId,
'X-Memori-Process-Id': processId,
'X-Memori-Session-Id': sessionId,
},
},
modelKwargs: {
memoriattribution: { entityid, processid, sessionid },
},
});
A small fetch wrapper strips LangChain-injected defaults (topp, n, presencepenalty, frequencypenalty) from outgoing bodies and recomputes Content-Length, so the node works cleanly against both OpenAI-backed and Anthropic-backed models routed through Memori (otherwise Anthropic rejects temperature + topp together).
Relevant discussion in the n8n community:
Development
git clone https://github.com/the-automagicians/memori-ai-model.git
cd memori-ai-model
npm installnpm run dev # spins up a local n8n with the node pre-installed + live reload
npm run build # one-shot TypeScript build + asset copy (@n8n/node-cli)
npm run build:watch # incremental TypeScript rebuild
npm run lint
npm run lint:fix
npm run dev is the fastest inner loop: it starts a sub-process n8n at http://localhost:5678 with the node auto-installed into ~/.n8n-node-cli, and rebuilds on save.
Repo layout
credentials/
MemoriApi.credentials.ts # Memori API credential type
memori.svg
nodes/
LmChatMemori/
LmChatMemori.node.ts # the sub-node
memori.svg
.github/workflows/
ci.yml # lint + build on PRs and main
publish.yml # publishes to npm on v..* tags
Release process
1. Bump version in package.json.
2. Commit, git tag -a vX.Y.Z -m "...", push the commit and the tag.
3. publish.yml runs lint + build, then npm publish --provenance.
Publishing uses npm Trusted Publishing (OIDC) when configured on the package page; otherwise falls back to NPM_TOKEN.
Limitations
@langchain/openai, so the package cannot be verified for n8n Cloud.configuration.defaultHeaders / modelKwargs in supplyData.License
MIT © the-automagicians