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 systemAuthentication
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_iddirectly 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 IDPerformance 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!"
}
}'Advanced: Document Processing (Optional)
Upload documents and let the system intelligently analyze and extract memories with knowledge graphs.
# Process a PDF with automatic analysis
doc_response = client.document.upload(
file=open("product_spec.pdf", "rb"),
hierarchical_enabled=True, # Create hierarchical memory structure
simple_schema_mode=True # Use system schema + one custom schema for consistency
)
# Check processing status
status = client.document.get_status(doc_response.document_status.upload_id)
print(f"Processing: {status.progress * 100}%")
print(f"Current page: {status.current_page}/{status.total_pages}")
# Wait for completion
import time
while status.status_type == "processing":
time.sleep(5)
status = client.document.get_status(doc_response.document_status.upload_id)
print(f"Progress: {status.progress * 100}%")
print("Document processed!")The system analyzes your document, decides what's worth remembering, and creates structured memories with entities and relationships automatically extracted.
Learn more: Document Processing Guide
Advanced: Custom Schemas and GraphQL (Optional)
Define your domain ontology to guide extraction and query insights with GraphQL.
Create a Custom Schema
# Define a custom schema for your domain
schema = client.schemas.create(
name="Product Schema",
description="Schema for product information",
node_types={
"Product": {
"name": "Product",
"label": "Product",
"properties": {
"name": {
"type": "string",
"required": True,
"description": "Product name, typically 2-4 words"
},
"price": {
"type": "float",
"required": True,
"description": "Price in USD as decimal"
},
"category": {
"type": "string",
"required": True,
"enum_values": ["electronics", "software", "hardware"]
}
},
"required_properties": ["name", "price", "category"],
"unique_identifiers": ["name"]
}
}
)
print(f"Schema created: {schema.data.id}")Query with GraphQL
# Query your knowledge graph with GraphQL
response = client.graphql.query(
query="""
query GetProducts {
products {
name
price
category
}
}
"""
)
for product in response.data['products']:
print(f"{product['name']}: ${product['price']} ({product['category']})")Learn more:
Next Steps
Now that you've successfully:
- Created a user
- Added a memory
- Retrieved memories through search
- Provided feedback on search results
- (Optional) Processed documents
- (Optional) Created custom schemas and queried with GraphQL
You're ready to explore more advanced features of the Papr Memory API:
Core Concepts
- Architecture - Complete system architecture and design
- 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
New Feature Guides
- Document Processing - Upload and process PDFs and Word documents
- Custom Schemas - Define domain ontologies for your knowledge graph
- Graph Generation - Control how knowledge graphs are created
- GraphQL Analysis - Query insights with structured GraphQL queries
Core 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