Python SDK

The synapse-layer package on PyPI provides a synchronous client for storing and recalling encrypted memories. One class, three methods, zero boilerplate.

Installation

bash
pip install synapse-layer

Requires Python 3.10+. The package depends on cryptography≥48.0.1, pydantic≥2.4.0, and httpx≥0.27.0.

For framework integrations, install optional extras:

bash
# LangChain integration
pip install synapse-layer[langchain]

Quick Start

python
from synapse_layer import Synapse

client = Synapse(api_key="sk_connect_your_token")

# Store a memory — encrypted server-side with AES-256-GCM
client.remember("User prefers dark mode and TypeScript")

# Recall relevant memories via semantic search
results = client.recall("user preferences")
for memory in results:
    print(memory["content"], memory["trust_quotient"])

Note

Get your sk_connect_* token from Forge → Dashboard → Connect.

Client Reference

The Synapse class (aliased as SynapseClient) is the primary interface.

Constructor

ParameterTypeDescription
api_keystrConnect token (sk_connect_*). Also accepts token= kwarg.
base_urlstrForge URL. Default: https://forge.synapselayer.org
agent_idstrAgent namespace. Default: sdk-client
timeoutfloatHTTP timeout in seconds. Default: 15.0
verboseboolEnable debug logging. Default: False

Methods

store(content, *, memory_type, metadata) → dict

Persist a memory. Returns memoryId, contentHash, trustQuotient.

remember(content, ...) → dict

Alias for store().

recall(query, *, top_k, mode) → list[dict]

Semantic recall. Returns list of memories with content, trust_quotient, intent, agent, timestamp.

list_memories(*, limit) → list[dict]

List recent memories. Default limit: 10.

close() → None

Release the HTTP connection pool. Also supports context manager (with Synapse(...) as client:).

Framework Integrations

Built-in adapters for popular AI frameworks:

FrameworkImportInstall
LangChainfrom synapse_memory.integrations import SynapseChatMessageHistorypip install synapse-layer[langchain]
CrewAIfrom synapse_memory.integrations.crewai_memory import SynapseCrewStoragepip install synapse-layer crewai
AutoGenfrom synapse_memory.integrations.autogen_memory import ...pip install synapse-layer autogen
LlamaIndexfrom synapse_memory.integrations.llamaindex import ...pip install synapse-layer llama-index
Semantic Kernelfrom synapse_memory.integrations.semantic_kernel import ...pip install synapse-layer semantic-kernel

Error Handling

The SDK raises specific exceptions from synapse_memory.exceptions:

ExceptionWhen
ForgeAuthErrorInvalid or expired Connect Token (HTTP 401)
ForgeRateLimitErrorRate limit exceeded (HTTP 429)
ForgeBackendErrorNetwork error or unexpected server response
python
from synapse_memory.exceptions import ForgeAuthError, ForgeRateLimitError

try:
    client.remember("important decision")
except ForgeAuthError:
    print("Check your Connect Token")
except ForgeRateLimitError:
    print("Too many requests — back off and retry")

Configuration

The SDK reads these environment variables as fallbacks:

VariablePurpose
SYNAPSE_TOKENFallback Connect Token if not passed to constructor
SYNAPSE_FORGE_URLForge base URL (default: https://forge.synapselayer.org)