Quick Start Guide

From zero to AI with memory in 5 minutes ⚑

Let's build your first Memof.ai application! Pick your weapon of choice and let's go.

Prerequisites Checklist

Before we start, make sure you have:

  • βœ… API Token from memof.ai (format: moa_...)
  • βœ… Your favorite language ready (Python, JavaScript, or just cURL)
  • βœ… 5 minutes of uninterrupted focus time
  • βœ… Coffee (optional but recommended β˜•)

Don't have an API token? Get one at memof.ai β€” it takes 30 seconds!

Choose Your Path

import { Tab, Tabs } from 'rspress/theme';

Python Quick Start

Step 1: Install

pip install memofai

Step 2: Your First Memory

Create a file called first_memory.py:

from memofai import create_moa_client

# Initialize client
client = create_moa_client(
    api_token='moa_your_token_here',  # Replace with your token!
    environment='production'
)

# Create a workspace
print("πŸ“ Creating workspace...")
workspace = client.workspaces.create({
    'name': 'Quick Start Project',
    'description': 'My first Memof.ai app!'
})
print(f"βœ… Workspace created: {workspace['name']} (ID: {workspace['id']})")

# Create a bot
print("\nπŸ€– Creating bot...")
bot = client.bots.create({
    'name': 'Quick Start Bot',
    'workspace_id': workspace['id'],
    'description': 'Learning to remember things!'
})
print(f"βœ… Bot created: {bot['name']} (ID: {bot['id']})")

# Store some memories
print("\n🧠 Storing memories...")
memories_to_store = [
    "User prefers Python over JavaScript",
    "User loves clean, readable code",
    "User is building an AI application",
    "User's favorite framework is FastAPI"
]

for content in memories_to_store:
    memory = client.memories.create({
        'bot_id': bot['id'],
        'content': content
    })
    print(f"  βœ“ Stored: {content}")

# Search memories
print("\nπŸ” Searching memories...")
results = client.memories.search({
    'bot_id': bot['id'],
    'query': 'programming language preferences',
    'limit': 5
})

print(f"\nπŸ“Š Found {len(results)} relevant memories:")
for i, result in enumerate(results, 1):
    print(f"{i}. {result['content']}")

print("\nπŸŽ‰ Success! Your AI now has permanent memory!")

Step 3: Run It

python first_memory.py

Expected Output

πŸ“ Creating workspace... βœ… Workspace created: Quick Start Project (ID: ws_abc123) πŸ€– Creating bot... βœ… Bot created: Quick Start Bot (ID: bot_xyz789) 🧠 Storing memories... βœ“ Stored: User prefers Python over JavaScript βœ“ Stored: User loves clean, readable code βœ“ Stored: User is building an AI application βœ“ Stored: User's favorite framework is FastAPI πŸ” Searching memories... πŸ“Š Found 2 relevant memories: 1. User prefers Python over JavaScript 2. User's favorite framework is FastAPI πŸŽ‰ Success! Your AI now has permanent memory!

Next Steps

JavaScript Quick Start

Step 1: Install

npm install memofai
# or
pnpm add memofai
# or
yarn add memofai

Step 2: Your First Memory

Create a file called first-memory.js:

import { createMoaClient } from 'memofai';

async function main() {
  // Initialize client
  const client = createMoaClient({
    apiToken: 'moa_your_token_here',  // Replace with your token!
    environment: 'production'
  });

  // Create a workspace
  console.log('πŸ“ Creating workspace...');
  const workspace = await client.workspaces.create({
    name: 'Quick Start Project',
    description: 'My first Memof.ai app!'
  });
  console.log(`βœ… Workspace created: ${workspace.name} (ID: ${workspace.id})`);

  // Create a bot
  console.log('\nπŸ€– Creating bot...');
  const bot = await client.bots.create({
    name: 'Quick Start Bot',
    workspaceId: workspace.id,
    description: 'Learning to remember things!'
  });
  console.log(`βœ… Bot created: ${bot.name} (ID: ${bot.id})`);

  // Store some memories
  console.log('\n🧠 Storing memories...');
  const memoriesToStore = [
    'User prefers TypeScript with strict mode',
    'User loves React and Next.js',
    'User is building a web application',
    'User values type safety'
  ];

  for (const content of memoriesToStore) {
    await client.memories.create({
      botId: bot.id,
      content
    });
    console.log(`  βœ“ Stored: ${content}`);
  }

  // Search memories
  console.log('\nπŸ” Searching memories...');
  const results = await client.memories.search({
    botId: bot.id,
    query: 'technology preferences',
    limit: 5
  });

  console.log(`\nπŸ“Š Found ${results.length} relevant memories:`);
  results.forEach((result, i) => {
    console.log(`${i + 1}. ${result.content}`);
  });

  console.log('\nπŸŽ‰ Success! Your AI now has permanent memory!');
}

main().catch(console.error);

Step 3: Run It

node first-memory.js

Or if using TypeScript:

ts-node first-memory.ts
# or
tsx first-memory.ts

Expected Output

πŸ“ Creating workspace... βœ… Workspace created: Quick Start Project (ID: ws_abc123) πŸ€– Creating bot... βœ… Bot created: Quick Start Bot (ID: bot_xyz789) 🧠 Storing memories... βœ“ Stored: User prefers TypeScript with strict mode βœ“ Stored: User loves React and Next.js βœ“ Stored: User is building a web application βœ“ Stored: User values type safety πŸ” Searching memories... πŸ“Š Found 3 relevant memories: 1. User prefers TypeScript with strict mode 2. User loves React and Next.js 3. User values type safety πŸŽ‰ Success! Your AI now has permanent memory!

Next Steps

HTTP Quick Start

No SDK needed! Just pure HTTP requests.

Step 1: Set Your Token

export MEMOFAI_TOKEN="moa_your_token_here"

Step 2: Create Workspace

curl -X POST https://api.memof.ai/api/workspaces/workspace/create \
  -H "Authorization: Bearer $MEMOFAI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Quick Start Project",
    "description": "My first Memof.ai app!"
  }'

Response:

{
  "id": "ws_abc123",
  "name": "Quick Start Project",
  "description": "My first Memof.ai app!"
}

Step 3: Create Bot

curl -X POST https://api.memof.ai/api/bots/bot/create \
  -H "Authorization: Bearer $MEMOFAI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Quick Start Bot",
    "workspace_id": "ws_abc123",
    "description": "Learning to remember!"
  }'

Response:

{
  "id": "bot_xyz789",
  "name": "Quick Start Bot",
  "workspace_id": "ws_abc123"
}

Step 4: Store Memory

curl -X POST https://api.memof.ai/api/integrations/memory/store \
  -H "Authorization: Bearer $MEMOFAI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "bot_id": "bot_xyz789",
    "content": "User prefers REST APIs and loves cURL"
  }'

Step 5: Search Memories

curl -X POST https://api.memof.ai/api/integrations/memory/search \
  -H "Authorization: Bearer $MEMOFAI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "bot_id": "bot_xyz789",
    "query": "API preferences",
    "limit": 5
  }'

Response:

[
  {
    "id": "mem_123",
    "content": "User prefers REST APIs and loves cURL",
    "bot_id": "bot_xyz789",
    "created_at": "2025-01-15T10:30:00Z"
  }
]

Next Steps

MCP Server Quick Start

Connect Claude Desktop to Memof.ai

Step 1: Install MCP Server

# Clone the repository
git clone https://github.com/memof-ai/memofai-mcp-server.git
cd memofai-mcp-server

# Install dependencies
npm install

# Build
npm run build

Step 2: Configure Claude Desktop

macOS: Edit ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: Edit %APPDATA%\Claude\claude_desktop_config.json

Add this configuration:

{
  "mcpServers": {
    "memofai": {
      "command": "node",
      "args": ["/path/to/memofai-mcp-server/dist/index.js"],
      "env": {
        "MEMOFAI_API_TOKEN": "moa_your_token_here",
        "MEMOFAI_ENVIRONMENT": "production"
      }
    }
  }
}

Step 3: Restart Claude Desktop

Close and reopen Claude Desktop. Look for the πŸ”Œ icon!

Step 4: Test It

Try these commands in Claude:

"Create a workspace called 'My Test Workspace'" "Create a bot named 'Memory Bot' in that workspace" "Remember that I love building with AI" "What do you know about my interests?"

Claude will use the MCP server to store and retrieve memories!

Next Steps

What Just Happened?

Let's break it down πŸ”

  1. Created a Workspace β†’ Your project container
  2. Created a Bot β†’ Your AI agent
  3. Stored Memories β†’ Gave your bot information to remember
  4. Searched Memories β†’ Retrieved relevant information by meaning

The magic? Semantic search found relevant memories even though you didn't use exact keywords!

Common Issues & Solutions

Because things don't always work first try πŸ”§

"Invalid API token"

Problem: Token is wrong or expired
Solution: Get a fresh token from memof.ai

# Make sure it starts with "moa_"
echo $MEMOFAI_TOKEN
# Should output: moa_...

"Module not found"

Problem: Package not installed
Solution: Install the SDK

# Python
pip install memofai

# JavaScript
npm install memofai

"Connection refused"

Problem: Wrong environment URL
Solution: Use 'production' environment

# Python
client = create_moa_client(
    api_token='moa_...',
    environment='production'  # ← Important!
)
// JavaScript
const client = createMoaClient({
  apiToken: 'moa_...',
  environment: 'production'  // ← Important!
});

"Rate limit exceeded"

Problem: Too many requests too fast
Solution: Add delays between requests or implement retry logic

import time

# Add small delay
time.sleep(0.1)  # 100ms between requests

Next Steps

Choose your own adventure πŸ—ΊοΈ

Learn the Concepts

Pick Your SDK

Advanced Topics

Framework Integration

  • βš›οΈ React - React hooks included
  • πŸ”Ί Next.js - Server & client components
  • πŸƒ FastAPI - Python web apps
  • πŸš‚ Express - Node.js servers

Pro Tips

Level up your memory game πŸ’‘

1. Store Meaningful Content

# βœ… Good
"User Sarah from Acme Corp prefers email communication, timezone EST"

# ❌ Bad  
"user email"
# You can search by concept, not exact words!
search(query="customer contact preferences")
# Will find: "Sarah prefers email", "John likes phone calls", etc.

3. Organize by Purpose

# Different bots for different purposes
user_context_bot = create_bot('User Context')
conversation_bot = create_bot('Conversation History')
knowledge_bot = create_bot('Product Knowledge')

4. Don't Over-Store

# βœ… Store important stuff
"User is working on authentication module"

# ❌ Don't store everything
"User pressed button"  # Too granular!

5. Include Context

# βœ… With context
"Customer reported login issue on 2025-01-15, resolved with password reset"

# ❌ Without context
"login issue"  # When? Who? How resolved?

Example: Full Application

A more realistic example

from memofai import create_moa_client
import os

class UserMemoryManager:
    """Manages memories for a user in your app"""
    
    def __init__(self, user_id: str):
        self.client = create_moa_client(
            api_token=os.getenv('MEMOFAI_TOKEN'),
            environment='production'
        )
        self.user_id = user_id
        self.bot_id = self._get_or_create_bot()
    
    def _get_or_create_bot(self):
        """Get or create bot for this user"""
        # In production, you'd cache this!
        bots = self.client.bots.list()
        user_bot = next(
            (b for b in bots if b['name'] == f'user_{self.user_id}'),
            None
        )
        
        if not user_bot:
            workspace = self.client.workspaces.list()[0]
            user_bot = self.client.bots.create({
                'name': f'user_{self.user_id}',
                'workspace_id': workspace['id']
            })
        
        return user_bot['id']
    
    def remember(self, content: str):
        """Store a memory"""
        return self.client.memories.create({
            'bot_id': self.bot_id,
            'content': content
        })
    
    def recall(self, query: str, limit: int = 5):
        """Search memories"""
        return self.client.memories.search({
            'bot_id': self.bot_id,
            'query': query,
            'limit': limit
        })
    
    def get_all_memories(self):
        """Get all memories for this user"""
        return self.client.memories.list({
            'bot_id': self.bot_id
        })

# Usage
manager = UserMemoryManager(user_id='123')

# Store preferences
manager.remember("User prefers dark mode and compact layout")
manager.remember("User is working on API integration project")

# Later, recall context
preferences = manager.recall("UI preferences")
project_context = manager.recall("current project")

print(f"UI Preferences: {preferences[0]['content']}")
print(f"Project: {project_context[0]['content']}")

Congratulations! πŸŽ‰

You've successfully:

  • βœ… Set up Memof.ai
  • βœ… Created a workspace and bot
  • βœ… Stored and retrieved memories
  • βœ… Experienced semantic search

You're now ready to build AI applications with permanent memory!

Need Help?

We're here for you πŸ’¬

  • πŸ“§ Email: support@memof.ai
  • πŸ› Issues: GitHub
  • πŸ“š Docs: You're already here!
  • πŸ’‘ Ideas: We love feature requests!

Ready for more? β†’ Best Practices | SDK Docs