Memory Text
intermediateText-specific memory operations: semantic search, summarize, compare, tag, link, timeline, context window, and bulk operations.
Semantic search
/v1/memory/text/searchFull semantic search across all stored text memories. Returns ranked results with highlighted matches.
querystringrequiredNatural language search query.
top_kintegerDefault: 10Maximum results to return (1-100).
metadata_filterobjectFilter by metadata fields.
date_rangeobjectFilter by storage date: {from: "ISO date", to: "ISO date"}.
{
"results": [
{
"id": "mem_abc123",
"text": "Paris is the capital of France",
"score": 0.94,
"highlights": [
"**Paris** is the **capital** of **France**"
],
"stored_at": "2026-01-15T10:30:00Z",
"metadata": {
"category": "geography"
}
}
],
"total_matches": 23,
"search_time_ms": 8
}import os
from engramma_cloud import EngrammaClient
client = EngrammaClient(api_key=os.environ["ENGRAMMA_API_KEY"])
results = client.text.search(
query="European capitals",
top_k=5,
metadata_filter={"category": "geography"}
)
for r in results:
print(f"[{r.score:.2f}] {r.text}")Summarize
/v1/memory/text/summarizeGenerate a summary from a set of memories. Useful for condensing many related memories into a coherent overview.
memory_idsarraySpecific memory IDs to summarize. If omitted, uses query to select memories.
querystringSummarize memories relevant to this query. Required if memory_ids is not provided.
max_lengthintegerDefault: 200Maximum summary length in words.
stylestringDefault: paragraphSummary style: paragraph, bullets, or structured.
{
"summary": "France is a Western European country with Paris as its capital. The country has 67 million inhabitants and is known for its cultural influence, cuisine, and historical landmarks.",
"memories_used": [
"mem_abc123",
"mem_def456",
"mem_ghi789"
],
"coverage": 0.85,
"style": "paragraph"
}summary = client.text.summarize(
query="What do I know about France?",
max_length=100,
style="bullets"
)
print(summary.summary)
print(f"Based on {len(summary.memories_used)} memories")Compare
/v1/memory/text/compareCompare two memories and identify similarities, differences, and potential contradictions.
memory_id_astringrequiredFirst memory ID.
memory_id_bstringrequiredSecond memory ID.
{
"memory_a": "mem_abc123",
"memory_b": "mem_def456",
"similarity": 0.72,
"relationship": "complementary",
"analysis": {
"common_concepts": [
"France",
"geography"
],
"differences": [
"A focuses on capital city",
"B focuses on population"
],
"contradictions": [],
"merge_candidate": false
}
}comparison = client.text.compare(
memory_id_a="mem_abc123",
memory_id_b="mem_def456"
)
print(f"Similarity: {comparison.similarity:.2f}")
print(f"Relationship: {comparison.relationship}")
if comparison.analysis.contradictions:
print(f"Contradictions: {comparison.analysis.contradictions}")Tag
/v1/memory/text/tagAuto-generate semantic tags for a memory based on its content.
memory_idstringrequiredThe memory to tag.
max_tagsintegerDefault: 5Maximum number of tags to generate.
{
"memory_id": "mem_abc123",
"tags": [
"geography",
"capital-cities",
"france",
"europe",
"facts"
],
"confidence_per_tag": {
"geography": 0.95,
"capital-cities": 0.92,
"france": 0.99,
"europe": 0.87,
"facts": 0.71
}
}tags = client.text.tag(memory_id="mem_abc123", max_tags=5)
for tag, conf in tags.confidence_per_tag.items():
print(f" {tag}: {conf:.2f}")Link
/v1/memory/text/linkCreate an explicit causal or semantic link between two memories.
source_idstringrequiredThe source memory ID.
target_idstringrequiredThe target memory ID.
relationshipstringrequiredLink type: causes, supports, contradicts, context, follows, or related.
strengthnumberDefault: 0.5Link strength (0.0 to 1.0). Strong links are more likely to surface during recall.
{
"link_id": "lnk_abc123",
"source_id": "mem_abc123",
"target_id": "mem_def456",
"relationship": "causes",
"strength": 0.8,
"created_at": "2026-01-15T11:00:00Z"
}link = client.text.link(
source_id="mem_abc123",
target_id="mem_def456",
relationship="causes",
strength=0.8
)
print(f"Link created: {link.link_id}")Timeline
/v1/memory/text/timelineGet a chronological timeline of memories, optionally filtered by topic or metadata.
topicstringFilter timeline to memories related to this topic.
fromstringISO 8601 start date.
tostringISO 8601 end date.
limitintegerDefault: 50Maximum entries to return.
{
"timeline": [
{
"id": "mem_001",
"text": "Project kickoff meeting — agreed on microservices architecture",
"stored_at": "2026-01-10T09:00:00Z",
"importance": 0.9
},
{
"id": "mem_002",
"text": "First prototype deployed to staging",
"stored_at": "2026-01-12T16:00:00Z",
"importance": 0.7
}
],
"span": {
"from": "2026-01-10T09:00:00Z",
"to": "2026-01-12T16:00:00Z"
},
"total": 2
}timeline = client.text.timeline(
topic="project milestones",
from_date="2026-01-01",
to_date="2026-01-31"
)
for entry in timeline:
print(f"{entry.stored_at}: {entry.text}")Context window
/v1/memory/text/contextBuild a context window of the most relevant memories for a given prompt. Optimized for feeding into LLMs.
promptstringrequiredThe LLM prompt or user query to build context for.
max_tokensintegerDefault: 2000Maximum tokens for the context window (memories are truncated to fit).
strategystringDefault: relevanceRanking strategy: relevance (by confidence), recency (newest first), or balanced (mix of both).
{
"context": "Paris is the capital of France. France has 67 million inhabitants. The Eiffel Tower was built in 1889 for the World's Fair.",
"memories_used": [
"mem_abc123",
"mem_def456",
"mem_ghi789"
],
"total_tokens": 42,
"strategy": "relevance",
"truncated": false
}context = client.text.context(
prompt="Tell the user about France",
max_tokens=1000,
strategy="balanced"
)
# Inject into your LLM call
llm_prompt = f"Context:\n{context.context}\n\nUser: Tell me about France"Bulk update metadata
/v1/memory/text/bulk-metadataUpdate metadata on multiple memories at once. Useful for re-categorizing or adding tags in bulk.
memory_idsarrayrequiredArray of memory IDs to update (max 100).
metadataobjectrequiredMetadata fields to set or update. Existing fields not mentioned are preserved.
mergebooleanDefault: trueIf true, merges with existing metadata. If false, replaces all metadata.
{
"updated": 15,
"ids": [
"mem_001",
"mem_002",
"..."
],
"errors": []
}result = client.text.bulk_update_metadata(
memory_ids=["mem_001", "mem_002", "mem_003"],
metadata={"project": "v2-migration", "reviewed": True},
merge=True
)
print(f"Updated {result.updated} memories")Bulk delete
/v1/memory/text/bulk-deleteDelete multiple memories in a single request. Irreversible.
memory_idsarrayrequiredArray of memory IDs to delete (max 100).
confirmbooleanrequiredMust be true to proceed. Safety check.
{
"deleted": 5,
"causal_links_removed": 12,
"errors": []
}Bulk delete is irreversible and removes all causal links associated with the deleted memories. Use with caution.
Next steps
- Memory Core — Store, retrieve, recall, explain
- Engine Advanced — Consolidation and diagnostics
- Errors — Error codes and troubleshooting