Configuration
Configure the fishmem engine — LLM, embedder, graph store, vector index, and defaults.
You configure the engine with a single config object passed to
new Memory({...}). It has four backend sections — llm, embedder,
graphStore, vectorStore — plus a small set of defaults that control how
add behaves. Each section is independent, so you can swap any one backend
without touching the others.
A complete config
import { Memory } from 'fishmem'
export const memory = new Memory({
llm: {
provider: 'openai',
model: 'gpt-4o-mini',
apiKey: process.env.OPENAI_API_KEY,
},
embedder: {
provider: 'openai',
model: 'text-embedding-3-small',
apiKey: process.env.OPENAI_API_KEY,
},
graphStore: {
provider: 'd1',
binding: env.DB,
},
vectorStore: {
provider: 'vectorize',
binding: env.VECTORIZE,
},
defaults: {
infer: true,
},
})llm
The model used for fact extraction and reconciliation. A
gpt-4o-mini-class model is the recommended balance of quality and cost — this
is the model that decides ADD / UPDATE / INVALIDATE / NOOP on the write path
(see Architecture).
| Option | Type | Description |
|---|---|---|
provider | string | LLM provider, e.g. openai. |
model | string | Model id, e.g. gpt-4o-mini. |
apiKey | string | API key. Falls back to the provider's standard env var. |
baseUrl | string | Optional. Point at a compatible endpoint or proxy. |
embedder
The model used to turn facts into vectors for similarity search. The default is
text-embedding-3-small.
| Option | Type | Description |
|---|---|---|
provider | string | Embedding provider, e.g. openai. |
model | string | Model id. Default text-embedding-3-small. |
apiKey | string | API key. Falls back to the provider's standard env var. |
baseUrl | string | Optional. Compatible endpoint or proxy. |
The embedding model's vector dimensions must match the vector index. If you change the embedder after writing memories, you must re-index — vectors from different models are not comparable.
graphStore
Holds the facts, their entities, and the relationships between them. This is what makes graph diffusion possible at read time. FishMem Cloud uses Cloudflare D1 (SQLite).
| Option | Type | Description |
|---|---|---|
provider | string | Store backend, e.g. d1 or local. |
binding | object | The store handle (e.g. a D1 binding on Workers). |
path | string | For local file-backed stores. |
vectorStore
Holds the embeddings and serves similarity search. FishMem Cloud uses Cloudflare Vectorize.
| Option | Type | Description |
|---|---|---|
provider | string | Index backend, e.g. vectorize or local. |
binding | object | The index handle (e.g. a Vectorize binding on Workers). |
path | string | For local file-backed indexes. |
defaults
Behavior applied to every call unless overridden per request.
| Option | Type | Default | Description |
|---|---|---|---|
infer | boolean | true | When true, add extracts durable facts. Set false to store content verbatim. |
userId | string | — | Default scope applied when a call omits one. |
agentId | string | — | Default agent scope. |
topK | number | 10 | Default number of results returned by search. |
infer and the scope fields can be overridden on any individual add or
search call. For what infer: false does and why scoping matters, see
How memory works.
Swapping providers
Because the four sections are independent, moving from local development to
production is a config change, not a code change. Run the bundled local stores
while you build, then point graphStore at D1 and vectorStore at Vectorize for
deployment — the add / search code stays exactly the same. The same is true
of the LLM and embedder: change provider, model, and baseUrl to use a
different provider, keeping the rest of your app untouched.