The official Node.js SDK for BaseGrid — persistent memory infrastructure for AI agents.
Sub-200ms memory retrieval. Hybrid semantic search. Built for production.
npm install @basegrid-io/coreimport { BaseGrid } from '@basegrid-io/core';
const client = new BaseGrid({ apiKey: process.env.BASEGRID_API_KEY });
// Store a memory
await client.memory.store({
agentId: 'support-bot',
content: 'User prefers concise answers and dislikes jargon',
});
// Recall relevant memories
const memories = await client.memory.recall({
agentId: 'support-bot',
query: 'communication preferences',
limit: 5,
});
console.log(memories);import { BaseGrid } from '@basegrid-io/core';
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
const memory = new BaseGrid({ apiKey: process.env.BASEGRID_API_KEY });
// Retrieve context before generating
const memories = await memory.recall({ agentId: 'assistant', query: userMessage });
const context = memories.map(m => m.content).join('\n');
const { text } = await generateText({
model: openai('gpt-4o'),
prompt: `Context from memory:\n${context}\n\nUser: ${userMessage}`,
});
// Store the interaction
await memory.store({ agentId: 'assistant', content: `User asked: ${userMessage}` });import { BaseGrid } from '@basegrid-io/core';
const memory = new BaseGrid({ apiKey: process.env.BASEGRID_API_KEY });
// Use as a memory layer in your chain
const relevantMemories = await memory.recall({
agentId: 'langchain-agent',
query: input,
});await client.memory.store({
agentId: string, // Required: namespace for this agent
content: string, // Required: the memory content
metadata?: object, // Optional: key-value metadata
importance?: number, // Optional: 0-1 (default: 0.5)
});const memories = await client.memory.recall({
agentId: string, // Required: namespace to search
query: string, // Required: semantic search query
limit?: number, // Optional: max results (default: 5)
});const memories = await client.memory.list({
agentId: string, // Required
limit?: number, // Optional: (default: 10)
});await client.memory.forget('memory_id_here');const client = new BaseGrid({
apiKey: process.env.BASEGRID_API_KEY, // Required
baseUrl?: string, // Optional: default https://api.basegrid.io
timeout?: number, // Optional: ms (default: 10000)
});| Plan | Memories | API Calls/Month | Price |
|---|---|---|---|
| Free Trial | 500K | 1,000 | Free for 2 months |
| Pro Starter | 500K | 5M | $49/month |
| Pro Plus | 2M | 20M | $79/month |
| Scale | 10M | 50M | $199/month |
Self-hosting available on Scale plan. Get your key at basegrid.io
- Node.js 18+
- A BaseGrid API key (get one free)
- Python:
pip install basegrid-io→ basegridio/basegrid-python - Go:
go get github.com/basegridio/basegrid-go→ basegridio/basegrid-go
See CONTRIBUTING.md
Apache 2.0 — see LICENSE