TypeScript client
Use the TypeScript client when a Node.js service needs typed calls to the SPM memory API. The package uses the global fetch API and supports Node.js 18 and newer. It is version 0.1.0 and is not published to npm yet.
Install from source
Clone the SPM-Polaris repository, then install dependencies in the TypeScript SDK directory. Build it before importing the compiled package.
git clone https://github.com/VeridicalTech/SPM-Polaris.git
cd SPM-Polaris/sdk/typescript
npm install
npm run build
The package name is @spmos/spm-client. Do not use npm install @spmos/spm-client as a public registry install. The package is not on npm yet, so source installation is required.
Ingest and recall
import { SpmClient } from '@spmos/spm-client';
const spm = new SpmClient({
baseUrl: 'https://api.spmos.ai',
apiKey: process.env.SPM_API_KEY!,
});
await spm.ingest({
text: 'The launch review is scheduled for Friday.',
source_id: 'launch-review-2026-01',
topic: 'launch',
});
const result = await spm.recall({
query: 'When is the launch review?',
top_k: 10,
});
if (result.gate_reason === 'passed') {
const full = await spm.recallText('When is the launch review?', { top_k: 10 });
console.log(full.text);
} else {
console.log(`No supported answer: ${result.gate_reason}`);
}
A refusal is a normal result, not a client exception. Treat any gate_reason other than passed as unsupported. Do not show answer as a verified claim after a refusal.
Methods
SpmClient provides ingest, ingestBatch, rememberMany, recall, recallText, read, and purge. It also provides listPartitions, partition export and wipe, memory export and import, event subscription methods, and subscription listing or removal. rememberMany splits input into batches of 500 and sends them in order. recallText recalls evidence and then reads its tokens, returning both the recall response and joined text.
Errors and retry behavior
Failed requests throw SpmApiError. Its status field contains the HTTP status. Its code field contains the API error code when the response includes one. GET list operations retry once after a 429 response and honor Retry-After. POST requests do not retry.
/v2/recall limits top_k to 50 (the MCP tool allows 100), accepts up to 32 read tokens per request, and expires them after about 300 seconds, so read promptly after recall. The server may return pagination metadata with partition lists. The client does not hide refusals or convert them into exceptions. Check the returned gate reason before displaying recalled text.