Skip to main content

Human-like memory for AI — semantic, episodic & procedural. Experience-driven procedures, Cognitive Profile, unified search, memory agents. Free open-source Mem0 alternative.

Project description

Mengram

The memory layer for AI agents that learns from experience

Your agents remember facts, events, and workflows — and procedures improve automatically when they fail.

PyPI npm License: Apache 2.0 PyPI Downloads

Website · Get API Key · API Docs · Examples


Why Mengram?

Every AI memory tool stores facts. Mengram stores 3 types — and procedures evolve from failures.

Mengram Mem0 Letta Zep
Semantic Memory (facts)
Episodic Memory (events) Partial
Procedural Memory (workflows)
Experience-Driven Evolution
Cognitive Profile
Multi-User Isolation
Knowledge Graph
LangChain / CrewAI / OpenClaw Partial
Import (ChatGPT, Obsidian)
MCP Server
Price Free $19–249/mo Free (self-host) Enterprise

Quick Start

pip install mengram-ai
from cloud.client import CloudMemory

m = CloudMemory(api_key="om-...")  # Free key → mengram.io/dashboard

# Add a conversation — Mengram auto-extracts facts, events, and workflows
m.add([
    {"role": "user", "content": "Deployed to Railway today. Build passed but forgot migrations — DB crashed. Fixed by adding a pre-deploy check."},
])

# Search facts
m.search("deployment setup")

# Search events — what happened?
m.episodes(query="deployment")
# → [{summary: "Deployed to Railway, DB crashed due to missing migrations", outcome: "resolved", ...}]

# Search workflows — how to do it?
m.procedures(query="deploy")
# → [{name: "Deploy to Railway", steps: ["build", "run migrations", "push", "verify"], ...}]

# Unified search — all 3 types at once
m.search_all("deployment issues")
# → {semantic: [...], episodic: [...], procedural: [...]}

JavaScript / TypeScript:

npm install mengram-ai
const { MengramClient } = require('mengram-ai');
const m = new MengramClient('om-...');

await m.add([{ role: 'user', content: 'Fixed OOM with Redis cache' }]);
const all = await m.searchAll('database issues');
// → { semantic: [...], episodic: [...], procedural: [...] }

Experience-Driven Procedures

The feature no one else has. Procedures learn from real outcomes — not static runbooks.

Week 1:  "Deploy" → build → push → deploy
                                         ↓ FAILURE: forgot migrations, DB crashed
Week 2:  "Deploy" v2 → build → run migrations → push → deploy
                                                          ↓ FAILURE: OOM on Railway
Week 3:  "Deploy" v3 → build → run migrations → check memory → push → deploy ✅

This happens automatically when you report failures:

# Report failure with context → procedure evolves to a new version
m.procedure_feedback(proc_id, success=False,
                     context="OOM error on step 3", failed_at_step=3)

# View version history
history = m.procedure_history(proc_id)
# → {versions: [v1, v2, v3], evolution_log: [{change: "step_added", reason: "prevent OOM"}]}

Or fully automatic — add conversations and Mengram detects failures, links them to procedures, and evolves:

m.add([{"role": "user", "content": "Deploy to Railway failed again — OOM on the build step"}])
# → Episode auto-linked to "Deploy" procedure → failure detected → v3 created

Cognitive Profile

One API call generates a system prompt from all your memories:

profile = m.get_profile()
# → "You are talking to Ali, a developer in Almaty building Mengram.
#    He uses Python, PostgreSQL, and Railway. Recently debugged pgvector deployment.
#    Workflows: deploys via build→twine→npm→git. Communicate directly, focus on practical next steps."

Insert into any LLM's system prompt for instant personalization.

Import Existing Data

Kill the cold-start problem — import your ChatGPT history, Obsidian vault, or text files:

# ChatGPT export (Settings → Data Controls → Export)
mengram import chatgpt ~/Downloads/chatgpt-export.zip --cloud

# Obsidian vault
mengram import obsidian ~/Documents/MyVault --cloud

# Any text/markdown files
mengram import files notes/*.md --cloud

Works with Python SDK too:

m = CloudMemory(api_key="om-...")
m.import_chatgpt("export.zip")
m.import_obsidian("~/Documents/MyVault")
m.import_files(["notes.md", "journal.txt"])

Integrations

MCP Server (Claude Desktop, Cursor, Windsurf)

{
  "mcpServers": {
    "mengram": {
      "command": "mengram",
      "args": ["server", "--cloud"],
      "env": { "MENGRAM_API_KEY": "om-..." }
    }
  }
}

LangChain

from integrations.langchain import MengramChatMessageHistory, MengramRetriever

# Drop-in message history — auto-saves to Mengram
history = MengramChatMessageHistory(api_key="om-...", user_id="user-1")

# RAG retriever — searches all 3 memory types
retriever = MengramRetriever(api_key="om-...")

CrewAI

from integrations.crewai import create_mengram_tools

tools = create_mengram_tools(api_key="om-...")
# → 5 tools: search, remember, profile, save_workflow, workflow_feedback

agent = Agent(role="Support Engineer", tools=tools)

OpenClaw

openclaw plugins install openclaw-mengram
{
  "plugins": {
    "entries": {
      "openclaw-mengram": {
        "enabled": true,
        "config": { "apiKey": "${MENGRAM_API_KEY}" }
      }
    },
    "slots": { "memory": "openclaw-mengram" }
  }
}

Auto-recall before every turn, auto-capture after every turn. 6 tools, slash commands, CLI. GitHub · npm

Agent Templates

Ready-to-run examples — clone, set API key, run in 5 minutes:

Template Stack What it shows
DevOps Agent Python SDK Procedures that evolve from deployment failures
Customer Support CrewAI Agent with 5 memory tools, remembers returning customers
Personal Assistant LangChain Cognitive profile + auto-saving chat history
cd examples/devops-agent && pip install -r requirements.txt
export MENGRAM_API_KEY=om-...
python main.py

API Reference

All endpoints require Authorization: Bearer om-.... Your API key identifies the account. Pass user_id to isolate data per end-user (multi-tenant apps).

Endpoint Description
POST /v1/add Add memories (auto-extracts all 3 types)
POST /v1/search Semantic search
POST /v1/search/all Unified search (all 3 types)
GET /v1/episodes/search Search episodic memories
GET /v1/procedures/search Search procedural memories
PATCH /v1/procedures/{id}/feedback Report success/failure → triggers evolution
GET /v1/procedures/{id}/history Version history + evolution log
GET /v1/profile Cognitive Profile
GET /v1/triggers Smart Triggers (reminders, contradictions, patterns)
POST /v1/agents/run Run memory agents (Curator, Connector, Digest)

Multi-User Isolation

Building an app with multiple users? Pass user_id to isolate memories per end-user. One API key, many users — each sees only their own data:

# Each user_id gets its own isolated memory space
m.add([...], user_id="alice")
m.add([...], user_id="bob")

m.search_all("preferences", user_id="alice")  # Only Alice's memories
m.search_all("preferences", user_id="bob")    # Only Bob's memories

m.get_profile(user_id="alice")  # Alice's cognitive profile
await m.add([...], { userId: 'alice' });
await m.searchAll('preferences', { userId: 'alice' });  // Only Alice's memories

No user_id? Everything works as before — defaults to a single shared memory space.

Full interactive docs: mengram.io/docs

License

Apache 2.0 — free for commercial use.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mengram_ai-2.14.3.tar.gz (151.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mengram_ai-2.14.3-py3-none-any.whl (157.5 kB view details)

Uploaded Python 3

File details

Details for the file mengram_ai-2.14.3.tar.gz.

File metadata

  • Download URL: mengram_ai-2.14.3.tar.gz
  • Upload date:
  • Size: 151.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for mengram_ai-2.14.3.tar.gz
Algorithm Hash digest
SHA256 0d76d350c77c7cd454d72fd8c56dc45ca9d88d9c18b46a5fa26ec6ffe564ee1a
MD5 47f0a2861a6def2d752b6af40c5aaa49
BLAKE2b-256 89ec4d4a838c4f5397a3c398f038b7550b35030776b6e04981b0387b5aa13aa0

See more details on using hashes here.

File details

Details for the file mengram_ai-2.14.3-py3-none-any.whl.

File metadata

  • Download URL: mengram_ai-2.14.3-py3-none-any.whl
  • Upload date:
  • Size: 157.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for mengram_ai-2.14.3-py3-none-any.whl
Algorithm Hash digest
SHA256 afc715971ec8d3a9cce1e9fa07aaeb5203a7894c6a73780ce03beae99f65faf6
MD5 a5ec1ed2507a09c3ec2a4835a75eefd0
BLAKE2b-256 67bbfd6968b1d7f4bcd69bfdfe704a8c10d2839c586333945f5309a3840bfa8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page