JavaScript / TypeScript SDK
The official Suprflo SDK for Node.js and TypeScript. Wraps the REST API.
Install
bash
npm install @suprflo/sdkQuickstart
ts
import { MemoryGClient } from '@suprflo/sdk'
// `MemoryClient` is exported as an alias if you prefer that name.
const client = new MemoryGClient({
apiKey: process.env.SUPRFLO_API_KEY!,
// baseUrl defaults to https://api.suprflo.com
})
// Add memories from a message
await client.addMemory(['I prefer window seats and travel light'], { user_id: 'alice' })
// Recall relevant memories
const { results } = await client.searchMemories('seating preference?', {
filters: { user_id: 'alice' },
top_k: 5,
})
console.log(results) // [{ id, memory, score, metadata }, …]Methods
| Method | REST call |
|---|---|
addMemory(messages, options?) | POST /api/memories |
searchMemories(query, options?) | POST /api/memories/search |
listMemories(options?) | GET /api/memories |
getMemory(id) | GET /api/memories/{id} |
updateMemory(id, text) | PUT /api/memories/{id} |
deleteMemory(id) | DELETE /api/memories/{id} |
deleteAllMemories(options) | DELETE /api/memories |
getHistory(id) | GET /api/memories/{id}/history |
users() | GET /api/memories/users |
options mirror the REST fields. For addMemory the subject ids go at the top level (user_id, agent_id, run_id, app_id, plus metadata, infer, async_mode). For searchMemories and listMemories, scope goes inside filters ({ filters: { user_id } }); a top-level user_id on search is ignored. Other search fields: top_k, rerank, memory_types, as_of. Everything is fully typed.
Full source: the @suprflo/sdk package on GitHub.
Errors
Non-2xx responses throw with the HTTP status and the API's detail message. 503 is a retryable "upstream busy" signal.