Skip to main content
Build AI applications with LangChain that remember context across conversations. Supermemory handles memory storage, retrieval, and user profiling while LangChain manages your conversation flow.

Overview

This guide shows how to integrate Supermemory with LangChain to create AI agents that:
  • Maintain user context through automatic profiling
  • Store and retrieve relevant memories semantically
  • Personalize responses based on conversation history

Setup

Install the required packages:
Configure your environment:
Get your Supermemory API key from console.supermemory.ai.

Basic Integration

Initialize both clients and set up a simple chat function with memory:

Core Concepts

User Profiles

Supermemory automatically maintains user profiles with two types of information:
  • Static facts: Long-term information about the user (preferences, expertise, background)
  • Dynamic context: Recent activity and current focus areas

Memory Storage

Content you add is automatically processed into searchable memories:
Search returns both extracted memories and document chunks:

Complete Example: Code Review Assistant

Here’s a full example of a code review assistant that learns from past reviews and adapts to the user’s coding style:

Advanced Patterns

Conversation History with Memory

Maintain multi-turn conversations while building long-term memory:

Metadata Filtering

Use metadata to organize and filter memories:

Batch Memory Operations

Efficiently store multiple memories:

Next Steps

User Profiles

Deep dive into automatic user profiling

Search API

Advanced search patterns and filtering

OpenAI SDK

Native OpenAI integration with memory tools

Vercel AI SDK

Memory middleware for Next.js apps