Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.maximem.ai/llms.txt

Use this file to discover all available pages before exploring further.

await sdk.fetch(conversation_id=None, user_id=None, customer_id=None, search_query=None, max_results=20, types=None, mode="fast", include_conversation_context=True, scopes=None, include_scope_labels=False)
The recommended entry point for framework integrations. fetch() queries every scope you provide an identifier for in parallel, deduplicates the merged items (first scope wins), attributes each item to its source scope, optionally folds in the conversation’s compacted history plus recent messages, and returns a ready-to-inject formatted_context string. Pass it the identifiers you have on hand for the current turn — conversation, user, customer — and use the resulting formatted_context directly in your LLM prompt.

Parameters

conversation_id
str
Conversation scope identifier. When provided, the conversation scope is queried and (unless disabled) the conversation’s compacted history is included.
user_id
str
User scope identifier. Threaded into the conversation-scope sub-fetch so per-user privacy filtering applies.
customer_id
str
Customer scope identifier. Required for B2B deployments where customer-scoped context is in use.
search_query
list[str]
Search queries applied to all queried scopes. Defaults to None (no query-side filtering).
max_results
int
Maximum results per scope. The merged total may be higher across scopes. Defaults to 20.
types
list[str]
Memory types to include. Defaults to None, which means all types.
mode
str
Retrieval mode. "fast" (default) or "accurate".
include_conversation_context
bool
Include the conversation’s compacted history plus recent messages in the result. Defaults to True. Only effective when conversation_id is also provided.
scopes
list[str]
Explicitly limit which scopes to query (e.g. ["user", "customer"]). Defaults to None, which queries every scope for which an identifier was provided.
include_scope_labels
bool
Annotate each item with its source scope in the formatted_context output. Defaults to False.

Returns

A UnifiedContextResponse with merged items, scope attribution, and a formatted_context string ready for LLM injection.
formatted_context
str
Pre-formatted context block you can drop straight into an LLM prompt. Honors include_scope_labels and include_conversation_context.
scopes_queried
list[str]
The scopes that were actually queried for this call, in order.
scope_map
dict[str, str]
Mapping from item ID to the scope that produced it after deduplication.
conversation_context
object | None
When include_conversation_context=True and a conversation_id was supplied, the conversation’s compacted history and recent messages. None otherwise.

Example

from maximem_synap import MaximemSynapSDK

sdk = MaximemSynapSDK(api_key="synap_your_key_here")
await sdk.initialize()

# Fetch everything for a conversation turn.
ctx = await sdk.fetch(
    conversation_id="conv-123",
    user_id="user-456",
    customer_id="cust-789",
    search_query=["user preferences"],
)
prompt = ctx.formatted_context  # Drop into your LLM system prompt.

# Fetch only user + customer context (skip conversation scope).
ctx = await sdk.fetch(
    user_id="user-456",
    customer_id="cust-789",
    scopes=["user", "customer"],
)

Raises

  • AuthenticationError — when the SDK has not been initialized (call await sdk.initialize() first).
Per-scope fetch failures are logged and skipped rather than raised, so a partial-scope outage still returns the scopes that succeeded. See Error Codes for the full SDK exception hierarchy.

See also

  • initialize — required before calling fetch.
  • as_tool — expose fetch to an LLM as a tool definition.