Brain Docs

Reference

TypeScript SDKInstallationHTTP clientWire client
encoderecallforgetencodeVectormemoryListmemoryInspectgraphFetchlinkunlink
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
TypeScript SDKMemoryencodeVector

encodeVector

Store a memory with an embedding you computed yourself, bypassing Brain's embedder.

PURPOSE

Write a memory with your own embedding. Brain skips its embedder and stores the vector as given. Use it when you already run an embedding model, or when you need a model Brain does not ship. The wire verb is encodeVectorDirect.

POST/v1/memories/vectorBearer API keystable
encodeVector(input: EncodeVectorInput): Promise<EncodeResult>
Handshake credentialstable
encodeVectorDirect(request: EncodeVectorDirectRequest): Promise<EncodeResponse>

Parameters

ParameterTypeRequired
textstringrequired

The memory text. Still required — it is what recall returns and what the lexical retriever indexes.

vectorfloat[]required

The embedding. Its length must equal the shard's vectorDim — read it from capabilities. Any other length is rejected.

modelFingerprintstring (wire: bytes)required

Which model produced the vector. Brain refuses to mix fingerprints inside one space, because cosine distance between two models' vectors is meaningless. A mismatch is BadModelFingerprint, not a silent bad result.

session64-bit integeroptional

The session to attribute it to.

kindintegeroptional

Force the memory kind instead of letting Brain classify it.

salienceHintfloatoptional

Seed salience in [0, 1] instead of letting the pipeline score it.

deduplicatebooleanoptional

Whether to run the dedup check. Defaults to on.

Returns

FieldTypePresence
—EncodeResultalways

The same shape encode returns: memoryId, wasDeduplicated, salience, kind, createdAtUnixNanos, autoEdgesAdded.

The wire form

encodeVectorDirect takes no builder, and every field is explicit: text, vector, modelFingerprint (bytes here, not a string), sessionId, kind, salienceHint, edges (memory edges to attach at write time), requestId, txnId, deduplicate, and an optional actAs. It is the only write verb that can attach edges in the same call.

One fingerprint per space, forever

A space's vectors must all come from the same model. There is no migration verb: changing embedding model means re-encoding the space. Decide the model before you load data, not after.

import { newId, MemoryKindWire } from "@brain-db/sdk";

await client.encodeVectorDirect({
  text: "Priya moved to Lisbon in March.",
  vector: myEmbedding,
  modelFingerprint: fp,
  sessionId: 42n,
  kind: MemoryKindWire.Episodic,
  salienceHint: 0.6,
  edges: [],
  requestId: newId(),
  txnId: null,
  deduplicate: true,
});
See also
encodecapabilities

Was this page helpful?

forget

Remove a memory — the soft tombstone, the hard zero, and why a repeat call is safe.

memoryList

Enumerate the memories in a space, cursor-paged, with filters for kind, time, salience and text.

On this page

ParametersReturnsThe wire form
Suggest an editOpen in Playground