MemoryKit

Chats

Conversational interface on top of RAG with full message history.

Chats provide a conversational interface on top of RAG. Create a session, send messages, and get context-aware responses with full history.

Create a chat and send messages

// Create a chat session
const chat = await mk.chats.create({
  userId: "user_123",
  title: "Support Chat",
});
 
// Send a message (RAG-powered response)
const response = await mk.chats.sendMessage(chat.id, {
  message: "How do I reset my password?",
  mode: "balanced",
});
 
console.log(response.message.content);
 
// Stream a response
for await (const event of mk.chats.streamMessage(chat.id, {
  message: "Can you explain in more detail?",
})) {
  if (event.event === "text") {
    process.stdout.write(event.data.content);
  }
}

Chat endpoints

MethodEndpointDescription
POST/v1/chatsCreate a new chat session
POST/v1/chats/:id/messagesSend a message
POST/v1/chats/:id/messages/streamStream a message response
GET/v1/chatsList chat sessions
GET/v1/chats/:idGet chat history

On this page