Quick Start Guide
Welcome to Papr Memory! This guide will get you up and running with adding memory to your experience in just 15 minutes. Whether you're building an AI assistant, knowledge management system, or any AI app that needs intelligent memory capabilities, you're in the right place.
What You'll Learn
By the end of this guide, you'll know how to:
- Set up Papr Memory in your project
- Add memories to your knowledge base
- Retrieve memories using semantic + graph-based search
Get your API Key
Create a free account then get your API Key from settings.
Installation
# No installation needed for curl
# Just make sure curl is installed on your system
Authentication
Add PAPR_MEMORY_API_KEY to your .env file, then use it to authenticate:
# Set your API key as an environment variable
export PAPR_MEMORY_API_KEY='your_api_key_here'
Creating Users
Before adding memories, create users to associate with your memories. This enables:
- User-specific memory storage and retrieval
- Access control for memories
- Organizing memories by user
- Sharing of memories between users
Note: While creating users explicitly is recommended for better performance and control, you can also use
external_user_id
directly in memory operations without creating users first. Papr will automatically create users for you behind the scenes.
# Create a user
curl -X POST https://memory.papr.ai/v1/user \
-H "X-API-Key: $PAPR_MEMORY_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Client-Type: curl" \
-d '{
"external_id": "user123", # Your application's user identifier
"email": "user@example.com", # Optional
"metadata": {
"name": "John Doe", # Optional
"role": "developer" # Optional
}
}'
User ID Storage Best Practices
You have two options for associating memories with users:
Using external_user_id (Recommended for most cases)
- Use your application's existing user IDs
- No need to store additional IDs
- Automatic user creation behind the scenes
Using Papr-generated user_id (For advanced use cases)
- Pre-create users for better performance
- More control over user metadata and settings
- Requires storing the Papr user ID
# Example: Storing user ID in your database
def save_papr_user_id(app_user_id, papr_user_id):
# Your database code here
db.users.update_one(
{"id": app_user_id}, # Your application's internal user ID
{"$set": {"papr_user_id": papr_user_id}} # The Papr-generated ID (e.g., "usr_abc123")
)
# Example: Retrieving user ID from your database
def get_papr_user_id(app_user_id):
user = db.users.find_one({"id": app_user_id})
return user.get("papr_user_id") # Returns the Papr-generated ID
Performance Optimization with Batch User Creation
For applications with many users, pre-creating users in bulk can improve performance:
# Pre-create users in bulk
bulk_users = client.user.create_batch(
users=[
{"external_id": "user123", "email": "user123@example.com"},
{"external_id": "user456", "email": "user456@example.com"},
{"external_id": "user789", "email": "user789@example.com"}
]
)
Adding Memories
Add a new memory to your knowledge base, using either your external user ID or the Papr-generated user ID:
curl -X POST https://memory.papr.ai/v1/memory \
-H "X-API-Key: $PAPR_MEMORY_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Client-Type: curl" \
-d '{
"content": "Meeting notes from the product planning session",
"type": "text",
"metadata": {
"external_user_id": "user123", // Your application's user identifier
"createdAt": "2024-03-21T10:00:00Z",
"topics": ["meeting", "planning", "product"],
"customMetadata": {
"priority": "high",
"department": "product",
"meeting_type": "planning"
}
}
}'
Searching Memories
Search through memories using natural language and either your external user ID or the Papr-generated user ID:
curl -X POST https://memory.papr.ai/v1/memory/search \
-H "X-API-Key: $PAPR_MEMORY_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept-Encoding: gzip" \
-H "X-Client-Type: curl" \
-d '{
"query": "What are the key points from our recent product planning?",
"external_user_id": "user123", // Your application's user identifier
"enable_agentic_graph": true, // Enable intelligent entity-aware search
"max_memories": 20,
"max_nodes": 15,
"metadata": {
"topics": ["planning", "product"],
"customMetadata": {
"priority": "high",
"department": "product"
}
}
}'
User-Specific vs. Global Search
You can choose whether to search memories for a specific user or across all accessible memories:
# Search only for a specific user's memories (using external_user_id)
user_specific_results = client.memory.search(
query="product planning",
external_user_id="user123", # Your application's user identifier
enable_agentic_graph=True # Enable intelligent entity-aware search
)
# Search across all accessible memories
global_results = client.memory.search(
query="product planning",
enable_agentic_graph=True # Enable intelligent entity-aware search
# No user filter means search all accessible memories
)
Getting a Specific Memory
Retrieve a specific memory by its ID to verify it was added correctly:
curl -X GET https://memory.papr.ai/v1/memory/mem_abc123 \
-H "X-API-Key: $PAPR_MEMORY_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Client-Type: curl"
Providing Search Feedback
After retrieving search results, you can provide feedback to improve future search quality:
curl -X POST https://memory.papr.ai/v1/feedback \
-H "X-API-Key: $PAPR_MEMORY_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Client-Type: curl" \
-d '{
"search_id": "search_def456",
"feedbackData": {
"feedbackType": "thumbs_up",
"feedbackSource": "inline",
"feedbackText": "These results were helpful!"
}
}'
Next Steps
Now that you've successfully:
- Created a user
- Added a memory
- Retrieved memories through search
- Provided feedback on search results
You're ready to explore more advanced features of the Papr Memory API:
Core Concepts
- Memory Model - Understand how memories are structured and organized
- Vector and Graph Search - Learn about our hybrid search approach
- Context and Relationships - How memories relate to each other
- ACL and Tenancy - Access control and multi-tenant architecture
Guides
- Memory Management - Learn how to update, delete, and organize memories
- Context Handling - Add rich context to improve memory relevance
- Search Tuning - Optimize search results for your use case
- Batch Operations - Efficiently manage large volumes of memories
- Content Ingestion - Best practices for adding different types of content
- Retrieval Strategies - Advanced techniques for finding the right memories
SDKs and Tools
- Python SDK - Complete Python SDK documentation and examples
- TypeScript SDK - Complete TypeScript/JavaScript SDK documentation and examples
- MCP Integration - Model Context Protocol integration guide
- LLM Tool Schema - Schema for LLM tool integration
API Reference
- Full API Reference - Complete REST API documentation