POST /memory/search
Search memories based on a query using semantic similarity. Returns relevant memories with similarity scores. Optionally filter results by memory type.
Request Body
The search query. The API will find memories semantically similar to this query.
Unique identifier for the user whose memories to search.
Maximum number of results to return. Defaults to 10.
Filter results by memory type. Accepts: LONG_TERM, SHORT_TERM, EPISODIC, SEMANTIC, or PROCEDURAL.
Response
Indicates whether the operation was successful.
Array of matching memories sorted by relevance. Show Memory Result Object
Unique identifier for the memory.
The extracted memory content.
Similarity score indicating relevance to the query (higher is better).
Associated metadata including memory_type and custom fields.
The user ID this memory belongs to.
ISO 8601 timestamp of when the memory was created.
ISO 8601 timestamp of when the memory was last updated.
Example Request
curl -X POST http://localhost:8000/memory/search \
-H "Content-Type: application/json" \
-d '{
"query": "What are my UI preferences?",
"user_id": "user_123",
"limit": 5
}'
Example Response
{
"success" : true ,
"results" : [
{
"id" : "mem_abc123" ,
"memory" : "User prefers dark mode in applications" ,
"score" : 0.92 ,
"metadata" : {
"memory_type" : "LONG_TERM"
},
"user_id" : "user_123" ,
"created_at" : "2026-03-01T10:30:00Z" ,
"updated_at" : "2026-03-01T10:30:00Z"
},
{
"id" : "mem_def456" ,
"memory" : "User likes minimal UI designs with high contrast" ,
"score" : 0.87 ,
"metadata" : {
"memory_type" : "LONG_TERM"
},
"user_id" : "user_123" ,
"created_at" : "2026-02-28T14:20:00Z" ,
"updated_at" : "2026-02-28T14:20:00Z"
}
]
}
Filtering by Memory Type
Search only for episodic memories (past events):
curl -X POST http://localhost:8000/memory/search \
-H "Content-Type: application/json" \
-d '{
"query": "conferences I attended",
"user_id": "user_123",
"memory_type": "EPISODIC",
"limit": 10
}'
Search Short-Term Memories
Find what the user is currently working on:
curl -X POST http://localhost:8000/memory/search \
-H "Content-Type: application/json" \
-d '{
"query": "current tasks",
"user_id": "user_123",
"memory_type": "SHORT_TERM"
}'
Error Responses
Error message describing what went wrong.
500 Internal Server Error
{
"detail" : "Failed to execute search query"
}
Implementation Details
Source: backend/main.py:221
Search Method: Semantic similarity using vector embeddings
Index: Supabase HNSW index with cosine distance
Filtering: Supports metadata-based filtering for memory_type and custom fields