SDKs
Python SDK
Install, configure, and use the MemHQ Python SDK.
Python SDK
The Python SDK is the canonical client for MemHQ from a Python agent or
backend. It wraps the /v1/memhq/* endpoints with typed methods and
sensible retry behavior.
Install
pip install memhqRequires Python 3.9+.
Configure
Set MEMHQ_API_KEY in your environment:
export MEMHQ_API_KEY="mhq_live_..."The client picks it up automatically:
from memhq import MemoryClient
client = MemoryClient()Or pass the key explicitly:
client = MemoryClient(api_key="mhq_live_...")Available constructor options:
| Option | Default | Description |
|---|---|---|
api_key | $MEMHQ_API_KEY | Project API key. |
base_url | https://api.memhq.ai | Override for self-hosted control planes (rare). |
timeout | 30.0 (seconds) | Per-request timeout. |
max_retries | 3 | Retries on 429/5xx with exponential backoff. |
Usage
The methods mirror the Memory API:
# Ingest
episode = client.add(
user_id="user_42",
messages=[{"role": "user", "content": "I'm vegetarian."}],
)
# Search
results = client.search(user_id="user_42", query="dietary preferences")
# Ask
answer = client.ask(user_id="user_42", question="What should I order them?")
print(answer.text)Async
An async client is available for use in asyncio-based stacks:
from memhq import AsyncMemHQ
client = AsyncMemHQ()
answer = await client.ask(user_id="user_42", question="...")Coming soon — full guide. Type stubs, error classes, streaming ask
responses, and the dashboard-side client surface will be documented
in the next pass.