Skip to main content

memhq — Python SDK for MemHQ

The official Python client for MemHQ, a drop-in memory layer for AI agents. Same shape as Mem0, with a built-in synthesis pass (ask()) for cited answers.

Install

pip install memhq

Quickstart

import os
from memhq import MemoryClient

client = MemoryClient(api_key=os.environ["MEMHQ_API_KEY"])

# 1. Add — auto-creates the user + default thread
client.add(
    messages=[{"role": "user", "content": "I'm a vegetarian, allergic to nuts."}],
    user_id="user_123",
)

# 2. Search — hybrid retrieval (BM25 + vector + graph)
results = client.search("dietary restrictions", user_id="user_123")
for memory in results:
    print(memory.score, memory.content)

# 3. Ask — synthesized answer with citations
answer = client.ask("What should I avoid eating?", user_id="user_123")
print(answer.text)
for cit in answer.citations:
    print(" •", cit.content)

Async

import asyncio
from memhq import AsyncMemoryClient

async def main():
    async with AsyncMemoryClient() as client:  # picks up MEMHQ_API_KEY
        await client.add(
            messages=[{"role": "user", "content": "I live in Brooklyn"}],
            user_id="user_123",
        )
        result = await client.ask("Where does the user live?", user_id="user_123")
        print(result.text)

asyncio.run(main())

Configuration

Env var Default Notes
MEMHQ_API_KEY (required) Get one from the dashboard.
MEMHQ_BASE_URL https://api.memhq.ai Override for self-host or local dev.
# Self-hosted MemoryOS or local development
client = MemoryClient(api_key="...", base_url="http://localhost:3000")

Reference

client.add(messages, *, user_id, group_id=None, metadata=None) -> AddResult

Ingest one or more messages into the user's memory graph. Extraction runs asynchronously on the server — typically completes in under three seconds.

client.search(query, *, user_id=None, group_ids=None, limit=10) -> SearchResult

Hybrid search across the user's graph plus any shared group graphs. Returns an iterable SearchResult; each element is a Memory(id, content, type, score).

client.ask(question, *, user_id=None, group_ids=None, limit=8) -> AskResult

Retrieve, rerank, and synthesize a cited answer. Returns an AskResult with answer (alias: text) and a list of Citation(id, content).

client.users.get(user_id), client.users.delete(user_id), client.users.list()

User management. user_id accepts the external id you passed to add().

License

Apache-2.0.

Metadata

Release files for memhq 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for memhq 0.1.0
File Size Uploaded
memhq-0.1.0.tar.gz 12.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for memhq 0.1.0
File Interpreter ABI Platform
memhq-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.2 kB

Release files / memhq-0.1.0.tar.gz

Download URL memhq-0.1.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
935e0df81d02a8d342785ded5f390b427945e317339e5173983df61dd8c30ab2
BLAKE2b-256 checksum
How to use checksums
d4142b1f63770a3b7304ad645ea02f9d96b2dff263f2d31b9b12e2ba018713cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.8

Release files / memhq-0.1.0-py3-none-any.whl

Download URL memhq-0.1.0-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ef280f71122d4e39564b06e58e48540003fceded3c0fef3955bebaf19f06e6a
BLAKE2b-256 checksum
How to use checksums
0f0dee0be90f0e2b5dfc64fd6f7b5cf6d5c7b4f166a4ce0cca85e23a1d904701
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.8

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page