Skip to main content

Python SDK for Engram by Weaviate.

Project description

Weaviate

weaviate-engram

PyPI version Python versions License CI

The official Python SDK for Engram, the fully managed memory service by Weaviate.

Engram lets you add persistent, personalized memory to AI assistants and agents, with no infrastructure to set up or manage. When you add a memory, Engram processes it asynchronously through a background pipeline that extracts, deduplicates, and reconciles facts. Memories are scoped by project and user, along with any custom scope properties you define, and these scopes can be mixed and matched freely. Each scope is backed by Weaviate's multi-tenant architecture, ensuring strong isolation between tenants.

Learn more about Engram →

Requirements

  • Python 3.11 to 3.14

Installation

pip install weaviate-engram
uv add weaviate-engram

Get an API key

Engram runs on Weaviate Cloud. To get started:

  1. Sign up (or log in) at console.weaviate.cloud.
  2. Open Engram and create a project at console.weaviate.cloud/engram.
  3. Generate an API key from the project's API Keys page. Keys are shown once, so copy yours somewhere safe.

Quick start

1. Initialize the client

from engram import EngramClient

client = EngramClient(api_key="YOUR_API_KEY")

2. Add a memory from a string

# add() returns immediately. Memory processing happens asynchronously
# in the background via Engram's pipeline.
run = client.memories.add(
    "User prefers concise responses and dark mode",
    user_id="alice@example.com",
)
print(run.run_id)  # e.g. "run_abc123"

3. Add a memory from a conversation

Conversations use the OpenAI Chat Completions message format. Separately, you can pass scope properties to control where a memory lives — here a conversation_id scopes it to a specific session. Properties work with any input type, not just conversations:

run = client.memories.add(
    [
        {"role": "user", "content": "I just moved to Berlin and I am looking for a good coffee shop."},
        {"role": "assistant", "content": "Welcome to Berlin! Here are some popular coffee shops in the city..."},
        {"role": "user", "content": "I prefer specialty coffee, not chains."},
    ],
    user_id="alice@example.com",
    properties={"conversation_id": "session-abc123"},
)

print(run.run_id)  # e.g. "run_abc123"

4. Search memories

results = client.memories.search(
    query="What does the user prefer?",
    user_id="alice@example.com",
)
for memory in results:
    print(memory.content)

Async client

An async client with the same surface is available:

from engram import AsyncEngramClient

client = AsyncEngramClient(api_key="YOUR_API_KEY")

run = await client.memories.add(
    "User prefers concise responses and dark mode",
    user_id="alice@example.com",
)
results = await client.memories.search(
    query="What does the user prefer?",
    user_id="alice@example.com",
)

Error handling

All SDK exceptions inherit from EngramError:

from engram import (
    APIError,             # raised on any non-2xx response
    AuthenticationError,  # 401, invalid or missing API key
    ValidationError,      # invalid client configuration or request input
    ConnectionError,      # network failure reaching the Engram API
    EngramTimeoutError,   # runs.wait() did not reach a terminal status in time
)

Waiting for a run to complete

Each run is processed asynchronously. Under normal conditions you should not wait on runs — treat add() as fire-and-forget to keep latency low and let the pipeline reconcile memories in the background. Blocking on every run defeats the purpose of the async pipeline and will slow your application down, especially when ingesting at volume.

runs.wait() exists for the cases where you genuinely need the outcome of a specific run before proceeding — primarily debugging and tests:

status = client.runs.wait(run.run_id, timeout=60.0)
print(status.status)  # "completed" or "failed"
print(f"+{len(status.memories_created)} ~{len(status.memories_updated)} -{len(status.memories_deleted)}")

Learn more

Contributing

See CONTRIBUTING.md.

License

This project is licensed under the BSD 3-Clause License.

Support

For questions or help, reach out to support@weaviate.io.

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

weaviate_engram-1.0.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

weaviate_engram-1.0.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file weaviate_engram-1.0.0.tar.gz.

File metadata

  • Download URL: weaviate_engram-1.0.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for weaviate_engram-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a2841bd48d26a83e926656acd72d4cfe7d67942cea61f34dc3ff408b559dd69f
MD5 5fef00a67e44d97f6490bad12fd7dc9e
BLAKE2b-256 3af2ea2207b7d11aa0cf5f32abede401b084b1357876bbe80649897afaa2e0d2

See more details on using hashes here.

File details

Details for the file weaviate_engram-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: weaviate_engram-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for weaviate_engram-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43f2d76dd8224462ecccee666b6ae06f54340892279aeaec76868f70f40a4142
MD5 d4d412a310e23ac657986e000c78c52a
BLAKE2b-256 7d5657ef4e203490d77a82e747ffb3dc3535c5c735a7c8712e437131644635b1

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