1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
|
---
title: "Migrating from Zep to Supermemory"
description: "Quick guide to migrate from Zep to Supermemory"
sidebarTitle: "From Zep"
---
## Key Differences
| Zep AI | Supermemory |
|--------|-------------|
| Sessions & Messages | Documents & Container Tags |
| `session.create()` | Use `containerTags` parameter |
| `memory.add(session_id, ...)` | `add({containerTag: [...]})` |
| `memory.search(session_id, {text: ...})` | `search.execute({q: ..., containerTags: [...]})` |
## Installation
<CodeGroup>
```bash Python
pip install supermemory
```
```bash TypeScript
npm install supermemory
```
</CodeGroup>
<CodeGroup>
```python Python
from supermemory import Supermemory
client = Supermemory(api_key="your-api-key")
```
```typescript TypeScript
import { Supermemory } from "supermemory";
const client = new Supermemory({ apiKey: "your-api-key" });
```
</CodeGroup>
## API Mapping
### Session Management
<CodeGroup>
```python Zep AI
session = client.session.create(
session_id="user_123",
user_id="user_123"
)
```
```python Supermemory
# No explicit session creation - use containerTag
containerTag = ["user_123"]
```
</CodeGroup>
### Adding Memories
<CodeGroup>
```python Zep AI
client.memory.add(
session_id="user_123",
memory={"content": "User prefers dark mode"}
)
```
```python Supermemory
client.add({
"content": "User prefers dark mode",
"containerTag": ["user_123"]
})
```
</CodeGroup>
### Searching
<CodeGroup>
```python Zep AI
results = client.memory.search(
session_id="user_123",
search_payload={"text": "preferences", "limit": 5}
)
```
```python Supermemory
results = client.search.execute({
"q": "preferences",
"containerTag": ["user_123"],
"limit": 5
})
```
</CodeGroup>
### Getting All Memories
<CodeGroup>
```python Zep AI
memories = client.memory.get(session_id="user_123")
```
```python Supermemory
documents = client.memories.list({
"containerTag": ["user_123"],
"limit": 100
})
```
</CodeGroup>
## Migration Steps
1. **Replace client initialization** - Use Supermemory client instead of Zep
2. **Map sessions to container tags** - Replace `session_id="user_123"` with `containerTag: ["user_123"]`
3. **Update method calls** - Use `add()` and `search.execute()` instead of `memory.add()` and `memory.search()`
4. **Change search parameter** - Use `q` instead of `text`
5. **Handle async processing** - Documents process asynchronously (status: `queued` → `done`)
## Complete Example
<CodeGroup>
```python Zep AI
from zep_python import ZepClient
client = ZepClient(api_key="...")
session = client.session.create(session_id="user_123", user_id="user_123")
client.memory.add("user_123", {
"content": "I love Python",
"role": "user"
})
results = client.memory.search("user_123", {
"text": "programming",
"limit": 3
})
```
```python Supermemory
from supermemory import Supermemory
client = Supermemory(api_key="...")
containerTag = ["user_123"]
client.add({
"content": "I love Python",
"containerTag": containerTag,
"metadata": {"role": "user"}
})
results = client.search.execute({
"q": "programming",
"containerTag": containerTag,
"limit": 3
})
```
</CodeGroup>
## Important Notes
- **No session creation needed** - Just use `containerTag` in requests
- **Messages are documents** - Store with `metadata.role` and `metadata.type`
- **Async processing** - Documents may take a moment to be searchable
- **Response structure** - Supermemory returns chunks with scores, not direct memory content
## Migrating Existing Data
### Quick Migration (All-in-One)
Complete migration in one script:
<CodeGroup>
```typescript TypeScript
import { ZepClient } from "@getzep/zep-js";
import { Supermemory } from "supermemory";
// Initialize clients
const zep = new ZepClient({ apiKey: "your_zep_api_key" });
const supermemory = new Supermemory({ apiKey: "your_supermemory_api_key" });
// Export from Zep and import to Supermemory
const sessionIds = ["session_1", "session_2"]; // Add your session IDs
for (const sessionId of sessionIds) {
const memory = await zep.memory.get(sessionId);
const memories = memory?.memories || [];
for (const mem of memories) {
if (mem.content) {
await supermemory.add({
content: mem.content,
containerTag: [`session_${sessionId}`, `user_${memory.user_id || "unknown"}`],
metadata: {
role: mem.role,
type: "message",
original_uuid: mem.uuid,
...mem.metadata
}
});
console.log(`✅ Imported: ${mem.content.substring(0, 50)}...`);
}
}
}
console.log("Migration complete!");
```
```python Python
from zep_python import ZepClient
from supermemory import Supermemory
# Initialize clients
zep = ZepClient(api_key="your_zep_api_key")
supermemory = Supermemory(api_key="your_supermemory_api_key")
# Export from Zep and import to Supermemory
session_ids = ["session_1", "session_2"] # Add your session IDs
for session_id in session_ids:
memory = zep.memory.get(session_id)
memories = memory.memories if memory else []
for mem in memories:
if mem.content:
supermemory.add({
"content": mem.content,
"containerTag": [f"session_{session_id}", f"user_{memory.user_id or 'unknown'}"],
"metadata": {
"role": mem.role,
"type": "message",
"original_uuid": mem.uuid,
**(mem.metadata or {})
}
})
print(f"✅ Imported: {mem.content[:50]}...")
print("Migration complete!")
```
</CodeGroup>
### Full Migration Script
For a complete migration script with error handling, verification, and progress tracking, copy this TypeScript script:
```typescript
import { ZepClient } from "@getzep/zep-js";
import { Supermemory } from "supermemory";
import * as dotenv from "dotenv";
import * as fs from "fs";
dotenv.config();
interface MigrationStats {
imported: number;
failed: number;
skipped: number;
}
async function migrateFromZep(
zepApiKey: string,
supermemoryApiKey: string,
sessionIds: string[]
) {
const zep = new ZepClient({ apiKey: zepApiKey });
const supermemory = new Supermemory({ apiKey: supermemoryApiKey });
const stats: MigrationStats = { imported: 0, failed: 0, skipped: 0 };
const exportedData: any = {};
console.log("🔄 Starting migration...");
// Export from Zep
for (const sessionId of sessionIds) {
try {
const session = await zep.session.get(sessionId);
const memory = await zep.memory.get(sessionId);
const memories = memory?.memories || [];
exportedData[sessionId] = {
session: { session_id: sessionId, user_id: session?.user_id },
memories: memories.map((m: any) => ({
content: m.content,
role: m.role,
metadata: m.metadata,
uuid: m.uuid,
})),
};
console.log(`✅ Exported ${memories.length} memories from ${sessionId}`);
} catch (error: any) {
console.log(`❌ Error exporting ${sessionId}: ${error.message}`);
}
}
// Save backup
const backupFile = `zep_export_${Date.now()}.json`;
fs.writeFileSync(backupFile, JSON.stringify(exportedData, null, 2));
console.log(`💾 Backup saved to: ${backupFile}`);
// Import to Supermemory
let totalMemories = 0;
for (const [sessionId, data] of Object.entries(exportedData) as any) {
const containerTag = ["imported_from_zep", `session_${sessionId}`];
if (data.session.user_id) {
containerTag.push(`user_${data.session.user_id}`);
}
for (const memory of data.memories) {
totalMemories++;
try {
if (!memory.content?.trim()) {
stats.skipped++;
continue;
}
await supermemory.add({
content: memory.content,
containerTag: containerTag,
metadata: {
source: "zep_migration",
role: memory.role,
type: "message",
original_uuid: memory.uuid,
...memory.metadata,
},
});
stats.imported++;
console.log(`✅ [${stats.imported}/${totalMemories}] Imported`);
} catch (error: any) {
stats.failed++;
console.log(`❌ Failed: ${error.message}`);
}
}
}
console.log("\n📊 Migration Summary:");
console.log(`✅ Imported: ${stats.imported}`);
console.log(`⚠️ Skipped: ${stats.skipped}`);
console.log(`❌ Failed: ${stats.failed}`);
}
// Usage
const sessionIds = ["session_1", "session_2"]; // Add your session IDs
migrateFromZep(
process.env.ZEP_API_KEY!,
process.env.SUPERMEMORY_API_KEY!,
sessionIds
).catch(console.error);
```
## Resources
- [Supermemory SDKs](/memory-api/sdks/overview)
- [API Reference](/memory-api/overview)
- [Search Documentation](/search/overview)
|