Added improved docs index and overview pages and quickstart (#3603)
This commit is contained in:
+92
-163
@@ -1,14 +1,22 @@
|
||||
---
|
||||
title: Quickstart
|
||||
description: 'Get started with Mem0 Platform in minutes'
|
||||
description: "Get started with Mem0 Platform in minutes"
|
||||
icon: "bolt"
|
||||
iconType: "solid"
|
||||
---
|
||||
|
||||
Get up and running with Mem0 Platform quickly. This guide covers the essential steps to start storing and retrieving memories.
|
||||
Get started with Mem0 Platform's hosted API in under 5 minutes. This guide shows you how to authenticate and store your first memory.
|
||||
|
||||
## 1. Installation
|
||||
## Prerequisites
|
||||
|
||||
- Mem0 Platform account ([Sign up here](https://app.mem0.ai))
|
||||
- API key ([Get one from dashboard](https://app.mem0.ai/settings/api-keys))
|
||||
- Python 3.10+, Node.js 14+, or cURL
|
||||
|
||||
## Installation
|
||||
|
||||
<Steps>
|
||||
<Step title="Install SDK">
|
||||
<CodeGroup>
|
||||
```bash pip
|
||||
pip install mem0ai
|
||||
@@ -17,205 +25,126 @@ pip install mem0ai
|
||||
```bash npm
|
||||
npm install mem0ai
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
</Step>
|
||||
|
||||
## 2. API Key Setup
|
||||
|
||||
1. Sign in to [Mem0 Platform](https://mem0.dev/pd-api)
|
||||
2. Copy your API Key from the dashboard
|
||||
|
||||

|
||||
|
||||
## 3. Initialize Client
|
||||
|
||||
<Step title="Set your API key">
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
import os
|
||||
from mem0 import MemoryClient
|
||||
|
||||
os.environ["MEM0_API_KEY"] = "your-api-key"
|
||||
client = MemoryClient()
|
||||
```
|
||||
client = MemoryClient(api_key="your-api-key")
|
||||
````
|
||||
|
||||
```javascript JavaScript
|
||||
import MemoryClient from 'mem0ai';
|
||||
const client = new MemoryClient({ apiKey: 'your-api-key' });
|
||||
````
|
||||
|
||||
```bash cURL
|
||||
export MEM0_API_KEY="your-api-key"
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
</Step>
|
||||
|
||||
## 4. Basic Operations
|
||||
|
||||
### Add Memories
|
||||
|
||||
Store user preferences and context:
|
||||
|
||||
<Step title="Add a memory">
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
messages = [
|
||||
{"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and allergic to nuts."},
|
||||
{"role": "assistant", "content": "Hello Alex! I'll remember your dietary preferences."}
|
||||
{"role": "user", "content": "I'm a vegetarian and allergic to nuts."},
|
||||
{"role": "assistant", "content": "Got it! I'll remember your dietary preferences."}
|
||||
]
|
||||
|
||||
result = client.add(messages, user_id="alex")
|
||||
print(result)
|
||||
```
|
||||
client.add(messages, user_id="user123")
|
||||
````
|
||||
|
||||
```javascript JavaScript
|
||||
const messages = [
|
||||
{"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and allergic to nuts."},
|
||||
{"role": "assistant", "content": "Hello Alex! I'll remember your dietary preferences."}
|
||||
{"role": "user", "content": "I'm a vegetarian and allergic to nuts."},
|
||||
{"role": "assistant", "content": "Got it! I'll remember your dietary preferences."}
|
||||
];
|
||||
await client.add(messages, { user_id: "user123" });
|
||||
````
|
||||
|
||||
client.add(messages, { user_id: "alex" })
|
||||
.then(result => console.log(result))
|
||||
.catch(error => console.error(error));
|
||||
```bash cURL
|
||||
curl -X POST https://api.mem0.ai/v1/memories/add \
|
||||
-H "Authorization: Bearer $MEM0_API_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"messages": [
|
||||
{"role": "user", "content": "Im a vegetarian and allergic to nuts."},
|
||||
{"role": "assistant", "content": "Got it! Ill remember your dietary preferences."}
|
||||
],
|
||||
"user_id": "user123"
|
||||
}'
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
</Step>
|
||||
|
||||
### Search Memories
|
||||
|
||||
Retrieve relevant memories based on queries:
|
||||
|
||||
<Step title="Search memories">
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
query = "What should I cook for dinner?"
|
||||
results = client.search(query, user_id="alex")
|
||||
results = client.search("What are my dietary restrictions?", filters={"user_id": "user123"})
|
||||
print(results)
|
||||
```
|
||||
````
|
||||
|
||||
```javascript JavaScript
|
||||
const query = "What should I cook for dinner?";
|
||||
client.search(query, { user_id: "alex" })
|
||||
.then(results => console.log(results))
|
||||
.catch(error => console.error(error));
|
||||
const results = await client.search("What are my dietary restrictions?", { filters: { user_id: "user123" } });
|
||||
console.log(results);
|
||||
````
|
||||
|
||||
```bash cURL
|
||||
curl -X POST https://api.mem0.ai/v1/memories/search \
|
||||
-H "Authorization: Bearer $MEM0_API_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"query": "What are my dietary restrictions?",
|
||||
"filters": {"user_id": "user123"}
|
||||
}'
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
### Get All Memories
|
||||
**Output:**
|
||||
|
||||
Fetch all memories for a user:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
memories = client.get_all(user_id="alex")
|
||||
print(memories)
|
||||
```json
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"id": "14e1b28a-2014-40ad-ac42-69c9ef42193d",
|
||||
"memory": "Allergic to nuts",
|
||||
"user_id": "user123",
|
||||
"categories": ["health"],
|
||||
"created_at": "2025-10-22T04:40:22.864647-07:00",
|
||||
"score": 0.30
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
```javascript JavaScript
|
||||
client.getAll({ user_id: "alex" })
|
||||
.then(memories => console.log(memories))
|
||||
.catch(error => console.error(error));
|
||||
```
|
||||
</CodeGroup>
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## 5. Memory Types
|
||||
## What's Next?
|
||||
|
||||
### User Memories
|
||||
Long-term memories that persist across sessions:
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Memory Operations" icon="database" href="/core-concepts/memory-operations/add">
|
||||
Learn how to search, update, and delete memories with complete CRUD operations
|
||||
</Card>
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
client.add(messages, user_id="alex", metadata={"category": "preferences"})
|
||||
```
|
||||
<Card title="Platform Features" icon="star" href="/platform/features/platform-overview">
|
||||
Explore advanced features like metadata filtering, graph memory, and webhooks
|
||||
</Card>
|
||||
|
||||
```javascript JavaScript
|
||||
client.add(messages, { user_id: "alex", metadata: { category: "preferences" } });
|
||||
```
|
||||
</CodeGroup>
|
||||
<Card title="API Reference" icon="code" href="/api-reference/memory/add-memories">
|
||||
See complete API documentation and integration examples
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
### Session Memories
|
||||
Short-term memories for specific conversations:
|
||||
## Additional Resources
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
client.add(messages, user_id="alex", run_id="session-123")
|
||||
```
|
||||
|
||||
```javascript JavaScript
|
||||
client.add(messages, { user_id: "alex", run_id: "session-123" });
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Agent Memories
|
||||
Memories for AI assistants and agents:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
client.add(messages, agent_id="support-bot")
|
||||
```
|
||||
|
||||
```javascript JavaScript
|
||||
client.add(messages, { agent_id: "support-bot" });
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## 6. Advanced Features
|
||||
|
||||
### Async Processing
|
||||
Process memories in the background for faster responses:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
client.add(messages, user_id="alex", async_mode=True)
|
||||
```
|
||||
|
||||
```javascript JavaScript
|
||||
client.add(messages, { user_id: "alex", async_mode: true });
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Search with Filters
|
||||
Filter results by categories and metadata:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
results = client.search(
|
||||
"food preferences",
|
||||
user_id="alex",
|
||||
categories=["preferences"],
|
||||
metadata={"category": "food"}
|
||||
)
|
||||
```
|
||||
|
||||
```javascript JavaScript
|
||||
client.search("food preferences", {
|
||||
user_id: "alex",
|
||||
categories: ["preferences"],
|
||||
metadata: { category: "food" }
|
||||
});
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## TypeScript Example
|
||||
|
||||
<CodeGroup>
|
||||
```typescript TypeScript
|
||||
import MemoryClient, { Message, MemoryOptions } from 'mem0ai';
|
||||
|
||||
const client = new MemoryClient('your-api-key');
|
||||
|
||||
const messages: Message[] = [
|
||||
{ role: "user", content: "I love Italian food" },
|
||||
{ role: "assistant", content: "Noted! I'll remember your preference for Italian cuisine." }
|
||||
];
|
||||
|
||||
const options: MemoryOptions = {
|
||||
user_id: "alex",
|
||||
metadata: { category: "food_preferences" }
|
||||
};
|
||||
|
||||
client.add(messages, options)
|
||||
.then(result => console.log(result))
|
||||
.catch(error => console.error(error));
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Next Steps
|
||||
|
||||
Now that you're up and running, explore more advanced features:
|
||||
|
||||
- **[Advanced Memory Operations](/core-concepts/memory-operations)** - Learn about filtering, updating, and managing memories
|
||||
- **[Platform Features](/platform/features/platform-overview)** - Discover advanced platform capabilities
|
||||
- **[API Reference](/api-reference)** - Complete API documentation
|
||||
|
||||
<Snippet file="get-help.mdx" />
|
||||
- **[Platform vs OSS](/platform/platform-vs-oss)** - Understand the differences between Platform and Open Source
|
||||
- **[Troubleshooting](/platform/faqs)** - Common issues and solutions
|
||||
- **[Integration Examples](/examples/mem0-demo)** - See Mem0 in action
|
||||
|
||||
Reference in New Issue
Block a user