Firebase Genkit
Use GoodMem's RAG memory from Genkit as a native retriever and indexer plus goodmem/ tools for any Genkit agent or flow.
Overview
GoodMem gives AI agents retrieval-augmented generation (RAG) memory: store documents in a space
and GoodMem chunks, embeds, and indexes them so your agent can pull back the most relevant
passages on any question. The Genkit plugin registers goodmem/memories as a native Genkit
retriever and indexer for RAG paths, plus tools under the goodmem/ namespace: goodmem/search
and goodmem/remember by default, with space management, deletion, and file-upload tools
available as opt-ins — and optional reranking and LLM-generated answers on retrieval. The
canonical source is the standalone genkitx-goodmem package; the upstream Genkit PR is only a
proposal.
Installation
npm install genkitx-goodmem
# or
pnpm add genkitx-goodmem
# or
yarn add genkitx-goodmemgenkit is a peer dependency. Install it too if you do not already have it:
npm install genkitConfiguration
The goodmem() plugin is configured in code. It does not read environment variables itself —
the examples pass values from GOODMEM_BASE_URL and GOODMEM_API_KEY explicitly.
| Option | Description |
|---|---|
baseUrl | Required. Base URL of your GoodMem server, e.g. https://your-goodmem-server.example.com. |
apiKey | Required. API key sent as the X-API-Key header. |
spaceIds | Required. UUIDs of the space or spaces the plugin may read and write. The model never chooses a space. |
For a server with a private or self-signed CA, set the NODE_EXTRA_CA_CERTS environment variable
to the absolute path of the CA's PEM certificate file before launching Node.js, and restart after
changing it. An expired or invalid server certificate must be fixed on the server.
Quick start
import { genkit } from 'genkit';
import { goodmem } from 'genkitx-goodmem';
const ai = genkit({
plugins: [
goodmem({
baseUrl: process.env.GOODMEM_BASE_URL!,
apiKey: process.env.GOODMEM_API_KEY!,
spaceIds: ['<space-uuid>'],
}),
],
});Once the plugin is loaded, the goodmem/memories retriever and indexer are registered for
Genkit's RAG paths (ai.retrieve and ai.index), and the goodmem/search and
goodmem/remember tools are available to any Genkit agent or flow. Administrative, delete, and
upload tools are off by default and enabled through the plugin options (allowAdminTools,
allowDelete, uploadDir).
Local development. The example above assumes a TLS-verified server URL. If you are running
GoodMem locally with a self-signed certificate, use https://localhost:8080 and point
NODE_EXTRA_CA_CERTS at your local CA's PEM file before launching Node.js — the plugin has no
option to disable TLS verification. Keep normal TLS verification for any deployed server.
Retrieval post-processing
GoodMem's retrieval call accepts these optional post-processing parameters (each framework exposes them under its own naming convention):
| Parameter | Range | Description |
|---|---|---|
reranker_id | UUID | Reranker model that reorders matched chunks by relevance. |
llm_id | UUID | LLM that generates a contextual answer (abstractReply) alongside the chunks. |
relevance_threshold | 0–1 | Minimum relevance score for a result to be included. |
llm_temperature | 0–2 | Sampling temperature for the LLM post-processor. |
max_results | integer | Maximum number of results to return. |
chronological_resort | boolean | Re-sort the final results by creation time instead of relevance. |
The Genkit plugin exposes reranking and LLM answers as the developer-set rerankerId and llmId
plugin options, plus minScore (applied to reranker scores only — there is no default
threshold, and reranker score ranges are provider-dependent). The number of results is the
retrieval's k / the search tool's topK. The other parameters are not exposed by this plugin.
Learn more
The full README, examples, and API reference are available on the npm package page.