Skip to main content
Add long-term memory to your AI agents in three simple steps.

Get your API key

Sign up and get your API key from the Mem[v] Dashboard.
export MEMV_API_KEY="your-api-key-here"

Install the SDK

pip install memvai

Build your first memory-enabled app

1

Create a space

Spaces organize memories for different contexts or users.
from memvai import Memv

client = Memv()

# Create a space
response = client.spaces.create(
    name="My AI Assistant",
    description="Personal assistant memories"
)
space_id = response.space.id

print(f"Created space: {space_id}")
2

Add memories

Add text, upload files, or import from connectors.
# Add a text memory
memory = client.memories.add(
    space_id=space_id,
    content="User prefers concise responses without small talk"
)

# Upload a file
with open("meeting_notes.pdf", "rb") as file:
    batch = client.upload.batch.create(
        space_id=space_id,
        files=[file]
    )
3

Search memories

Query memories using natural language.
# Search for relevant memories
results = client.memories.search(
    space_id=space_id,
    query="What are the user's communication preferences?"
)

for memory in results.memories:
    print(f"- {memory.content}")

Complete example

Here’s a complete example of a memory-enabled chatbot:
from memvai import Memv

# Initialize client
client = Memv()

# Create or get space
response = client.spaces.create(name="Chatbot Memory")
space_id = response.space.id

def chat_with_memory(user_message: str) -> str:
    """Process user message with memory context."""

    # 1. Search for relevant memories
    memories = client.memories.search(
        space_id=space_id,
        query=user_message,
        limit=5
    )

    # 2. Build context from memories
    context = "\n".join([m.content for m in memories.memories])

    # 3. Generate response (using your LLM of choice)
    # response = your_llm.generate(
    #     prompt=f"Context: {context}\n\nUser: {user_message}",
    # )

    # 4. Store the conversation as a new memory
    client.memories.add(
        space_id=space_id,
        content=f"User: {user_message}\nAssistant: {response}"
    )

    return response

# Use it
response = chat_with_memory("What features should we prioritize?")
print(response)

What’s next?

SDK Documentation

Explore all SDK features

Core Concepts

Understand how Mem[v] works under the hood

Use Cases

Explore real-world applications

Connectors

Connect your data sources

Need help?

Join Discord

Chat with the community

GitHub

View source code and examples