MemoryKit

Working with Memories

Store, manage, and retrieve memories — the core storage unit in MemoryKit.

Memories are the core unit of knowledge in MemoryKit. Each memory holds content that is automatically chunked, embedded, and indexed for retrieval. Smart Ingestion extracts title, tags, language, and content type — so you can send raw text and let MemoryKit do the rest.

Lifecycle

Ingest

Send text or upload a file. Returns 202 Accepted — processing is async.

Processing

Content is chunked, embedded with vectors, indexed for full-text search, and optionally connected in a knowledge graph.

Ready

Status becomes completed. The memory is now searchable and queryable.

Statuses: processingcompleted or failed. Use webhooks or polling to know when a memory is ready.

Create from text

const memory = await mk.memories.create({
  content: "Meeting notes from Q4 planning. Revenue target is $2M...",
  title: "Q4 Planning Notes",       // optional — auto-extracted
  tags: ["planning", "q4"],          // optional — auto-extracted
  metadata: { department: "eng" },   // arbitrary key-value pairs
  userId: "user_123",                // scope to a user
});
 
console.log(memory.id);     // "mem_abc123"
console.log(memory.status); // "processing"

Upload a file

Upload PDF, DOCX, XLSX, PPTX, TXT, CSV, Markdown, HTML, or JSON. Max file size: 100 MB.

const file = new File([buffer], "report.pdf", { type: "application/pdf" });
const memory = await mk.memories.upload({
  file,
  title: "Q4 Report",
  userId: "user_123",
});

Supported file types

FormatMIME Type
PDFapplication/pdf
Word (.docx)application/vnd.openxmlformats-officedocument.wordprocessingml.document
Excel (.xlsx)application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
PowerPoint (.pptx)application/vnd.openxmlformats-officedocument.presentationml.presentation
Plain texttext/plain
CSVtext/csv
Markdowntext/markdown
HTMLtext/html
JSONapplication/json

Batch ingest

Ingest up to 100 memories in a single request. Great for bulk imports.

const result = await mk.memories.batchIngest({
  items: [
    { content: "First document content", tags: ["import"] },
    { content: "Second document content", tags: ["import"] },
  ],
});
console.log(`${result.accepted} accepted, ${result.rejected} rejected`);

Polling for status

After creating a memory, poll until processing completes — or use webhooks for push notifications.

const memory = await mk.memories.create({ content: "Long document..." });
 
// Poll until ready
let current = memory;
while (current.status === "processing") {
  await new Promise((r) => setTimeout(r, 2000));
  current = await mk.memories.get(memory.id);
}
 
if (current.status === "completed") {
  console.log("Ready for search!");
} else {
  console.error("Processing failed");
}

For production, use webhooks instead of polling. Subscribe to memory.completed and memory.failed events.

List and paginate

Cursor-based pagination. Filter by status, type, or user.

// First page
const page = await mk.memories.list({ limit: 20, status: "completed" });
console.log(page.data.length, "memories");
 
// Next page
if (page.hasMore) {
  const next = await mk.memories.list({ cursor: page.cursor });
}

Update and reprocess

Update metadata, or change content and trigger reprocessing.

// Update metadata only
await mk.memories.update("mem_abc123", {
  title: "Updated Title",
  tags: ["meetings", "q4", "important"],
});
 
// Reprocess — re-chunks and re-embeds the content
await mk.memories.reprocess("mem_abc123");

Delete

Soft-deletes the memory and all associated chunks.

await mk.memories.delete("mem_abc123");
Edit on GitHub

On this page