What You’re Building
An AI that remembers user preferences and past conversations automatically. Without Memory:Prerequisites
- Alchemyst account (sign up)
- Your
ALCHEMYST_AI_API_KEY - Node.js 18+ or Python 3.9+
Choose Your Approach
- TypeScript (Recommended)
- Python
Best for: Next.js, React, Node.js appsUses Vercel AI SDK wrapper for automatic memory management.
Quick Start: TypeScript
Step 1: Set Up Memory
- Retrieves past conversations for this user
- Includes them in the prompt automatically
- Stores the new conversation
Step 2: Use Memory
- Different sessions (profile_setup → cooking_monday)
- Different topics (preferences → recipes)
- Days or weeks apart
Complete TypeScript Example
- Visit platform.getalchemystai.com/context
- You should see stored conversations for user “bob”
- Click to view memory contents
Quick Start: Python
Step 1: Simple Example (Recommended)
Start with this simplified version to understand the basics:Step 2: Full Integration with OpenAI
Now integrate with OpenAI for complete chat functionality:Understanding userId and sessionId
These two parameters control memory scope:Real-World Examples
Pro Tip: Use descriptive sessionIds like
"recipe_planning_2024_02" instead of "session_1" for easier debugging and analytics.userId + same sessionId = same conversation thread
Advanced Features
Stream Responses with Memory
For real-time chat experiences:- TypeScript
- Python
Manage Memory
Update or delete conversations as needed:- TypeScript
- Python
Multi-User Conversations
Handle group chats where multiple users participate in the same thread:- TypeScript
- Python
sessionId across different userId values creates a shared memory space for team conversations.
Configuration Options
Customize memory retrieval and storage behavior:- TypeScript
- Python
Configuration Reference
Recommendation: Start with
similarityThreshold: 0.7. Lower to 0.5 if you get no results, raise to 0.9 if results are too broad.Troubleshooting
Missing userId or sessionId error
Missing userId or sessionId error
Error Message:Cause: Both parameters are required for memory operations.Fix: Always provide both:
Memory not retrieving
Memory not retrieving
Symptoms: AI doesn’t remember past conversations.Causes:2. Verify exact same IDs:3. Test retrieval directly:Expected Output:
- Threshold too high
- Wrong userId/sessionId
- Memory wasn’t stored correctly
Too much irrelevant context
Too much irrelevant context
Symptoms: AI references unrelated past conversations or gets confused.Causes:2. Use separate sessions by topic:3. Limit memory retrieval:
- Threshold too low
- Mixing unrelated conversations in same session
Memory storage failures
Memory storage failures
Error Message:Common Causes:2. Check rate limits:
- Invalid API key
- Rate limit exceeded
- Content too large
- Free tier: 100 operations/day
- Pro tier: Unlimited
Best Practices
1. Session Naming Convention
2. Memory Retention Limits
3. Privacy-Aware Memory
4. Error Handling
Verify Your Setup
After implementing memory, verify it’s working:1. Check Platform UI
- Visit platform.getalchemystai.com/context
- Filter by your userId
- You should see stored memories with timestamps
- Click to view conversation content
2. Test with Code
What’s Next?
Add Context Search
Combine memory with document search for powerful RAG
Vercel AI SDK Guide
Deep dive into AI SDK integration
TypeScript SDK Reference
Complete API reference for TypeScript
Python SDK Reference
Complete API reference for Python
Learn Advanced Patterns
User Profiling
Build rich user profiles from memory
Memory Use Cases
Customer support, personal assistants, chatbots
Memory API Reference
Complete REST API documentation
Sample Projects
Community-built memory applications
Need Help?
Discord Community
Get real-time help from our community
Documentation
Browse guides and API references
Email Support
Contact our support team
GitHub Issues
Report bugs or request features

