Quickstart
Quickstart
Build a memory-augmented agent in 30 seconds.
1. Initialization
Import Memori and your LLM client. Memori will default to using a local SQLite database in your project root.
typescript
1import { Memori } from "memori-js";2import OpenAI from "openai";34const memori = new Memori(); 5const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });2. Registration
Connect the two clients. This registers a middleware that intercepts calls to chat.completions.create.
typescript
1// This single line enables active memory2memori.llm.register(client);3. Interaction
Chat normally. Memori silently searches for relevant past conversations and injects them into the system prompt.
typescript
1async function chat(message: string) {2 const response = await client.chat.completions.create({3 model: "gpt-4",4 messages: [5 { role: "user", content: message }6 ]7 });8 9 console.log(response.choices[0].message.content);10}1112// First run: "My name is Roach." -> Saved to memory.13// Second run: "What is my name?" -> Retrieves context, answers "Roach".