The fastest way to run Engram locally is Docker Compose:
git clone https://github.com/Harshitk-cp/engramcd engramcp .env.example .env# Add your OPENAI_API_KEY (or set EMBEDDING_PROVIDER=mock for testing)docker compose up -d --wait
from engram import Engram# Bootstrap creates a tenant and returns an API key (shown once)client = Engram(base_url="http://localhost:8080", api_key="")result = client.setup("my-org", setup_token="your-setup-token")api_key = result.api_keyprint(f"Save this key: {api_key}")
The ENGRAM_SETUP_TOKEN in your .env file controls who can create tenants. Change it before deploying to production.
from engram import Engramclient = Engram( base_url="http://localhost:8080", api_key="mk_your_api_key_here",)# Create an agent (one per user, bot, or context)agent = client.agents.create( external_id="user-123", name="Alice's Assistant",)# Store memories — confidence is assigned automatically based on evidence typeclient.memories.store( agent_id=agent.id, content="User prefers dark mode in all interfaces", type="preference",)client.memories.store( agent_id=agent.id, content="User is a backend engineer specialising in distributed systems", type="fact",)client.memories.store( agent_id=agent.id, content="User's timezone is UTC+5:30 (Mumbai)", type="fact",)
# Hybrid vector + graph recallresults = client.memories.recall( agent_id=agent.id, query="What are this user's technical preferences?", top_k=5,)for memory in results: print(f"[{memory.confidence:.2f}] {memory.content}")# Output:# [0.92] User prefers dark mode in all interfaces# [0.88] User is a backend engineer specialising in distributed systems
# Store a factclient.memories.store( agent_id=agent.id, content="User's primary language is Python", type="fact",)# Store a contradicting update — Engram detects the tensionclient.memories.store( agent_id=agent.id, content="User recently switched their primary language to Rust", type="fact",)# The original memory is now archived; the new one has full confidenceresults = client.memories.recall( agent_id=agent.id, query="What programming language does the user use?", top_k=3,)
# See the overall health of the agent's knowledgefrom engram import Engramhealth = client.cognitive.health()print(f"Health score: {health.overall_score}")print(f"Contradictions: {health.contradiction_count}")print(f"Stale memories: {health.stale_count}")