Try it
button to try this API now in our playground. It’s the best way to check the full request and response in one place, customize your parameters, and generate ready-to-use code snippets.Sample Request
Overview
The Retrieve User Memory endpoint performs semantic search through a user’s stored memories to find the most relevant information based on a query. This is the primary endpoint for accessing user memories in your AI applications, enabling context-aware responses and personalized interactions.Functionality
- Semantic Search: Uses advanced vector search to find memories that are semantically similar to your query
- Relevance Ranking: Returns memories ranked by relevance to the search query
- Configurable Results: Control the number of memories returned with the
max_count
parameter - Intelligent Selection: When
max_count
is set to 0, Cortex intelligently selects the best memories based on relevance and context - Context-Aware: Finds memories that are contextually relevant, not just keyword matches
- Personalization: Optional
user_name
parameter enhances personalization by providing user context for more targeted memory retrieval
How Semantic Search Works
Unlike traditional keyword search, semantic search understands the meaning and context of your query. For example:- Query: “authentication preferences”
- Will find memories about: “JWT tokens”, “login methods”, “security settings”, etc.
- Even if the exact words don’t match
Use Cases
- Context Retrieval: Get relevant user context before generating AI responses
- Personalization: Find user preferences and past interactions for tailored experiences
- Memory-Based Chat: Enable AI to reference past conversations and user history
- Recommendation Systems: Use user memories to provide personalized recommendations
- Customer Support: Access user history and preferences for better support
Response
Advanced Usage: Context-Aware AI Response
Different Query Examples
max_count=0
, Cortex will analyze all available memories and return only the most relevant ones based on semantic similarity and contextual relevance, automatically determining the optimal number of memories to return.
Important Notes
- Be specific about the type of information you’re looking for
- Consider using synonyms or related terms if initial queries don’t return results
- Shorter, focused queries often work better than long, complex ones
- Include the
user_name
parameter for enhanced personalization and more targeted memory retrieval
Error Responses
All endpoints return consistent error responses following the standard format. For detailed error information, see our Error Responses documentation.Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Query Parameters
Unique identifier for the tenant/organization
"tenant_1234"
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
"sub_tenant_4567"
Maximum number of memories to return (default: 5)
0 <= x <= 50
5
Body
Response
Successful Response
Response model for retrieving user memories through semantic search.
Indicates whether the memory retrieval operation was successful
true
Array of user memories ranked by relevance to your search query
[
{
"memory_id": "memory_1234",
"memory_content": "I prefer detailed technical explanations and works in the Pacific timezone"
},
{
"memory_id": "memory_4567",
"memory_content": "I prefer dark mode"
}
]