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 memhq

Requires 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:

OptionDefaultDescription
api_key$MEMHQ_API_KEYProject API key.
base_urlhttps://api.memhq.aiOverride for self-hosted control planes (rare).
timeout30.0 (seconds)Per-request timeout.
max_retries3Retries 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.