MemG Python SDK
Python SDK for MemG -- a pluggable memory layer for LLM applications.
Installation
pip install memg
# With provider extras
pip install memg[openai]
pip install memg[anthropic]
pip install memg[all]
Quick Start
Proxy Mode (simplest)
Redirect your LLM client through the MemG proxy. No extra code needed beyond wrapping:
from openai import OpenAI
from memg import MemG
client = OpenAI()
client = MemG.wrap(client, entity="user-123", mode="proxy")
# Use as normal -- MemG injects and extracts memories transparently
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "I love hiking in the mountains"}],
)
Client Mode (no proxy needed)
The SDK intercepts calls, queries the MCP server for relevant memories, injects them, and extracts new knowledge:
from openai import OpenAI
from memg import MemG
client = OpenAI()
client = MemG.wrap(client, entity="user-123", mode="client")
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Remember I prefer dark roast coffee"}],
)
Direct Memory Operations
from memg import MemG
m = MemG()
# Add memories
m.add("user-123", "likes coffee")
m.add("user-123", ["works at Acme", "prefers dark mode"])
# Search
results = m.search("user-123", "coffee preferences")
for mem in results.memories:
print(f"{mem.content} (score={mem.score})")
# List
all_mems = m.list("user-123", type="identity")
# Delete
m.delete("user-123", memory_id="some-uuid")
m.delete_all("user-123")
m.close()
Modes
| Mode | Requires | How it works |
|---|---|---|
proxy |
MemG proxy running | Redirects LLM calls through the proxy via with_options() |
client |
MemG MCP server running | SDK intercepts calls, queries MCP for memories, injects context |
Configuration
Default URLs:
- MCP server:
http://localhost:8686 - Proxy:
http://localhost:8787/v1
Override via constructor or wrap():
m = MemG(mcp_url="http://custom:8686", proxy_url="http://custom:8787/v1")
MemG.wrap(client, mode="proxy", proxy_url="http://custom:8787/v1")
Metadata
Release files for memg-sdk 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| memg_sdk-0.2.0.tar.gz | 1.9 kB | Without provenance | Details for memg_sdk-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| memg_sdk-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for memg_sdk-0.2.0-py3-none-any.whl |
Total release size: 3.7 kB
Release files / memg_sdk-0.2.0.tar.gz
| Download URL | memg_sdk-0.2.0.tar.gz |
|---|---|
| Size | 1.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e836111691f4d7a4f3ac1012967365cec3bea233881fd6b68cca6b12b13fbfe4
|
|
BLAKE2b-256 checksum How to use checksums |
1129a393d0e4e80a7cfe54ab40ebacbf783b2b41de4fa6a4c1907f279b32560e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / memg_sdk-0.2.0-py3-none-any.whl
| Download URL | memg_sdk-0.2.0-py3-none-any.whl |
|---|---|
| Size | 1.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1e7eea95a591b340e721f6588f6e1ebe5d5e3f75e533b4edf0102e361b79520
|
|
BLAKE2b-256 checksum How to use checksums |
f4bd0dddc0b0b63828b21fe2451d0845e77bdbb72fb51f004fc57823790a7020
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for memg-sdk 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.