Documentation

AI Memory SDK

Why AI Memory

Overview

Your users don't want a chatbot — they want a product that remembers them. AI Memory gives your app a durable, searchable memory layer so your assistant can keep context across sessions without you building vector infrastructure.

Start in minutes: create an account and generate an API key. Then use the SDK to store and recall memories as part of your agent loop.

Quickstart

  1. 1Create an API key in the dashboard.
  2. 2Install the SDK:npm install @youraimemory/sdk
  3. 3Store memories right after the user says something worth remembering.
  4. 4Before each model call, fetch relevant memories and inject them into your prompt.
memory.ts
import MemoryClient from "@youraimemory/sdk"

const client = new MemoryClient({ apiKey: process.env.YOURAIMEMORY_API_KEY })

// 1) Save something durable
await client.add({
  userId: "user_123",
  content: "Prefers concise responses. Uses Go.",
})

// 2) Recall before the next model call
const { memories } = await client.find({
  userId: "user_123",
  query: "formatting preferences",
})

For end-to-end apps, browse Examples.

Authentication

The SDK sends the bearer token automatically. Set YOURAIMEMORY_API_KEY (recommended), or pass apiKey to the client constructor.

YOURAIMEMORY_API_KEY=sk_live_...
ADD

client.add()

Store a single durable memory for a user. Use this when you detect a stable preference, identity detail, or long-term goal — not every chat message.

await client.add({
  userId: "user_123",
  content: "Prefers short bullet points.",
  metadata: { source: "chat" },
})
DEL

client.deleteMemory()

Delete a memory by id for compliance, cleanup, or user-controlled data removal.

await client.deleteMemory("mem_123")
AUTO

client.auto()

Let AI Memory extract memories from a chat transcript automatically. This is the fastest path to production-grade personalization: you send messages, we pick what matters and store it.

await client.auto({
  userId: "user_123",
  messages: [
    { role: "user", content: "I always want concise answers." },
    { role: "assistant", content: "Got it — I'll remember that." },
  ],
  maxMemories: 5,
})

Pro tip: use client.auto() for broad capture, then client.find() for precision recall.

Ready to ship memory?

Open the examples repo, copy the patterns, and plug AI Memory into your agent loop today.

View Examples