Skip to main content
Add memory capabilities to the official OpenAI SDKs using Supermemory. Two approaches available:
  1. withSupermemory wrapper - Automatic memory injection into system prompts (zero-config)
  2. Function calling tools - Explicit tool calls for search/add memory operations
Migrating to v2 from 1.4.x? Check the migration guide.
New to Supermemory? Start with withSupermemory for the simplest integration. It automatically injects relevant memories into your prompts.

Supermemory tools on npm

Check out the NPM page for more details

Supermemory AI SDK

Check out the PyPI page for more details

withSupermemory Wrapper

The simplest way to add memory to your OpenAI client. Wraps your client to automatically inject relevant memories into system prompts.

Installation

Quick Start

Configuration Options

Modes Explained

ModeDescriptionUse Case
profileInjects user profile (static + dynamic facts)General personalization
querySearches memories based on user messageQuestion answering
fullBoth profile and query-based searchBest for chatbots

Works with Responses API Too

Environment Variables


Function Calling Tools

For explicit control over memory operations, use function calling tools. The model decides when to search or add memories.

Installation

Quick Start

Configuration

Memory Tools Configuration

Available Tools

Search Memories

Search through user memories using semantic search:

Add Memory

Store new information in memory:

Individual Tools

Use tools separately for more granular control:

Complete Chat Example

Here’s a complete example showing a multi-turn conversation with memory:

Error Handling

Handle errors gracefully in your applications:

API Reference

Python SDK

SupermemoryTools

Constructor
Methods
  • get_tool_definitions() - Get OpenAI function definitions
  • search_memories(information_to_get, limit, include_full_docs) - Search user memories
  • add_memory(memory) - Add new memory
  • execute_tool_call(tool_call) - Execute individual tool call

execute_memory_tool_calls

JavaScript SDK

supermemoryTools

createToolCallExecutor

Environment Variables

Set these environment variables:

Development

Python Setup

JavaScript Setup

Next Steps

AI SDK Integration

Use with Vercel AI SDK for streamlined development

Memory API

Direct API access for advanced memory management