npm install normal-memorySupports every current OpenAI chat/completions model (e.g. gpt-4o, gpt-4o-mini, gpt-4.1, o4-mini, and their real-time variants). Set llmProvider: 'openai' and pass whichever model name you need.
Set llmProvider: 'gemini' plus models like gemini-2.5-pro, gemini-2.5-flash, or gemini-2.0-flash-lite-001. We validate your selection before we hit Google’s API.
Your LLM API keys stay client-side—Normal Memory reads them per request only. Embeddings and background pipelines still use our managed infrastructure.
import { NormalMemory } from 'normal-memory';
// Initialize SDK
const memory = new NormalMemory({
apiKey: 'sk_backend_api_key', // Required: Normal Memory API key
conversationId: 'conversation-id', // Required: Conversation ID
baseUrl: 'https://your-backend-url.com', // Required: Backend URL
llmProvider: 'openai', // Required: 'openai' | 'gemini'
llmApiKey: process.env.OPENAI_KEY, // Required: Bring-your-own LLM key
llmModel: 'gpt-4o-mini', // Optional: Provider-specific model
});
// Use it!
await memory.say("Hi, I'm Alex");
const answer = await memory.ask("What's my name?");Model agnostic: swap llmProvider, llmApiKey, and llmModel to run against any OpenAI chat/completions model or supported Gemini model. Your LLM keys are never stored.
Main method that automatically routes to chat or ask based on message content.
await memory.say("I'm feeling great!");
await memory.say("What do you remember about me?");Normal conversation with immediate LLM response.
const reply = await memory.chat("Hi, I'm Alex");
// → "Hey Alex! Nice to meet you."Ask questions using long-term memory.
const answer = await memory.ask("Where do I live?");
// → Uses stored memories to answerconst memory = new NormalMemory({
apiKey: 'sk_...', // Required
conversationId: '...', // Required
baseUrl: 'https://...', // Required backend URL
llmProvider: 'openai', // Required: 'openai' | 'gemini'
llmApiKey: process.env.OPENAI_KEY,// Required: Bring-your-own LLM key
llmModel: 'gpt-4o-mini', // Optional: provider-specific override
smartRouting: true, // Optional: enable smart routing
});Automatically routes to chat or ask based on message content.
Normal conversation with immediate LLM response.
Ask question using long-term memory.