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
| Variable | Meaning |
|---|---|
LOCALMEM_PROJECT | The project id, p-… |
LOCALMEM_KEY_ID | The key that signs, key_… |
LOCALMEM_KEY_SECRET | Its secret. Never print or commit it |
LOCALMEM_API_URL | Optional; 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
| TypeScript | Python | Request |
|---|---|---|
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 same | GET /v1/memory/documents/{id} |
facts, write, search, recall, get, profile, forget | the same | POST /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
- A document, and any
GET, is sent again after no answer or a 5xx, up to 3 times with growing waits; a document keeps itsIdempotency-Key, so it is never read twice. - A document whose first send is still being read (
409 idempotency_key_in_use) is sent again shortly, and gets that first send's answer. - A
429or503 server_busywas refused before any work, so any request is sent again after itsRetry-After, when that is 60 seconds or less. - Any other call that got a 5xx (a write, facts, a search) is not sent again: it may have been done. The error is raised for you to decide.
- A monthly limit (
429 monthly_limit) is raised at once: its wait is until the month resets. From 0.1.3 (coming soon), after it the SDK refuses that kind of call (documents, or writes and facts) at once with the same error, without sending it, untilresets_ator until any answer says the allowance is back (a pack, going live); one call of that kind still goes once a minute to find out. Searches are never held back.
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.