cookbook · Extractor · Agent memory
Extract memories from a conversation
An assistant that remembers people needs to pull durable facts out of each conversation: preferences, restrictions, plans and routines. Memory layers like Mem0 do this with a general-purpose model on every message. This recipe does it with one Extractor call over the conversation, which returns a list of facts about the user, each tagged with a kind your store can index.
Request
POST /v1/extract, documented in the Extractor reference.
curl https://meragpt.com/v1/extract \
-H "Authorization: Bearer $MERAGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "extractor-1",
"reference_date": "2026-11-24",
"text": "user: Can you help me plan meals for the week? I'\''m vegetarian, have been for about six years.\nassistant: Of course. Any allergies or things you don'\''t like?\nuser: I'\''m allergic to peanuts, and honestly I can'\''t stand mushrooms.\nassistant: Noted. How much time do you have for cooking on weeknights?\nuser: Not much, maybe 30 minutes. My partner Sam usually cooks on weekends though.\nassistant: Great. Any cuisines you love?\nuser: Thai and Ethiopian mostly. Oh and I'\''m training for a half marathon in March so I need more protein than usual.\nassistant: That helps. Want me to include lunches?\nuser: No, I eat lunch at the office canteen. Just dinners.",
"schema": {
"type": "object",
"properties": {
"memories": {
"type": "array",
"description": "Facts about the user worth remembering for future conversations.",
"items": {
"type": "object",
"properties": {
"fact": {
"type": "string"
},
"kind": {
"type": "string",
"enum": [
"preference",
"restriction",
"personal",
"goal",
"routine"
]
}
}
}
}
}
}
}'What came back
The real output from running this recipe, unedited.
{
"memories": [
{
"fact": "Vegetarian",
"kind": "preference"
},
{
"fact": "Allergic to peanuts",
"kind": "restriction"
},
{
"fact": "Does not like mushrooms",
"kind": "personal"
},
{
"fact": "Cooking time is about 30 minutes",
"kind": "routine"
},
{
"fact": "Partner Sam usually cooks on weekends",
"kind": "routine"
},
{
"fact": "Thai and Ethiopian cuisines",
"kind": "personal"
},
{
"fact": "Training for a half marathon in March",
"kind": "goal"
},
{
"fact": "Needs more protein than usual",
"kind": "goal"
},
{
"fact": "Eats lunch at the office canteen",
"kind": "routine"
}
]
}Python
import os, requests
API = "https://meragpt.com/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['MERAGPT_API_KEY']}"}
conversation = "\n".join(f"{m['role']}: {m['content']}" for m in messages)
schema = {
"type": "object",
"properties": {
"memories": {
"type": "array",
"description": "Facts about the user worth remembering for future conversations.",
"items": {
"type": "object",
"properties": {
"fact": {
"type": "string"
},
"kind": {
"type": "string",
"enum": [
"preference",
"restriction",
"personal",
"goal",
"routine"
]
}
}
}
}
}
}
r = requests.post(f"{API}/extract", headers=HEADERS, json={
"model": "extractor-1",
"text": conversation,
"schema": schema,
"reference_date": "2026-11-24",
}).json()
for m in r["data"]["memories"]:
if not store.contains(m["fact"]): # your vector store or database
store.add(m["fact"], kind=m["kind"])
TypeScript
const API = "https://meragpt.com/v1";
const headers = {
Authorization: `Bearer ${process.env.MERAGPT_API_KEY}`,
"Content-Type": "application/json",
};
const conversation = messages.map((m) => `${m.role}: ${m.content}`).join("\n");
const schema = {
"type": "object",
"properties": {
"memories": {
"type": "array",
"description": "Facts about the user worth remembering for future conversations.",
"items": {
"type": "object",
"properties": {
"fact": {
"type": "string"
},
"kind": {
"type": "string",
"enum": [
"preference",
"restriction",
"personal",
"goal",
"routine"
]
}
}
}
}
}
};
const r = await fetch(`${API}/extract`, {
method: "POST",
headers,
body: JSON.stringify({ model: "extractor-1", text: conversation, schema, reference_date: "2026-11-24" }),
}).then((res) => res.json());
for (const m of r.data.memories) console.log(m.kind, "-", m.fact);
When to trust it
All nine facts are real and worth keeping, and nothing was invented: there is no made-up detail in the list. The kinds are less reliable than the facts: 'Thai and Ethiopian cuisines' was tagged personal where preference fits better, and 'Vegetarian' as a preference rather than a restriction. Store the facts, and treat the kind as a hint. Before saving, drop facts your store already holds.
Try it without code in the playground, or see more Extractor recipes: read an invoice into your ap system, pull the key terms out of a contract, turn a support email into a ticket, get action items out of meeting notes, turn a receipt photo into an expense entry.