encode_vector
Store a memory with an embedding you computed yourself, bypassing Brain's embedder.
encode_vector(text: str, vector: list[float], model_fingerprint: str, ...) -> EncodeResultencode_vector_direct(request: EncodeVectorDirectRequest) -> EncodeResponseParameters
textstringrequiredThe memory text. Still required — it is what recall returns and what the lexical retriever indexes.
vectorfloat[]requiredThe embedding. Its length must equal the shard's vectorDim — read it from capabilities. Any other length is rejected.
model_fingerprintstring (wire: bytes)requiredWhich 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 integeroptionalThe session to attribute it to.
kindintegeroptionalForce the memory kind instead of letting Brain classify it.
salience_hintfloatoptionalSeed salience in [0, 1] instead of letting the pipeline score it.
deduplicatebooleanoptionalWhether to run the dedup check. Defaults to on.
Returns
—EncodeResultalwaysThe same shape encode returns: memoryId, wasDeduplicated, salience, kind, createdAtUnixNanos, autoEdgesAdded.
The wire form
encode_vector_direct 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.
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.
from brain_db_sdk import new_id
from brain_db_sdk.wire import EncodeVectorDirectRequest, MemoryKind
client.encode_vector_direct(
EncodeVectorDirectRequest(
text="Priya moved to Lisbon in March.",
vector=my_embedding,
model_fingerprint=fp,
session_id=42,
kind=MemoryKind.EPISODIC,
salience_hint=0.6,
edges=[],
request_id=new_id(),
txn_id=None,
deduplicate=True,
)
)Was this page helpful?