MemoryEngineEmbeddingOptions
Defined in: src/lib/memoryEngine/types.ts:53
Options for embedding generation
Supports two auth methods:
getToken: For Privy identity tokens (uses Authorization: Bearer header)apiKey: For direct API keys (uses X-API-Key header)
At least one of getToken or apiKey must be provided.
Properties
apiKey?
optionalapiKey:string
Defined in: src/lib/memoryEngine/types.ts:58
Direct API key for server-side usage. Uses X-API-Key header.
baseUrl?
optionalbaseUrl:string
Defined in: src/lib/memoryEngine/types.ts:60
Base URL for the API
batchSize?
optionalbatchSize:number
Defined in: src/lib/memoryEngine/types.ts:64
Max texts per API call for batch embeddings (default: 100). Larger arrays are split into chunks.
cache?
optionalcache:Map<string,Float32Array<ArrayBufferLike>>
Defined in: src/lib/memoryEngine/types.ts:76
Optional in-memory cache for embedding vectors. When provided, texts are looked up in this map before calling the API, and new embeddings are stored after generation. Useful when the same texts are embedded repeatedly (e.g., across eval iterations or re-indexing runs).
Values are stored as Float32Array (the embedding model’s native
precision) rather than a float64 number[], halving the resident RAM of
the cache with no precision loss. generateEmbedding(s) still return
number[] at the API boundary, so callers are unaffected.
getToken()?
optionalgetToken: () =>Promise<string|null>
Defined in: src/lib/memoryEngine/types.ts:56
Function to get auth token (e.g., Privy’s getIdentityToken). Uses Authorization: Bearer header.
Returns
Promise<string | null>
maskInput()?
optionalmaskInput: (text:string) =>string
Defined in: src/lib/memoryEngine/types.ts:86
Optional transform applied to each text immediately before it is sent to
the embeddings endpoint (e.g. PiiRedactor.maskText). The cache and result
ordering still key on the original text — only the API request body is
transformed — so callers can keep storing/displaying the original value
while real PII never reaches the server. Used when PII redaction is active.
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
string
model?
optionalmodel:string
Defined in: src/lib/memoryEngine/types.ts:62
Embedding model to use
onUsage()?
optionalonUsage: (usage:object) =>void
Defined in: src/lib/memoryEngine/types.ts:78
Called after each embedding API call with the token usage from the response.
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
void
taskType?
optionaltaskType:TaskType
Defined in: src/lib/memoryEngine/types.ts:54
timeoutMs?
optionaltimeoutMs:number
Defined in: src/lib/memoryEngine/types.ts:92
Deadline, in ms, for EACH embeddings HTTP attempt (default 15000). An
attempt that exceeds it is aborted and counts as a transient failure, so the
bounded retry still applies. 0 disables the deadline.
tokenTimeoutMs?
optionaltokenTimeoutMs:number
Defined in: src/lib/memoryEngine/types.ts:98
Deadline, in ms, for the getToken() read that precedes a request (default
10000). A provider that never settles rejects instead of hanging the
embedding — and the recall waiting on it. 0 disables the deadline.
totalTimeoutMs?
optionaltotalTimeoutMs:number
Defined in: src/lib/memoryEngine/types.ts:108
Overall deadline, in ms, for one generateEmbedding or generateEmbeddings call — the token read,
every retry attempt and the backoff between them. Unset (the default) means
only the per-attempt deadlines apply, which is right for background/bulk
embeds. The recall query path sets it (see
RecallOptions.queryEmbedTotalTimeoutMs) so an outage degrades a turn to
BM25 within a few seconds instead of ~4 x timeoutMs. Batch calls share
one budget across authentication, all chunks, retries and backoff.