Skip to main content
The MemMachine Python Client SDK provides a robust, type-safe interface for your applications to interact with the MemMachine Server. It handles the complexity of authentication, connection pooling, retries, and object serialization, allowing you to focus on building intelligent agents.

Architecture

The MemMachine Client SDK acts as a bridge between your application logic (e.g., an AI agent, a chatbot, or a backend service) and the MemMachine Server.

Communication Flow

The following diagram illustrates how the Client SDK integrates into your system architecture:

Interaction Sequence

The standard workflow involves initializing the client, selecting a project, defining a memory context, and then performing operations.

Installation

Install the client package via pip:

Hello World Example

This complete example demonstrates the core workflow: connecting to the server, initializing a project workspace, and performing memory operations.
MemMachineClient Hello World
The expected output from running the above Hello World script should look like this:
Hello World Expected Output

Explore the API

Now that you understand the architecture, dive into the specific namespaces to see what you can build:

Client Core

Initialization, connection management, and global configuration.

Projects

Manage isolated data boundaries and organizations.

Memories

Ingest and search the raw stream of interaction data.

Semantic Graph

Organize facts into Sets, Categories, and Tags.

Configuration

Fine-tune LLM, Embedder, and Reranker resources.

System & Health

Monitor server status, metrics, and version compatibility.

Core Concepts

MemMachineClient

The entry point for the SDK. It manages the persistent HTTP session, connection pooling, and global configuration (like timeouts and retries). Key Parameters:
  • base_url: The URL of your MemMachine Server (e.g., http://localhost:8080).
  • api_key: (Optional) Authentication token if your server requires it.
  • timeout: Request timeout in seconds (default: 30).

Project

A Project represents an isolated workspace. All data in MemMachine is siloed by org_id and project_id.
  • Use client.create_project() to initialize or retrieve a project.
  • Use client.get_project() to retrieve an existing project (raises error if not found).

Memory

The Memory object is a transient interface bound to a specific context. It does not hold state itself but ensures that every operation (add, search, delete) is tagged with the correct metadata identifiers:
  • user_id: The human user.
  • agent_id: The AI agent.
  • group_id: (Optional) A group identifier for multi-user contexts.
  • session_id: (Optional) A specific session identifier.
Key Methods:
  • add(content, role, ...): Stores a new memory episode.
  • search(query, ...): Semantically searches for relevant memories.
  • delete(): Deletes memories matching specific criteria.