Skip to main content

Python SDK for the Engram memory API

Project description

openengram

Python SDK for the Engram memory API — persistent memory for AI agents.

Installation

pip install openengram

Quick Start

from openengram import Engram

engram = Engram(api_key="ek_...", user_id="user_beaux")

# Store a memory
memory = engram.remember("User prefers dark mode and uses vim")

# Search memories
results = engram.search("What editor does the user prefer?")
for m in results.memories:
    print(m.raw)

# Load context for a session
ctx = engram.context(max_tokens=2000)
print(ctx.context)

# Get a specific memory
memory = engram.get(memory.id)

# Update a memory
engram.update(memory.id, raw="User prefers dark mode and uses neovim")

# Delete a memory
engram.forget(memory.id)

Configuration

Parameter Env Var Default
api_key ENGRAM_API_KEY
user_id ENGRAM_USER_ID
base_url ENGRAM_BASE_URL https://api.openengram.ai
# Using environment variables
import os
os.environ["ENGRAM_API_KEY"] = "ek_..."
os.environ["ENGRAM_USER_ID"] = "user_beaux"

engram = Engram()  # picks up env vars automatically

Async Support

from openengram import AsyncEngram

async def main():
    async with AsyncEngram(api_key="ek_...") as engram:
        memory = await engram.remember("User likes async Python")
        results = await engram.search("async")

Memory Layers

Memories are organized into layers:

  • SESSION — Short-lived, conversation-scoped
  • PROJECT — Project-specific context
  • IDENTITY — Long-term user preferences and facts
  • TASK — Task-specific context
from openengram import MemoryLayer

engram.remember(
    "User's favorite color is blue",
    layer=MemoryLayer.IDENTITY,
)

results = engram.search("color", layers=[MemoryLayer.IDENTITY])

Feedback

Help improve memory relevance with feedback signals:

engram.mark_used(memory.id)      # implicit signal
engram.mark_helpful(memory.id)   # explicit signal

Error Handling

from openengram import NotFoundError, RateLimitError

try:
    memory = engram.get("nonexistent-id")
except NotFoundError:
    print("Memory not found")
except RateLimitError:
    print("Slow down!")

License

Apache 2.0

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

openengram-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

openengram-0.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file openengram-0.1.0.tar.gz.

File metadata

  • Download URL: openengram-0.1.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for openengram-0.1.0.tar.gz
Algorithm Hash digest
SHA256 07d5f511035013a53045f163b1684d560cebfea406d5cd49199b64f9db8bf1e9
MD5 6e5acde186a157c01ab17b82418b83d7
BLAKE2b-256 b9d684a589abaefabd2d9a938b115e9fb59932784d8ed9c5ffc6bc09a5316982

See more details on using hashes here.

File details

Details for the file openengram-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: openengram-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for openengram-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d95007b8bee6d1a2d1e829d7a71e159ffdc91a8f7b72eabcc620b4022d2f75c3
MD5 40bfe3e7d8b338da76e060d10a75e166
BLAKE2b-256 d7cae458fcc60ca451bad30a168dd811f21bca19149ef1d9a8ab151073d61067

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