Skip to content

Add Memory

Add a memory from a conversation.

This example assumes using Mem0; is in scope and apiKey contains your Mem0 API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
using var client = new Mem0Client(apiKey);

// Add a memory from a user conversation.
var results = await client.Memories.MemoriesCreateAsync(
    messages: [
        new Dictionary<string, string?>
        {
            ["role"] = "user",
            ["content"] = "I prefer dark mode in all my applications.",
        },
    ],
    userId: "test-user");