Skip to content

Memory API

Base path: /api/memory

All endpoints require authentication. See API Overview for auth details.

MethodPathDescription
GET/api/memory/episodesList episodes
GET/api/memory/episodes/{id}Get an episode
POST/api/memory/episodesCreate an episode (inject memory)
DELETE/api/memory/episodes/{id}Delete a single episode
GET/api/memory/episodes/{id}/relatedGet related episodes
GET/api/memory/searchFull-text and semantic search
GET/api/memory/clustersGet memory clusters
GET/api/memory/graphGet the knowledge graph
GET/api/memory/statsGet memory statistics
POST/api/memory/consolidate/conversationsConsolidate memory from conversations
POST/api/memory/generate-episodesGenerate episodes from conversations
POST/api/memory/backfill-entitiesBackfill entity data for episodes
GET/api/settings/memoryGet memory settings
PUT/api/settings/memoryUpdate memory settings
GET/api/settings/memory/exportExport memory data as JSON
DELETE/api/settings/memory/dataClear all memory data
GET /api/memory/episodes

Query parameters:

ParameterDescription
limitMax results (default: 20, max: 100)
offsetPagination offset (default: 0)
cluster_idFilter by cluster ID
agent_idFilter by agent ID

Response:

{
"episodes": [
{
"id": "ep_abc123",
"content": "User asked about FastAPI dependency injection...",
"summary": null,
"source": "conversation",
"valence": 0.24,
"importance": 0.6,
"access_count": 3,
"created_at": "2026-03-02T14:00:00Z",
"updated_at": "2026-03-02T14:00:00Z"
}
],
"total": 1247,
"limit": 20,
"offset": 0
}
GET /api/memory/episodes/{id}
POST /api/memory/episodes
{
"content": "Note: always use the snippbot_ prefix for database tables",
"importance": 0.7,
"valence": 0.0,
"topics": ["conventions"],
"agent_id": "agent_abc123"
}

Only content is required. All other fields are optional.

Use this to inject persistent instructions or context into an agent’s memory.

DELETE /api/memory/episodes/{id}

Deletes a single episode by ID.

GET /api/memory/episodes/{id}/related

Returns episodes related to the given episode.

GET /api/memory/search?q=database+migration+strategy&mode=hybrid&limit=10

Searches across all episodes using the selected mode. Pass natural language queries to find conceptually related memories.

Query parameters:

ParameterDescription
qSearch query string (required)
modeSearch mode: hybrid (default), keyword, or semantic
limitMax results (default: 10, max: 100)
offsetPagination offset (default: 0)
start_dateISO 8601 date filter (since)
end_dateISO 8601 date filter (until)
sourceFilter by episode source (e.g., conversation, task, insight)

Response:

{
"query": "database migration strategy",
"mode": "hybrid",
"limit": 10,
"offset": 0,
"results": [
{
"episode": {
"id": "ep_abc123",
"content": "User asked about database migration strategy...",
"summary": null,
"valence": 0.0,
"importance": 0.6,
"topics": [],
"entities": [
{ "id": "ent_xyz", "name": "Sql", "type": "concept", "mentions": 2 }
],
"source": "conversation",
"created_at": "2026-03-01T10:00:00Z"
},
"score": 0.92,
"source": "conversation",
"highlights": ["...we decided on a **database migration strategy** that..."]
}
],
"total": 3
}
GET /api/memory/clusters

Returns memory clusters — groups of related episodes identified by the memory system.

Query parameters:

ParameterDescription
nNumber of clusters to compute (default: 4, range: 2-8)
agent_idFilter clusters for a specific agent
GET /api/memory/graph

Returns the full knowledge graph (entities and relationships).

POST /api/memory/consolidate/conversations

Triggers memory consolidation from conversation history.

POST /api/memory/generate-episodes

Generates episodic memory entries from existing conversation data.

POST /api/memory/backfill-entities

Backfills entity extraction for episodes that were created before entity extraction was enabled.

Memory settings are managed under the Settings API, not under /api/memory:

GET /api/settings/memory
PUT /api/settings/memory
GET /api/settings/memory/export

Returns a JSON file containing all episodes and metadata as a download.

DELETE /api/settings/memory/data

Deletes all episodes, the vector index, and the knowledge graph. This action is irreversible.

Response:

{
"cleared": 4821
}
GET /api/memory/stats
{
"total_episodes": 4821,
"total_entities": 142,
"total_relations": 389,
"avg_importance": 0.54,
"avg_valence": 0.12,
"importance_distribution": [12, 45, 89, 210, 380, 920, 1100, 800, 180, 85],
"source_distribution": { "conversation": 4200, "task": 400, "insight": 221 },
"entity_type_distribution": { "language": 12, "framework": 18, "tool": 30, "concept": 82 },
"recall_feedback": { "total_recalls": 320, "used_count": 210, "ignored_count": 110, "usage_rate": 0.66 }
}