Engine Advanced
advancedSemantic neighbors, explorer, consolidation, diagnostics, configuration, and state management endpoints.
Semantic neighbors
/v1/engine/semantic/neighborsFind semantically similar patterns in the memory space. Returns the neighborhood graph around a memory.
memory_idstringrequiredCenter memory for neighborhood exploration.
radiusintegerDefault: 5Number of neighbor hops to explore (1-10).
min_similaritynumberDefault: 0.3Minimum similarity threshold for neighbors.
{
"center": "mem_abc123",
"neighbors": [
{
"id": "mem_def456",
"text": "France has 67 million inhabitants",
"similarity": 0.82,
"hop": 1,
"link_type": "context"
},
{
"id": "mem_ghi789",
"text": "The EU has 27 member states",
"similarity": 0.61,
"hop": 2,
"link_type": "related"
}
],
"graph_density": 0.34
}import os
from engramma_cloud import EngrammaClient
client = EngrammaClient(api_key=os.environ["ENGRAMMA_API_KEY"])
neighbors = client.engine.semantic_neighbors(
memory_id="mem_abc123",
radius=3,
min_similarity=0.5
)
for n in neighbors:
print(f" hop {n.hop}: [{n.similarity:.2f}] {n.text[:60]}")Semantic score
/v1/engine/semantic/scoreCalculate the semantic similarity score between two texts or memories without storing them.
text_astringFirst text to compare. Use this OR memory_id_a.
text_bstringSecond text to compare. Use this OR memory_id_b.
memory_id_astringFirst memory ID to compare.
memory_id_bstringSecond memory ID to compare.
{
"similarity": 0.87,
"breakdown": {
"cosine": 0.91,
"semantic_overlap": 0.83,
"structural": 0.72
}
}Semantic stats
/v1/engine/semantic/statsGet statistics about the semantic index: cluster count, average density, distribution.
{
"total_vectors": 1247,
"clusters": 23,
"avg_cluster_size": 54,
"avg_density": 0.67,
"orphan_count": 12,
"index_health": 0.91,
"last_reindex": "2026-01-14T03:00:00Z"
}Explorer: Entropy
/v1/engine/explorer/entropyMeasure the entropy (information diversity) of your memory space. High entropy means diverse, well-distributed knowledge.
scopestringDefault: globalEntropy scope: global (entire space), cluster (per cluster), or recent (last 7 days).
{
"global_entropy": 0.78,
"max_possible": 1,
"interpretation": "Well-distributed knowledge with some clusters of concentration",
"clusters": [
{
"name": "geography",
"entropy": 0.45,
"size": 142
},
{
"name": "engineering",
"entropy": 0.82,
"size": 534
}
]
}Explorer: Select
/v1/engine/explorer/selectIntelligently select a subset of memories for exploration. Uses entropy-maximizing selection to show the most diverse cross-section.
countintegerDefault: 10Number of memories to select.
strategystringDefault: diverseSelection strategy: diverse (maximize coverage), boundary (cluster boundaries), anomaly (unusual patterns), or random.
{
"selected": [
{
"id": "mem_abc123",
"text": "Paris is the capital of France",
"cluster": "geography",
"selection_reason": "cluster_representative"
}
],
"coverage": 0.73,
"strategy": "diverse"
}Explorer: Batch
/v1/engine/explorer/batchRun batch exploration across memory space. Returns a structured map of knowledge clusters, connections, and gaps.
depthstringDefault: standardExploration depth: shallow (clusters only), standard (clusters + connections), or deep (full graph analysis).
{
"clusters": [
{
"id": "cluster_001",
"label": "geography",
"size": 142,
"density": 0.78,
"top_memories": [
"mem_abc123",
"mem_def456"
]
}
],
"connections": [
{
"from": "cluster_001",
"to": "cluster_003",
"strength": 0.45,
"bridge_memories": [
"mem_ghi789"
]
}
],
"gaps": [
{
"between": [
"geography",
"history"
],
"suggestion": "Store memories connecting geographic facts to historical events"
}
]
}exploration = client.engine.explorer.batch(depth="deep")
for cluster in exploration.clusters:
print(f"{cluster.label}: {cluster.size} memories (density: {cluster.density:.2f})")
for gap in exploration.gaps:
print(f"Gap between {gap.between}: {gap.suggestion}")Consolidation: Preview
/v1/engine/consolidation/previewPreview what a consolidation cycle would do without actually executing it.
{
"would_merge": 12,
"would_prune": 5,
"would_strengthen": 34,
"would_weaken": 8,
"estimated_time_ms": 2400,
"merge_candidates": [
{
"ids": [
"mem_abc123",
"mem_def456"
],
"similarity": 0.94,
"merged_text_preview": "Paris is the capital of France with 67 million inhabitants"
}
]
}preview = client.engine.consolidation.preview()
print(f"Would merge: {preview.would_merge}")
print(f"Would prune: {preview.would_prune}")
print(f"Would strengthen: {preview.would_strengthen} links")
for candidate in preview.merge_candidates:
print(f" Merge {candidate.ids} → {candidate.merged_text_preview[:60]}")Consolidation: Execute
/v1/engine/consolidation/mergeExecute a consolidation cycle. Merges duplicates, prunes weak memories, strengthens frequent links, and builds new causal connections.
aggressivebooleanDefault: falseIf true, uses lower thresholds for merging and pruning. More cleanup but higher risk of losing nuance.
protect_recent_hoursintegerDefault: 24Don't consolidate memories stored in the last N hours.
{
"merged": 12,
"pruned": 5,
"strengthened": 34,
"weakened": 8,
"new_links": 6,
"duration_ms": 2340,
"before_count": 1247,
"after_count": 1230
}result = client.consolidate(
aggressive=False,
protect_recent_hours=48
)
print(f"Merged: {result.merged}")
print(f"Pruned: {result.pruned}")
print(f"New links: {result.new_links}")
print(f"Before: {result.before_count} → After: {result.after_count}")Consolidation is idempotent — running it multiple times without new data has no effect. It counts as 1 API call regardless of how many patterns it processes.
Consolidation: Protected list
/v1/engine/consolidation/protectedList all memories marked as protected from consolidation.
{
"protected": [
{
"id": "mem_abc123",
"text": "Production database is at db.prod.internal:5432",
"importance": 0.99,
"protected_at": "2026-01-10T10:00:00Z"
}
],
"total": 8
}Consolidation: Sleep stats
/v1/engine/consolidation/sleep-statsView statistics about automatic consolidation cycles (sleep cycles).
{
"total_cycles": 42,
"last_cycle": {
"started_at": "2026-01-20T03:00:00Z",
"duration_ms": 4200,
"merged": 3,
"pruned": 1,
"strengthened": 12
},
"avg_cycle_duration_ms": 3100,
"next_scheduled": "2026-01-21T03:00:00Z",
"frequency": "daily"
}Diagnostics: Prefetch
/v1/engine/diagnostics/prefetchWarm up the retrieval cache for expected queries. Reduces latency for anticipated requests.
queriesarrayrequiredArray of query strings to prefetch (max 20).
{
"prefetched": 5,
"cache_hits": 2,
"cache_misses": 3,
"estimated_speedup_ms": 45
}Diagnostics: Warmup
/v1/engine/diagnostics/warmupWarm up the entire memory engine. Loads indexes and frequently accessed patterns into memory.
{
"status": "warm",
"indexes_loaded": 3,
"patterns_cached": 312,
"duration_ms": 890
}Diagnostics: Invalidate cache
/v1/engine/diagnostics/invalidateInvalidate the retrieval cache. Forces fresh computations on next request.
scopestringDefault: allWhat to invalidate: all, retrieval, semantic, or consolidation.
{
"invalidated": true,
"scope": "all",
"entries_cleared": 1247
}Diagnostics: Structure
/v1/engine/diagnostics/structureInspect the internal structure of the memory engine: index health, tier distribution, link graph stats.
{
"index": {
"type": "hnsw",
"dimensions": 1536,
"total_vectors": 1247,
"fragmentation": 0.03
},
"tiers": {
"hot": {
"count": 312,
"avg_access": 12.4
},
"warm": {
"count": 645,
"avg_access": 3.1
},
"cold": {
"count": 290,
"avg_access": 0.4
}
},
"causal_graph": {
"nodes": 1247,
"edges": 834,
"avg_degree": 1.34,
"max_depth": 7,
"cycles": 0
},
"health": {
"overall": 0.91,
"index_health": 0.95,
"tier_balance": 0.88,
"graph_connectivity": 0.89
}
}structure = client.engine.diagnostics.structure()
print(f"Index: {structure.index.type} ({structure.index.dimensions}d)")
print(f"Vectors: {structure.index.total_vectors}")
print(f"Health: {structure.health.overall:.0%}")
print(f"Graph: {structure.causal_graph.edges} edges, max depth {structure.causal_graph.max_depth}")Configuration
/v1/engine/configRetrieve current engine configuration for your account.
{
"retrieval": {
"default_top_k": 5,
"default_threshold": 0,
"confidence_router_enabled": true,
"pathway_weights": {
"exact": 0.4,
"energy": 0.3,
"attention": 0.3
}
},
"consolidation": {
"auto_enabled": true,
"frequency": "daily",
"aggressive": false,
"protect_recent_hours": 24,
"merge_threshold": 0.85
},
"regime": {
"current": "normal",
"auto_detection": true
}
}/v1/engine/configUpdate engine configuration. Only provided fields are changed.
retrievalobjectRetrieval settings: default_top_k, default_threshold, confidence_router_enabled, pathway_weights.
consolidationobjectConsolidation settings: auto_enabled, frequency, aggressive, protect_recent_hours, merge_threshold.
regimeobjectRegime settings: auto_detection.
{
"updated": true,
"changes": [
"consolidation.frequency",
"consolidation.merge_threshold"
]
}# Adjust consolidation settings
client.engine.update_config(
consolidation={
"frequency": "twice_daily",
"merge_threshold": 0.90
}
)State: Save
/v1/engine/state/saveSave a snapshot of the current engine state. Useful before major changes or experiments.
labelstringOptional label for the snapshot.
{
"snapshot_id": "snap_abc123",
"label": "pre-migration",
"created_at": "2026-01-15T10:00:00Z",
"size_mb": 12.4,
"patterns_count": 1247
}State: Restore
/v1/engine/state/restoreRestore the engine to a previously saved snapshot. All changes since the snapshot are lost.
snapshot_idstringrequiredThe snapshot to restore.
{
"restored": true,
"snapshot_id": "snap_abc123",
"label": "pre-migration",
"patterns_restored": 1247,
"patterns_lost": 53
}Restoring a snapshot is irreversible. All memories stored after the snapshot was taken will be permanently lost.
# Save state before experiment
snapshot = client.engine.state.save(label="pre-experiment")
print(f"Saved: {snapshot.snapshot_id}")
# ... run experiment ...
# Restore if experiment failed
result = client.engine.state.restore(snapshot_id=snapshot.snapshot_id)
print(f"Restored {result.patterns_restored} patterns")Next steps
- Memory Core — Store, retrieve, recall, explain
- Consolidation Guide — Best practices for triggering consolidation
- Errors — Error codes and troubleshooting