Skip to main content

Official Python SDK for Memgraph - the memory graph for AI agents

Project description

Memgraph SDK

The official Python SDK for Memgraph -- the memory graph for AI agents.

PyPI version Python 3.8+ License: MIT

Installation

pip install memgraph-sdk

For async support:

pip install "memgraph-sdk[async]"

Quick Start

from memgraph_sdk import MemgraphClient

client = MemgraphClient(
    api_key="mg_your_api_key",
    tenant_id="your-tenant-id",
)

# Store a memory
client.add(
    text="User prefers dark mode and uses PyTorch.",
    user_id="user_123",
)

# Search for relevant context
result = client.search(
    query="What does this user prefer?",
    user_id="user_123",
)
print(result)

Async Client

from memgraph_sdk import AsyncMemgraphClient

async with AsyncMemgraphClient(
    api_key="mg_your_api_key",
    tenant_id="your-tenant-id",
) as client:
    await client.add("User prefers dark mode", user_id="user_123")
    result = await client.search("user preferences", user_id="user_123")

Memory Intelligence API

# Memory health metrics
health = client.health(user_id="user_123")

# Detect contradictions
contradictions = client.contradictions(user_id="user_123")

# Evaluate retrieval quality
evaluation = client.evaluate(query="test query", user_id="user_123")

# Cognitive Integrity Score (0-100)
score = client.mcis(user_id="user_123")

# Run benchmarks
result = client.benchmark(scenario="contradiction_storm")
scenarios = client.benchmark_scenarios()

CLI

# Initialize Memgraph in your project
memgraph init

# Store a memory
memgraph remember "We decided to use PostgreSQL" -c decision

# Search memories
memgraph recall "database choice"

# Check connection
memgraph status

Configuration

The client reads the API URL from the MEMGRAPH_API_URL environment variable, defaulting to http://localhost:8001/v1. You can also pass it explicitly:

client = MemgraphClient(
    api_key="mg_your_key",
    tenant_id="your-tenant-id",
    base_url="https://api.memgraph.ai/v1",
)

Examples

See the examples/ directory for complete integration examples:

License

MIT License. See LICENSE for details.

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

memgraph_sdk-0.3.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

memgraph_sdk-0.3.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file memgraph_sdk-0.3.0.tar.gz.

File metadata

  • Download URL: memgraph_sdk-0.3.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for memgraph_sdk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f4b023f63b293dc0a8a56cfa49c5bbfd7bfa15412f8dcf16eaebd0560f85c69c
MD5 a93874e11de8575fe119abc2a6efb05c
BLAKE2b-256 e3b4756f1969973b0a21d0bb7c19bf369406eb89709fe7eabb7d1988fc8cbbef

See more details on using hashes here.

Provenance

The following attestation bundles were made for memgraph_sdk-0.3.0.tar.gz:

Publisher: publish.yml on shubhamdev0/memgraph-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file memgraph_sdk-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: memgraph_sdk-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for memgraph_sdk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50d207d6d436762cdfe03533594fd41a3e3796a1681238b2df48cbccef66e602
MD5 620cb9d0e43731f2eb34a27c142c6370
BLAKE2b-256 810bcecc81adf94c48dafb5eb7cc6c94c3cff7529f5114b0fb0f41af22474876

See more details on using hashes here.

Provenance

The following attestation bundles were made for memgraph_sdk-0.3.0-py3-none-any.whl:

Publisher: publish.yml on shubhamdev0/memgraph-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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