Brain Docs

Reference

Rust SDKInstallationHTTP clientWire client
encoderecallforgetencode_vectormemory_listmemory_inspectgraph_fetchlinkunlink
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Rust SDKMemoryencode_vector

encode_vector

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 encode_vector_direct.

POST/v1/memories/vectorBearer API keystable
async fn encode_vector(&self, input: &EncodeVectorInput) -> Result<EncodeResult, BrainHttpError>
Handshake credentialstable
async fn encode_vector_direct(&self, request: &EncodeVectorDirectRequest) -> Result<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.

model_fingerprintstring (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.

salience_hintfloatoptional

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

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.

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.

use brain_db_sdk::{new_id, wire::types::{EncodeVectorDirectRequest, MemoryKindWire}};

client
    .encode_vector_direct(&EncodeVectorDirectRequest {
        text: "Priya moved to Lisbon in March.".into(),
        vector: my_embedding,
        model_fingerprint: fp,
        session_id: 42,
        kind: MemoryKindWire::Episodic,
        salience_hint: 0.6,
        edges: vec![],
        request_id: new_id(),
        txn_id: None,
        deduplicate: true,
        act_as: None,
    })
    .await?;
See also
encodecapabilities

Was this page helpful?

forget

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

memory_list

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