Skip to main content

Search Methods

Engram provides four ways to find memories:
MethodUse Case
Key searchFind by memory key substring
Content searchFind by content text
Tag searchFilter by metadata tags
Vector searchSemantic similarity with embeddings
curl -X POST "$API/memory/search" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "facts/",
    "contentQuery": "Rust backend",
    "type": "semantic",
    "tags": ["architecture"],
    "limit": 10
  }'
ParameterDescription
queryMatches against the memory key (case-insensitive substring)
contentQueryMatches against stored contentPreview (first 500 chars of content)
typeFilter by memory type
tagsFilter by metadata tags (matches any)
limitMax results (default 10, max 100)
Encrypted content is not indexed for content search. Only unencrypted text memories have a searchable contentPreview.
Store embeddings with memories, then find semantically similar ones:
# Store with embedding
curl -X POST "$API/memory" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "embedding",
    "key": "facts/blockchain",
    "content": "Blockchain provides decentralized storage",
    "embedding": [0.9, 0.1, 0.2, 0.05, 0.8]
  }'

# Search by similarity
curl -X POST "$API/memory/vector-search" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "embedding": [0.85, 0.15, 0.25, 0.1, 0.75],
    "threshold": 0.5,
    "type": "embedding",
    "limit": 5
  }'
Results include a score field (0.0–1.0) indicating cosine similarity. Uses pgvector native search when available.

Listing with Filters

The list endpoint supports filtering and sorting:
GET /v1/memory?type=semantic&pinned=true&minImportance=0.7&sortBy=importance&limit=20
ParameterDescription
typeFilter by memory type
pinnedtrue / false — filter by pin status
minImportanceMinimum importance score (0.0–1.0)
sortBySort by createdAt, updatedAt, or importance
cursorCursor for pagination (from nextCursor)
limitResults per page (default 50, max 100)