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.2.0.tar.gz (8.9 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.2.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: memgraph_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 8.9 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.2.0.tar.gz
Algorithm Hash digest
SHA256 4d334b1a0b0696037bdd08d0dfaceecd88ec1621d34394595299401e2df14e8a
MD5 3ec2d3202195d1d5f3bb8feba92e6a0b
BLAKE2b-256 fdfbcb524b9093fd4ab70805d0b4eca2fc5689ca77d4b14071e0dde6129c5cbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for memgraph_sdk-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: memgraph_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 642556907e86a8d82c8d7912f1daca311659e8f7d78a5478115e9685003adf66
MD5 99408da7972286141e52f658e6c86755
BLAKE2b-256 2985badbd0cfb46081338d76d24aeda9f55007b49ea06efd311d329325fe3e15

See more details on using hashes here.

Provenance

The following attestation bundles were made for memgraph_sdk-0.2.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