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.1.1.tar.gz (8.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.1.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: memgraph_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 8.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.1.1.tar.gz
Algorithm Hash digest
SHA256 b03528bea9b49aadbf49063fb8cf499eec78222e476eabf40a69fc44bd406470
MD5 cfc8f2880b899eeea882af6b85428ee3
BLAKE2b-256 4144993454ae0781a6e151f234b5fddab313427aaa4d4b5323942f7fd5f77bd9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: memgraph_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c38019a77627c72f3fa46c978eb461ef307987511ad3a08a7923a89c11ccb2d2
MD5 07dc541763aae84fa7fe39c8a0ccc4c8
BLAKE2b-256 80a43632516c436052c1d7bdaec438856f53fb0865d6f535844e7dc5b09a673f

See more details on using hashes here.

Provenance

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