Version: 2.0.0 | Base URL:
http://localhost:8100| Phase: Beta
- Authentication
- Rate Limiting
- Error Handling
- Security Headers
- Health & Stats
- Memory Operations
- Episodic Memory
- Working Memory
- Dream Loop
- Export
- Procedural Memory
- Predictions
- Concepts & Analogy
- Meta Memory & Self-Improvement
- Maintenance
- Subtle Thoughts
- Recursive Synthesis (RLM)
- Trust & Provenance
- Proactive Recall
- Contradictions
- Emotional Tags
- Knowledge Gaps
- Association Network
- Prometheus Metrics
All endpoints except Health & Stats require an API key via the X-API-Key header.
curl -H "X-API-Key: YOUR_KEY" http://localhost:8100/store ...Set the key via environment variable:
export HAIM_API_KEY="your-secret-key"If no key is configured, authentication is disabled (development mode only — not recommended for production).
Rate limits are applied per-client based on endpoint category:
| Category | Requests / Minute |
|---|---|
| Store | 100 |
| Query | 500 |
| Dream | 5 |
| Concept | 100 |
Exceeding the limit returns 429 Too Many Requests. Inspect current limits via GET /rate-limits.
All error responses follow a consistent structure:
{
"ok": false,
"error": "Human-readable error description",
"detail": "Optional technical detail"
}| Status Code | Meaning |
|---|---|
400 |
Invalid request (validation) |
401 |
Missing or invalid API key |
404 |
Resource not found |
429 |
Rate limit exceeded |
500 |
Internal server error |
Every response includes hardened security headers:
| Header | Value |
|---|---|
X-Content-Type-Options |
nosniff |
X-Frame-Options |
DENY |
X-XSS-Protection |
1; mode=block |
Content-Security-Policy |
default-src 'self' |
Referrer-Policy |
strict-origin-when-cross-origin |
Strict-Transport-Security |
max-age=31536000; includeSubDomains |
X-Trace-ID |
Unique trace identifier per request |
These endpoints do not require authentication.
Returns basic service information.
{
"status": "ok",
"service": "MnemoCore",
"version": "2.0.0",
"phase": "Phase 6",
"timestamp": "2026-02-28T12:00:00Z"
}Returns system health including backend connectivity.
{
"status": "healthy",
"redis_connected": true,
"storage_circuit_breaker": "closed",
"qdrant_circuit_breaker": "closed",
"engine_ready": true,
"timestamp": "2026-02-28T12:00:00Z"
}Status values: healthy, degraded.
Returns engine aggregate statistics (memory counts per tier, LTP distributions, etc.).
Returns the current rate limit configuration.
{
"limits": {
"Store": { "requests": 100, "window_seconds": 60, "requests_per_minute": 100 },
"Query": { "requests": 500, "window_seconds": 60, "requests_per_minute": 500 },
"Dream": { "requests": 5, "window_seconds": 60, "requests_per_minute": 5 }
}
}Store a new memory.
Request Body (StoreRequest):
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
content |
string |
Yes | max 100,000 chars | Memory text content |
metadata |
object |
No | max 50 keys | Arbitrary key-value metadata |
agent_id |
string |
No | max 256 chars | Agent identifier for multi-agent use |
ttl |
int |
No | 1–31,536,000 seconds | Time-to-live (auto-expires) |
Response (StoreResponse):
{
"ok": true,
"memory_id": "mem_abc123",
"message": "Memory stored successfully"
}Example:
curl -X POST http://localhost:8100/store \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_KEY" \
-d '{
"content": "Birds can migrate thousands of miles using magnetic fields",
"metadata": {"topic": "biology", "source": "textbook"},
"agent_id": "agent-01"
}'Semantic search across all memory tiers.
Request Body (QueryRequest):
| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
query |
string |
Yes | — | max 10,000 | Natural language query |
top_k |
int |
No | 5 | 1–100 | Number of results |
agent_id |
string |
No | — | max 256 | Filter by agent |
Response (QueryResponse):
{
"ok": true,
"query": "animal migration",
"results": [
{
"id": "mem_abc123",
"content": "Birds can migrate thousands of miles...",
"score": 0.87,
"metadata": {"topic": "biology"},
"tier": "hot"
}
]
}Example:
curl -X POST http://localhost:8100/query \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_KEY" \
-d '{"query": "animal migration patterns", "top_k": 3}'Retrieve a specific memory by ID.
Response:
{
"source": "hot",
"id": "mem_abc123",
"content": "Birds can migrate thousands of miles...",
"metadata": {"topic": "biology"},
"created_at": "2026-02-28T12:00:00Z",
"epistemic_value": 0.75,
"ltp_strength": 0.85,
"tier": "hot"
}Delete a memory by ID.
Response: {"ok": true, "deleted": true}
Start a new episodic memory chain for an agent.
Request Body (EpisodeStartRequest):
| Field | Type | Required | Description |
|---|---|---|---|
agent_id |
string |
Yes | Agent identifier |
goal |
string |
Yes | Episode goal/objective |
context |
string |
No | Additional context |
Response: {"ok": true, "episode_id": "ep_xyz789"}
Add an observation to an agent's working memory.
Request Body (ObserveRequest):
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
agent_id |
string |
Yes | — | Agent identifier |
content |
string |
Yes | — | Observation content |
kind |
string |
No | "observation" |
Observation type |
importance |
float |
No | 0.5 |
Importance weight (0–1) |
tags |
string[] |
No | [] |
Tags for categorization |
Response: {"ok": true, "item_id": "wm_item_001"}
Get the current working memory context for an agent.
Query Parameters: limit (int, default 16)
Response:
{
"ok": true,
"items": [
{"id": "wm_item_001", "content": "User asked about...", "kind": "observation", "importance": 0.8}
]
}Trigger a consolidation dream cycle. Dreams cluster, extract patterns, resolve contradictions, and promote important memories.
Request Body (DreamRequest):
| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
max_cycles |
int |
No | 1 | 1–10 | Number of dream cycles |
force_insight |
bool |
No | false |
— | Force insight generation |
Response (DreamResponse):
{
"ok": true,
"cycles_completed": 1,
"insights_generated": 3,
"concepts_extracted": 2,
"parallels_found": 1,
"memories_processed": 47,
"message": "Dream cycle completed"
}Export memories in JSON or JSONL format.
Query Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id |
string |
— | Filter by agent |
tier |
string |
— | Filter: hot, warm, cold, soul |
limit |
int |
100 | Max memories to export |
include_metadata |
bool |
true |
Include metadata in output |
format |
string |
"json" |
Output format: json or jsonl |
Response (ExportResponse):
{
"ok": true,
"count": 42,
"format": "json",
"memories": [
{
"id": "mem_abc123",
"content": "...",
"created_at": "2026-02-28T12:00:00Z",
"ltp_strength": 0.85,
"tier": "hot",
"metadata": {}
}
]
}Search the procedural skill library.
| Parameter | Type | Default | Description |
|---|---|---|---|
query |
string |
— | Search query (req) |
agent_id |
string |
— | Filter by agent |
top_k |
int |
5 | Number of results |
Response: {"ok": true, "procedures": [...]}
Report success/failure for a procedure execution.
Request Body: {"success": true}
Response: {"ok": true, "procedure_id": "proc_001", "success_recorded": true}
Create a new prediction (anticipatory memory).
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
content |
string |
Yes | — | Prediction text |
confidence |
float |
No | 0.5 |
Confidence level (0–1) |
deadline_days |
float |
No | — | Days until verification |
related_memory_ids |
string[] |
No | [] |
Related memory IDs |
tags |
string[] |
No | [] |
Classification tags |
Response: {"ok": true, "prediction": {...}}
List predictions. Optional filter: ?status=pending
Verify a prediction outcome.
Request Body: {"success": true, "notes": "Prediction was accurate"}
Define a conceptual symbol for analogy and reasoning operations.
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
name |
string |
Yes | max 256 | Concept name |
attributes |
dict[str, str] |
Yes | 1–50 keys | Attribute definitions |
Example:
curl -X POST http://localhost:8100/concept \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_KEY" \
-d '{"name": "bird", "attributes": {"can_fly": "true", "has_feathers": "true"}}'Solve an analogy: "A is to X as B is to ?"
| Field | Type | Required | Description |
|---|---|---|---|
source_concept |
string |
Yes | Source concept name |
source_value |
string |
Yes | Source attribute value |
target_concept |
string |
Yes | Target concept name |
Response: {"ok": true, "analogy": "...", "results": [{"value": "...", "score": 0.92}]}
List self-improvement proposals generated by the MetaMemory module.
Query Parameters: status (optional: "pending", "accepted", "rejected")
Response:
{
"ok": true,
"count": 3,
"proposals": [
{
"proposal_id": "prop_001",
"type": "consolidation",
"description": "Merge 5 similar memories about Python syntax",
"status": "pending",
"created_at": "2026-02-28T10:00:00Z"
}
]
}Update proposal status. Valid values: accepted, rejected, implemented.
Request Body: {"status": "accepted"}
Remove low-quality memories below a threshold.
Query Parameters: threshold (float, default 0.1)
Trigger a consolidation cycle across all tiers.
Run a full sweep of expired/stale memories.
All maintenance endpoints return {"ok": true, "stats": {...}}.
Retrieve associative "subtle thoughts" — background associations triggered by recent agent activity.
Query Parameters: limit (int, default 5)
Response: {"ok": true, "associations": [...]}
Execute a recursive language model query that decomposes complex questions into sub-queries, retrieves relevant memories for each, and synthesizes a unified answer.
Request Body (RLMQueryRequest):
| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
query |
string |
Yes | — | 1–4096 chars | The complex query |
context_text |
string |
No | — | max 500k | Additional context document |
project_id |
string |
No | — | max 128 | Project scope filter |
max_depth |
int |
No | 2 | 0–5 | Max recursive depth |
max_sub_queries |
int |
No | 3 | 1–10 | Sub-queries per level |
top_k |
int |
No | 5 | 1–50 | Results per sub-query |
Response (RLMQueryResponse):
{
"ok": true,
"query": "How does memory consolidation relate to learning?",
"sub_queries": ["What is memory consolidation?", "What mechanisms underlie learning?"],
"results": [...],
"synthesis": "Memory consolidation and learning are deeply interconnected...",
"max_depth_hit": 2,
"elapsed_ms": 342.5,
"ripple_snippets": ["Related: sleep plays a role in consolidation..."],
"stats": {"total_queries": 7, "cache_hits": 2}
}Get the provenance chain for a memory.
{
"ok": true,
"memory_id": "mem_abc123",
"provenance": {
"origin": "user_input",
"created_at": "2026-02-28T12:00:00Z",
"transformations": ["encoded", "consolidated"],
"parent_ids": []
}
}Get the Bayesian confidence envelope for a memory.
{
"ok": true,
"memory_id": "mem_abc123",
"confidence": {
"overall": 0.85,
"source_reliability": 0.9,
"temporal_decay": 0.88,
"contradiction_free": true
}
}Get proactively recommended memories based on context and patterns.
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id |
string |
— | Filter by agent |
limit |
int |
10 | Max results |
Response:
{
"ok": true,
"proactive_results": [
{"id": "mem_abc123", "content": "...", "ltp_strength": 0.9, "confidence": 0.85, "tier": "hot"}
],
"count": 3
}List detected contradictions. Query: ?unresolved_only=true (default).
{
"ok": true,
"count": 2,
"contradictions": [
{
"group_id": "cg_001",
"memory_a_id": "mem_abc123",
"memory_b_id": "mem_def456",
"similarity_score": 0.72,
"resolved": false
}
]
}Request Body: {"note": "Memory A is more recent and accurate"}
Response: {"ok": true, "resolved_group_id": "cg_001"}
Get the emotional profile of a memory.
{
"ok": true,
"memory_id": "mem_abc123",
"emotional_tag": {"valence": 0.6, "arousal": 0.3, "salience": 0.7}
}Update emotional valence and arousal.
Request Body: {"valence": 0.8, "arousal": 0.4}
List detected knowledge gaps.
{
"ok": true,
"gaps": [
{"gap_id": "gap_001", "query": "quantum entanglement", "type": "missing_info", "severity": 0.7}
],
"count": 1
}Phase 6.0 graph-based memory associations.
Get memories associated with a given node.
| Parameter | Type | Default | Description |
|---|---|---|---|
max_results |
int |
10 | Max associations |
min_strength |
float |
0.1 | Minimum edge strength |
include_content |
bool |
true |
Include memory content |
{
"ok": true,
"node_id": "mem_abc123",
"associations": [
{
"id": "mem_def456",
"content": "Related memory...",
"strength": 0.82,
"association_type": "semantic",
"fire_count": 5,
"metadata": {}
}
]
}Find paths between two memories in the association graph.
| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
from_id |
string |
Yes | — | — | Source memory ID |
to_id |
string |
Yes | — | — | Target memory ID |
max_hops |
int |
No | 3 | 1–10 | Max path length |
min_strength |
float |
No | 0.1 | 0–1 | Min edge strength |
Get clusters containing a specific node. Query: ?min_cluster_size=3
Get graph-level topology metrics.
{
"ok": true,
"metrics": {
"node_count": 1234,
"edge_count": 5678,
"avg_degree": 9.2,
"density": 0.015,
"avg_clustering": 0.42,
"connected_components": 3,
"largest_component_size": 1200
}
}Manually reinforce an association between two memories.
Request Body: {"node_a": "mem_abc123", "node_b": "mem_def456", "association_type": "co_occurrence"}
Interactive HTML visualization of the association graph.
| Parameter | Type | Default | Description |
|---|---|---|---|
max_nodes |
int |
100 | Max nodes |
min_strength |
float |
0.1 | Min edge strength |
layout |
string |
"spring" |
Graph layout |
Returns text/html content type.
Available at GET /metrics (no authentication required).
| Metric | Type | Description |
|---|---|---|
haim_store_total |
Counter | Total store operations |
haim_query_total |
Counter | Total query operations |
haim_store_latency_seconds |
Histogram | Store latency |
haim_query_latency_seconds |
Histogram | Query latency |
haim_tier_count |
Gauge | Memory count per tier |
haim_dream_cycles_total |
Counter | Dream cycles completed |
haim_consolidation_total |
Counter | Consolidation events |
This document covers all 41 API endpoints as of v2.0.0. For deployment, see DEPLOYMENT.md. For configuration, see CONFIGURATION.md.