FishMem

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

memory.ts
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).

OptionTypeDescription
providerstringLLM provider, e.g. openai.
modelstringModel id, e.g. gpt-4o-mini.
apiKeystringAPI key. Falls back to the provider's standard env var.
baseUrlstringOptional. 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.

OptionTypeDescription
providerstringEmbedding provider, e.g. openai.
modelstringModel id. Default text-embedding-3-small.
apiKeystringAPI key. Falls back to the provider's standard env var.
baseUrlstringOptional. 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).

OptionTypeDescription
providerstringStore backend, e.g. d1 or local.
bindingobjectThe store handle (e.g. a D1 binding on Workers).
pathstringFor local file-backed stores.

vectorStore

Holds the embeddings and serves similarity search. FishMem Cloud uses Cloudflare Vectorize.

OptionTypeDescription
providerstringIndex backend, e.g. vectorize or local.
bindingobjectThe index handle (e.g. a Vectorize binding on Workers).
pathstringFor local file-backed indexes.

defaults

Behavior applied to every call unless overridden per request.

OptionTypeDefaultDescription
inferbooleantrueWhen true, add extracts durable facts. Set false to store content verbatim.
userIdstringDefault scope applied when a call omits one.
agentIdstringDefault agent scope.
topKnumber10Default 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.

Next steps

On this page