content/providers/03-community-providers/42-supermemory.mdx
Supermemory is a long-term memory platform that adds persistent, self-growing memory to your AI applications. The Supermemory provider for the AI SDK enables you to build AI applications with memory that works like the human brain:
Learn more about Supermemory's capabilities in the Supermemory Documentation.
The Supermemory provider is available in the @supermemory/tools module. You can install it with:
<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}> <Tab> <Snippet text="pnpm add @supermemory/tools" dark /> </Tab> <Tab> <Snippet text="npm install @supermemory/tools" dark /> </Tab> <Tab> <Snippet text="yarn add @supermemory/tools" dark /> </Tab> <Tab> <Snippet text="bun add @supermemory/tools" dark /> </Tab> </Tabs>
You can obtain your Supermemory API key for free at https://console.supermemory.ai.
There are two ways to integrate Supermemory with your AI applications:
1. Using Supermemory Tools
Import and use Supermemory tools with your existing AI SDK setup:
import { supermemoryTools } from '@supermemory/tools/ai-sdk';
2. Using the Memory Router
Use the Memory Router for direct integration with language model providers:
import { createAnthropic } from '@ai-sdk/anthropic';
const supermemoryRouter = createAnthropic({
baseUrl: 'https://api.supermemory.ai/v3/https://api.anthropic.com/v1',
apiKey: 'your-provider-api-key',
headers: {
'x-supermemory-api-key': 'supermemory-api-key',
'x-sm-conversation-id': 'conversation-id',
},
});
Here are examples of using Supermemory with the AI SDK:
generateText with Toolsimport { generateText } from 'ai';
import { createOpenAI } from '@ai-sdk/openai';
import { supermemoryTools } from '@supermemory/tools/ai-sdk';
const openai = createOpenAI({
apiKey: 'YOUR_OPENAI_KEY',
});
const { text } = await generateText({
model: openai('gpt-5-mini'),
prompt: 'Remember that my name is Alice',
tools: supermemoryTools('YOUR_SUPERMEMORY_KEY'),
});
console.log(text);
streamText with Automatic Memoryimport { streamText } from 'ai';
import { createOpenAI } from '@ai-sdk/openai';
import { supermemoryTools } from '@supermemory/tools/ai-sdk';
const openai = createOpenAI({
apiKey: 'YOUR_OPENAI_KEY',
});
const result = streamText({
model: openai('gpt-5'),
prompt: 'What are my dietary preferences?',
tools: supermemoryTools('YOUR_SUPERMEMORY_KEY'),
});
// The AI will automatically call searchMemories tool
// Example tool call:
// searchMemories({ informationToGet: "dietary preferences and restrictions" })
// OR
// addMemory({ memory: "User is allergic to peanuts" })
for await (const chunk of result.textStream) {
console.log(chunk);
}
import { streamText } from 'ai';
import { createAnthropic } from '@ai-sdk/anthropic';
const supermemoryRouter = createAnthropic({
baseUrl: 'https://api.supermemory.ai/v3/https://api.anthropic.com/v1',
apiKey: 'your-provider-api-key',
headers: {
'x-supermemory-api-key': 'supermemory-api-key',
'x-sm-conversation-id': 'conversation-id',
},
});
const result = streamText({
model: supermemoryRouter('claude-3-sonnet'),
messages: [
{ role: 'user', content: 'Hello! Remember that I love TypeScript.' },
],
});
For more information about these features and advanced configuration options, visit the Supermemory Documentation.