Add Memory to Your LLM with Alchemyst AI
This guide shows you how to add memory to your LLM applications using Alchemyst AI with Vercelâs AI SDK - step by step.What youâll build
By the end of this guide, you will:- Wrap Vercel AI SDK functions with Alchemyst memory
- Store conversation context automatically
- Retrieve relevant memory across sessions
- Build context-aware AI applications
Prerequisites
Youâll need:- An Alchemyst AI account - sign up
- Your
ALCHEMYST_AI_API_KEY - Node.js 18+
Note that this tutorial is typescript-only. This is because AI SDK is only officially available for JS/TS.
Step 1: Install the SDKs
Step 2: Initialize Alchemyst with AI SDK
- AI SDK v5
- AI SDK v6
Step 3: Generate text with automatic memory storage
The memory integration automatically stores conversation history in Alchemystâs context layer.- AI SDK v5
- AI SDK v6
What just happened?
- The conversation was automatically stored in Alchemystâs memory layer
- Future queries from the same
userIdandconversationIdwill have access to this context - Memory retrieval happens automatically on subsequent calls
Step 4: Continue conversations with context
Subsequent messages in the same conversation automatically retrieve relevant context.- AI SDK v5
- AI SDK v6
Step 5: Stream responses with memory
For streaming responses, usestreamText instead of generateText.
Step 6: Update or delete memories
Manage conversation memory as needed.User Profiling for AI Consumer Applications
Alchemystâs memory layer enables sophisticated user profiling that enhances personalization in AI consumer applications. By automatically tracking and retrieving user interactions, preferences, and behavioral patterns, you can build AI experiences that truly understand and adapt to each user.How Memory Powers User Profiling
Alchemyst automatically builds rich user profiles through conversation history, enabling your AI to: Understand User Preferences: Track topics of interest, communication style, preferred level of detail, and recurring questions to tailor responses. Maintain Context Across Sessions: Users can pick up conversations days or weeks later without repeating themselves, creating a seamless experience. Personalize Recommendations: Leverage past interactions to suggest relevant content, features, or actions that align with user interests. Adapt Communication Style: Learn whether users prefer technical explanations, casual tone, brief answers, or detailed responses. Track User Journey: Understand feature adoption, pain points, and engagement patterns to improve product experience.Building User Profiles with Memory
Store user-specific information that persists across conversations:- AI SDK v5
- AI SDK v6
Real-World User Profiling Examples
Fitness Apps: Track workout preferences, fitness goals, injury history, and preferred exercise types to generate personalized workout plans. Learning Platforms: Remember completed lessons, difficulty level, learning pace, and topics of interest to customize curriculum and pacing. Shopping Assistants: Store style preferences, size information, budget ranges, and past purchases to provide relevant product recommendations. Health & Wellness: Maintain dietary restrictions, health goals, medication schedules, and symptom tracking for personalized health guidance. Content Platforms: Learn content preferences, reading habits, favorite topics, and engagement patterns to curate personalized feeds.Retrieving User Profile Data
Query stored user information to build comprehensive profiles:Privacy-First Profiling
Alchemystâs user profiling respects privacy by design:- User-scoped data: Each userIdâs data is isolated and secure
- Granular deletion: Remove specific memories or entire user profiles
- Transparent storage: Users can see what information is stored
- Compliance-ready: Built for GDPR, CCPA, and privacy regulations
Best Practices for User Profiling
Start Simple: Begin with basic preferences and gradually build richer profiles as users engage more. Be Transparent: Inform users about what data is being stored and how it improves their experience. Provide Control: Give users the ability to view, edit, or delete their profile data. Balance Personalization: Avoid making users feel âwatchedâ - use profiling to be helpful, not intrusive. Regular Updates: User preferences change over time - weight recent interactions more heavily. Segment Thoughtfully: Use metadata to categorize different types of profile information (preferences, history, goals).Advanced: Multi-user conversations
Handle group conversations where multiple users participate.- AI SDK v5
- AI SDK v6
What Alchemyst does automatically
- Stores conversation history by user and conversation
- Retrieves relevant context across sessions
- Maintains conversation flow and coherence
- Handles memory cleanup and optimization
You donât need
- Custom memory stores
- Manual context window management
- Session state handling
- Memory deduplication logic
Configuration Options
Customize how Alchemyst handles memory:Troubleshooting and Errors
Error: Missing userId or conversationId- Both
userIdandconversationIdare required for memory operations - Solution: Always provide both parameters when calling wrapped functions
- Check that
similarityThresholdisnât set too high - Verify the same
userIdandconversationIdare used - Use
client.v1.context.memory.search()to test retrieval directly
- Lower the
similarityThresholdfor more precise results - Implement pagination for long conversations
- Consider splitting into multiple conversation IDs
Next Steps: Go Deeper with Memory
Get up and running with dedicated SDKs and advanced memory features.AI SDK Integration
Full AI SDK guide
TypeScript SDK
TypeScript SDK docs
API Documentation
Memory API reference
Example Projects
View sample projects
Memory Use Cases
Real-world applications powered by Alchemyst memory:Customer Support
Persistent conversation history across sessions
Personal Assistants
Remember user preferences and past interactions
Collaborative Tools
Multi-user conversations with shared context
Educational Apps
Track learning progress and adapt to student needs
Need Help?
If you get stuck or want to share feedback:- Browse the Guides and API docs on this site.
- Search the documentation for targeted answers.
- Join our Discord server for real-time help.

