SDKs

Documentation · updated 9 November 2026

In short: @localmem/memory for TypeScript and localmem-memory for Python cover the whole API reference and nothing else. Each signs every request, sends an Idempotency-Key with every document and retries it safely, waits out a short Retry-After, and raises an error carrying our { error, message }. Neither has dependencies beyond the language's own library.

Configuration

VariableMeaning
LOCALMEM_PROJECTThe project id, p-…
LOCALMEM_KEY_IDThe key that signs, key_…
LOCALMEM_KEY_SECRETIts secret. Never print or commit it
LOCALMEM_API_URLOptional; default https://api.localmem.org

npx @localmem/memory login or localmem-memory login writes the first three for a test key. Each can also be passed to the constructor: new Memory({ project, keyId, secret }), Memory(project=…, key_id=…, secret=…).

Calls

TypeScriptPythonRequest
customers.create(ref, { phi })customers.create(ref, phi=)POST /v1/partner/tenants
customers.list(), .get(t), .delete(t)the same/v1/partner/tenants
documents.send(t, { text, … })documents.send(t, text, …)POST /v1/memory/documents
documents.get(t, id), .wait(t, id)the sameGET /v1/memory/documents/{id}
facts, write, search, recall, get, profile, forgetthe samePOST /v1/memory/{route}
usage({ from, to })usage(from_, to)GET /v1/partner/usage

tenants is the same group as customers, under the API's name: tenants.list() and customers.list() are one call.

Each memory call takes the customer's tenant first, then the request's fields as the API reference names them. A document above 20 KB is read in the background: send answers its document_id, and wait polls until it is written or failed.

Retries

Your month

From 0.1.3 (coming soon), allowance("documents" | "writes" | "reads") gives what the last answer that spent it said: { name, limit, remaining, resets }, packs included, or nothing before any. paused("documents" | "writes") gives the error a call of that kind raises while the month holds it back, or nothing. Show it quietly to your users ("memory paused until 1 December") and keep your product working: reads still answer.

Errors

Any other answer raises LocalmemError with status, error (the code to act on), message (in words, for people), the request id (requestId, request_id), retryAfter in seconds when given, and body, the whole answer, with fields such as resets_at. The codes are listed in the API reference.

try {
  await lm.documents.send(tenant, { text });
} catch (e) {
  if (e instanceof LocalmemError && e.error === "monthly_limit") console.log(e.message);
  else throw e;
}

Login

login takes --env-file (default .env), --device (the name the approval page shows; default this computer's), --api and --no-browser. It pairs for a test key only. The secret is written to the file and never printed.