Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

OpenZync Python SDK

PyPI Python License

Python SDK for OpenZync — the open-source agent memory platform with persistent, queryable, graph-based memory for AI agents.

Installation

pip install openzync

Requires Python 3.11+.

Quick Start

from openzync import OpenZync

client = OpenZync(api_key="oz_live_your_api_key_here")

# Create a user
user = client.users.create(external_id="alice")
print(f"User: {user.name} ({user.id})")

# Ingest conversation messages
resp = client.memory.ingest(
    messages=[
        {"role": "user", "content": "Hi, I am Alice from Acme Corp."},
        {"role": "assistant", "content": "Hello Alice! How can I help you today?"},
    ],
)
print(f"Ingested {resp.episode_count} episodes")

# Search across memory
results = client.graph.search("Alice Acme Corp", types="episodes,facts")
for r in results:
    print(f"  - {r['content']}")

Client API

Sync (default)

from openzync import OpenZync

client = OpenZync(api_key="...")

# ── Memory ──
client.memory.ingest(messages=[...])
client.memory.get_context(query="...")
client.memory.delete()

# ── Facts ──
client.facts.add(facts=[...])

# ── Graph ──
for node in client.graph.nodes():
    print(node.name)
detail = client.graph.node_detail(node_id)
client.graph.delete_node(node_id)
for edge in client.graph.edges(subject_id):
    print(edge.type)
comms = client.graph.communities()
results = client.graph.search("query")

# ── Users ──
user = client.users.create(external_id="bob")
user = client.users.get(user_id)
user = client.users.update(user_id, name="New Name")
client.users.delete(user_id)
for user in client.users.list_iter():
    print(user["name"])

# ── Sessions ──
session = client.sessions.create(external_id="s1")
msgs = client.sessions.messages(session_id)
client.sessions.delete(session_id)

Async

import asyncio
from openzync import AsyncOpenZync

async def main():
    async with AsyncOpenZync(api_key="...") as client:
        resp = await client.memory.ingest(messages=[...])

asyncio.run(main())

Error Handling

from openzync import OpenZync
from openzync._errors import NotFoundError, RateLimitError

client = OpenZync(api_key="...")

try:
    user = client.users.get("non-existent-id")
except NotFoundError:
    print("User not found")
except RateLimitError:
    print("Rate limited — slow down")

Pagination

List endpoints return an iterator that auto-fetches subsequent pages:

# Iterate over all users (auto-paginated)
for user in client.users.list_iter():
    print(user["name"])

LangChain Integration

LangChain developers can use OpenZync as a drop-in memory provider, graph retriever, and tool set.

pip install "openzync[langchain]"

Chat Message History

Persist conversation history to OpenZync:

from openzync import OpenZync
from openzync.integrations.langchain import OZChatMessageHistory
from langchain_core.messages import HumanMessage

client = OpenZync(api_key="...")
history = OZChatMessageHistory(
    session_id="session-1",
    user_id="user-abc",
    client=client,  # accepts both sync and async clients
)

history.add_message(HumanMessage(content="Hello!"))
print(history.messages)

Memory

Use OZMemory as a standard LangChain BaseMemory inside chains:

from openzync import OpenZync
from openzync.integrations.langchain import OZMemory
from langchain_core.messages import HumanMessage, AIMessage

client = OpenZync(api_key="...")
memory = OZMemory(
    session_id="session-1",
    user_id="user-abc",
    client=client,
    return_messages=True,   # False returns string
    memory_key="history",   # key in memory_variables
)

memory.save_context({"input": "Hi"}, {"output": "Hello!"})
context = memory.load_memory_variables({})
# context["history"] — list of BaseMessage or str depending on return_messages

Graph Retriever

Use OZGraphRetriever as a LangChain retriever for RAG pipelines:

from openzync.integrations.langchain import OZGraphRetriever

retriever = OZGraphRetriever(
    user_id="user-abc",
    client=client,
    k=5,                    # max results
    types="episodes,facts", # filter by node type
    score_threshold=0.7,    # minimum relevance score
)

docs = retriever.invoke("What does Alice know about Acme Corp?")
for doc in docs:
    print(doc.page_content, doc.metadata)

Tool plugins

Expose OpenZync graph search and fact management as LangChain tools:

from openzync.integrations.langchain.tools.graph import GraphSearchTool
from openzync.integrations.langchain.tools.facts import AddFactsTool

tools = [
    GraphSearchTool(client=client),
    AddFactsTool(client=client),
]

# Use with LangGraph / ReAct agents
# agent = create_react_agent(model, tools)

Development

# Install with dev dependencies
pip install "openzync[dev]"

# Install everything (dev + langchain)
pip install "openzync[dev,langchain]"

# Run tests
pytest

Metadata

Release files for openzync 1.0.0b2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openzync 1.0.0b2
File Size Uploaded
openzync-1.0.0b2.tar.gz 23.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openzync 1.0.0b2
File Interpreter ABI Platform
openzync-1.0.0b2-py3-none-any.whl Python 3 none any Details

Total release size: 61.2 kB

Release files / openzync-1.0.0b2.tar.gz

Download URL openzync-1.0.0b2.tar.gz
Size 23.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5bfe1b21dac8e095dff46086627348d22e2e4769e1eb9e8700f4e6e39251aa4e
BLAKE2b-256 checksum
How to use checksums
50e4eb5bc553695649d52996cda12d86528d7b6e57877a25e8a79cab6e402ddf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / openzync-1.0.0b2-py3-none-any.whl

Download URL openzync-1.0.0b2-py3-none-any.whl
Size 37.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
569803517259e126c954aefef8cc8625ebe6ca8140a60732d293a11bae0f0978
BLAKE2b-256 checksum
How to use checksums
5ae2732daa44ea6d84b9e05066fd2dc024de2fe10dede4fea6b8f921e649d6c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

1.0.0b2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page