REM Labs Node.js SDK: Complete Guide

The @remlabs/sdk package gives any Node.js or TypeScript application persistent AI memory. Fully typed, promise-based, and compatible with ESM and CommonJS. This guide covers everything from basic usage to advanced patterns like streaming, batching, and framework integrations.

Installation

npm install @remlabs/sdk # or yarn add @remlabs/sdk # or pnpm add @remlabs/sdk

Quick Start

import { RemLabs } from "@remlabs/sdk"; const client = new RemLabs({ apiKey: "your-api-key" }); // Store a memory await client.remember({ content: "The app uses Next.js 14 with App Router", tags: ["stack", "frontend"], namespace: "my-project" }); // Search memories const results = await client.recall({ query: "what frontend framework do we use", namespace: "my-project", limit: 5 }); console.log(results[0].content); // → "The app uses Next.js 14 with App Router" // Delete a memory await client.forget({ memoryId: results[0].id });

TypeScript Types

The SDK exports full TypeScript types for all parameters and return values:

import { RemLabs, RememberParams, RecallParams, Memory, RecallResult } from "@remlabs/sdk"; const params: RememberParams = { content: "API uses REST with JSON responses", tags: ["api", "conventions"], namespace: "backend" }; await client.remember(params); const results: RecallResult = await client.recall({ query: "API design", limit: 10 }); results.forEach((mem: Memory) => { console.log(mem.id, mem.content, mem.score); });

Express.js Integration

import express from "express"; import { RemLabs } from "@remlabs/sdk"; const app = express(); const memory = new RemLabs({ apiKey: process.env.REMLABS_API_KEY }); app.post("/chat", express.json(), async (req, res) => { const { userId, message } = req.body; // Recall user context const context = await memory.recall({ query: message, namespace: `user-${userId}`, limit: 5 }); // ... generate response with your LLM ... // Store the exchange await memory.remember({ content: `User: ${message}\nBot: ${reply}`, namespace: `user-${userId}`, tags: ["conversation"] }); res.json({ reply }); });

Next.js API Route

// app/api/memory/route.ts import { RemLabs } from "@remlabs/sdk"; import { NextRequest, NextResponse } from "next/server"; const memory = new RemLabs({ apiKey: process.env.REMLABS_API_KEY! }); export async function POST(req: NextRequest) { const { action, ...params } = await req.json(); if (action === "remember") { await memory.remember(params); return NextResponse.json({ ok: true }); } if (action === "recall") { const results = await memory.recall(params); return NextResponse.json({ memories: results }); } return NextResponse.json({ error: "Unknown action" }, { status: 400 }); }

Batch Operations

Store multiple memories efficiently with batch operations:

// Batch remember await client.rememberBatch([ { content: "DB uses PostgreSQL", tags: ["db"] }, { content: "Cache layer is Redis", tags: ["cache"] }, { content: "Queue is RabbitMQ", tags: ["queue"] } ], { namespace: "infrastructure" });

Environment Variables

The SDK reads REMLABS_API_KEY from process.env if no key is passed:

// .env REMLABS_API_KEY=your-api-key // Then: const client = new RemLabs(); // reads from env

Edge compatible: The SDK uses the Fetch API internally, making it compatible with Vercel Edge Functions, Cloudflare Workers, and Deno Deploy.

Add memory to your Node.js app

npm install @remlabs/sdk. Free tier. Full TypeScript support.

Get started free →