Python SDK for ForgeMemory Enterprise — multi-tenant AI memory at scale
Project description
ForgeMemory Enterprise Python SDK
Production-quality Python client for ForgeMemory Enterprise — multi-tenant AI memory at scale.
Installation
pip install forgememory-enterprise
With framework adapters:
pip install "forgememory-enterprise[crewai]" # CrewAI integration
pip install "forgememory-enterprise[langgraph]" # LangGraph integration
pip install "forgememory-enterprise[autogen]" # AutoGen integration
Quick Start
from forgememory_enterprise import EnterpriseClient
from forgememory_enterprise.types import CreateMemoryRequest
client = EnterpriseClient(api_key="fme_your_key", base_url="https://your-server:8201")
# Store a memory
mem = client.memory.create("tenant-123", CreateMemoryRequest(
content="Q4 revenue target is $2.5M",
memory_type="semantic",
importance=8,
tags=["finance"],
))
# Search memories
results = client.memory.search("tenant-123", "revenue target", limit=5)
# Get assembled LLM context
ctx = client.memory.context("tenant-123", "What are our targets?")
print(ctx.context)
Server Address
base_url is a required parameter — the SDK never embeds server addresses:
client = EnterpriseClient(api_key="fme_your_key", base_url="https://fme.example.com:8201")
For deployments that need dynamic LAN/Tailscale routing, use _network.detect_base_url() and pass the result as base_url. The detection function requires caller-supplied host names — no defaults are baked in:
from forgememory_enterprise._network import detect_base_url
url = detect_base_url(lan_host="your-lan-host", tailscale_host="your-ts-host")
client = EnterpriseClient(api_key="fme_your_key", base_url=url)
For the MCP server, set one of:
FME_BASE_URL=https://your-server:8201(preferred)FME_LAN_HOST=<ip>+FME_TAILSCALE_HOST=<hostname>(auto-detection)
Sub-Managers
| Manager | Access | Operations |
|---|---|---|
client.orgs |
OrgManager |
Create/list orgs, users, branches, provision tenants |
client.tenants |
TenantManager |
List, suspend, reactivate, delete, set quota |
client.api_keys |
ApiKeyManager |
Create, list, revoke API keys |
client.agents |
AgentRegistry |
Register, update, delete agents; sessions, heartbeat |
client.audit |
AuditLogger |
Log actions, memory access, delegations; costs |
client.memory |
MemoryClient |
CRUD, search, context, facts (per-tenant) |
client.admin |
AdminClient |
Health, dashboard, pool stats |
client.entities |
EntityGraphClient |
Entity CRUD, edges, BFS graph traversal |
client.ingest |
IngestClient |
Document, email, meeting, calendar ingestion |
All managers are lazily initialized on first access.
Agent Sessions
with client.session("agent-1", "tenant-1") as sess:
# Background heartbeat runs automatically
client.audit.log_action("agent-1", sess.id, "tool_call", "web_search")
client.memory.create("tenant-1", CreateMemoryRequest(content="Found info"))
# Session auto-ended (status=completed, or failed on exception)
Framework Adapters
CrewAI
from forgememory_enterprise.adapters.crewai_adapter import ForgeMemoryTool, FMECrewObserver
tool = ForgeMemoryTool(client, tenant_id="t-123")
result = tool.run("search:customer preferences")
observer = FMECrewObserver(client, "agent-1", session_id)
observer.on_tool_use("search", "query")
observer.on_llm_call(tokens_in=500, tokens_out=200, cost_usd=0.005)
LangGraph
from forgememory_enterprise.adapters.langgraph_adapter import (
make_memory_retrieve_node, make_memory_store_node, make_memory_context_node
)
retrieve = make_memory_retrieve_node(client, "t-123")
store = make_memory_store_node(client, "t-123")
# Add to your graph as nodes
AutoGen
from forgememory_enterprise.adapters.autogen_adapter import fme_tool, inject_context
@fme_tool(client, tenant_id="t-123")
def search_memory(query: str) -> str:
"""Search organizational memory."""
...
context = inject_context(client, "t-123", "project status")
OpenClaw
from forgememory_enterprise.adapters.openclaw_adapter import FMEOpenClawPlugin
plugin = FMEOpenClawPlugin(client, tenant_id="t-123")
results = plugin.search("customer preferences")
plugin.store("New finding from browsing session")
Error Handling
from forgememory_enterprise import (
AuthenticationError, # 401 — invalid/expired key
ForbiddenError, # 403 — insufficient permissions
NotFoundError, # 404 — resource not found
BudgetExceededError, # 402 — agent budget exceeded
RateLimitedError, # 429 — too many requests
LegalHoldError, # 403 — GDPR legal hold blocks mutation
)
Testing
cd sdk/python
pip install -e ".[dev]"
python -m pytest tests/ -v # 367 tests, all using MockTransport
Requirements
- Python 3.10+
- httpx >= 0.27.0
- pydantic >= 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file forgememory_enterprise-1.0.0.tar.gz.
File metadata
- Download URL: forgememory_enterprise-1.0.0.tar.gz
- Upload date:
- Size: 82.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2552807868c49a503187a354333df9228991d307dde5f9b69701370b47b8e7be
|
|
| MD5 |
27997c58769f06ed249d2f7fac236bff
|
|
| BLAKE2b-256 |
f098f7fe3e5ac8b3412369296783a7fee1196dfc553c7fd267f6dc1addef6a16
|
Provenance
The following attestation bundles were made for forgememory_enterprise-1.0.0.tar.gz:
Publisher:
publish-pypi.yml on MbartPhoto/ForgeMemoryEnterprise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
forgememory_enterprise-1.0.0.tar.gz -
Subject digest:
2552807868c49a503187a354333df9228991d307dde5f9b69701370b47b8e7be - Sigstore transparency entry: 1174386078
- Sigstore integration time:
-
Permalink:
MbartPhoto/ForgeMemoryEnterprise@88d89eddaae0068d32c377f3cfd896d96721c5a3 -
Branch / Tag:
refs/tags/sdk-python-v1.0.0 - Owner: https://github.com/MbartPhoto
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@88d89eddaae0068d32c377f3cfd896d96721c5a3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file forgememory_enterprise-1.0.0-py3-none-any.whl.
File metadata
- Download URL: forgememory_enterprise-1.0.0-py3-none-any.whl
- Upload date:
- Size: 49.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f676ccb9ee885ca7558c9ed4b4fc63751db2415a241367521aa177a949f340b
|
|
| MD5 |
a4cba3398b51e78a0596663c65e5ae78
|
|
| BLAKE2b-256 |
48bce42bb7c32d609328ca8004efe5778701d645d2db5243ba8ff0458db607d7
|
Provenance
The following attestation bundles were made for forgememory_enterprise-1.0.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on MbartPhoto/ForgeMemoryEnterprise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
forgememory_enterprise-1.0.0-py3-none-any.whl -
Subject digest:
8f676ccb9ee885ca7558c9ed4b4fc63751db2415a241367521aa177a949f340b - Sigstore transparency entry: 1174386510
- Sigstore integration time:
-
Permalink:
MbartPhoto/ForgeMemoryEnterprise@88d89eddaae0068d32c377f3cfd896d96721c5a3 -
Branch / Tag:
refs/tags/sdk-python-v1.0.0 - Owner: https://github.com/MbartPhoto
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@88d89eddaae0068d32c377f3cfd896d96721c5a3 -
Trigger Event:
push
-
Statement type: