Skip to main content
The Supermemory AI SDK provides native integration with Vercel’s AI SDK through two approaches: User Profiles for automatic personalization and Memory Tools for agent-based interactions.
Migrating to v2 from 1.4.x? Check the migration guide.

@supermemory/tools on npm

Check out the NPM page for more details

Installation

Quick Comparison

ApproachUse CaseSetup
User ProfilesPersonalized LLM responses with automatic user contextSimple middleware
Memory ToolsAI agents that need explicit memory controlTool definitions

User Profiles with Middleware

Automatically inject user profiles into every LLM call for instant personalization.

Required fields

Both containerTag and customId are required.
  • containerTagwho the memories belong to. Use a stable identifier per user, workspace, or tenant (e.g. "user-123", "acme-workspace"). Memory search and writes are scoped to this tag.
  • customIdwhich conversation this turn belongs to. Use it to group messages from the same chat session into a single document (e.g. "chat-2026-04-25", a thread ID, or a UUID per session).
Memory saving is enabled by default (addMemory: "always"). New conversations are persisted automatically. To opt out, set addMemory: "never":

Memory Search Modes

Profile Mode (Default) - Retrieves the user’s complete profile:
Query Mode - Searches memories based on the user’s message:
Full Mode - Combines profile AND query-based search:

Custom Prompt Templates

Customize how memories are formatted. The template receives userMemories, generalSearchMemories, and searchResults (raw array for filtering by metadata):

Verbose Logging

When Supermemory errors (default: continue without memories)

If the Supermemory API returns an error, is unreachable, or retrieval hits the internal time limit, memory injection is skipped. skipMemoryOnError defaults to true, so the LLM call still runs with the original prompt (no injected memories). Use verbose: true if you want console output when that happens. To fail the call when memory retrieval fails instead, set skipMemoryOnError: false:

Persisting Tool Calls (default: off)

By default, saved conversations include only user and assistant text — tool calls and tool results are dropped, since tool payloads are often large and low-signal and would pollute memory extraction. To persist the full tool round trip (tool calls with their arguments, plus tool results, in their original order), set includeToolCalls: true:

Memory Tools

Add memory capabilities to AI agents with search, add, and fetch operations.

Available Tools

Search Memories - Semantic search through user memories:
Add Memory - Store new information:

Using Individual Tools

For more control, import tools separately:

Tool Results