API Reference

AsyncMemsyClient

Async HTTP client — mirrors MemsyClient method-for-method.

Asynchronous HTTP client for the Memsy API. Mirrors MemsyClient method-for-method.

from memsy import AsyncMemsyClient

Constructor

AsyncMemsyClient(
    base_url: str,
    api_key: str,
    timeout: float = 30.0,
    max_retries: int = 3,
    retry_backoff: float = 1.0,
)

Parameters are identical to MemsyClient. See that page for the full table.

Async context manager

async with AsyncMemsyClient(base_url="...", api_key="***") as client:
    await client.health()

If you can't use async with, call await client.close() explicitly.

Methods

Each method has the same signature as the sync client but returns a coroutine.

MethodReturns
await ingest(events)IngestResponse
await search(query, *, actor_id, limit, threshold, include_source_events)SearchResponse
await status(event_ids)StatusResponse
await health()HealthResponse
await clear(container_tag)ClearResponse (currently a 501 Not Implemented stub — see retries notes)
await close()None

All raise the same exceptions as the sync client.

Sub-resource accessors

AsyncMemsyClient exposes async versions of all sub-resources.

AccessorMethods
client.orgsawait list(), await create(...), await get(...), await update(...), await regenerate_prompt(...), await delete(...)
client.rolesawait list(org_id), await create(...), await get(...), await update(...), await regenerate_prompt(...), await delete(...)
client.teamsawait list(org_id), await create(...), await get(...), await update(...), await regenerate_prompt(...), await delete(...)
client.memoriesawait list(...), await get(memory_id), await stats()

See MemsyClient for the full method signatures — async versions are identical except for await.

Parallel calls

import asyncio

async def two_in_parallel(client: AsyncMemsyClient, user_id: str):
    prefs, recent = await asyncio.gather(
        client.search("preferences", actor_id=user_id),
        client.search("recent topics", actor_id=user_id),
    )
    return prefs.results, recent.results

See also