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.customer.context.fetch(
    customer_id,
    conversation_id=None,
    search_query=None,
    max_results=10,
    types=None,
    mode="fast",
)
Retrieve context scoped to a specific customer organization. Customer-scoped memories are visible to all users within that customer. This is useful for fetching shared organizational knowledge, company policies, and team-wide context.

Parameters

customer_id
string
required
The customer identifier to fetch context for.
conversation_id
string
Optional conversation identifier. When provided, results are biased toward memories relevant to the active conversation.
search_query
string | string[]
One or more search queries to find relevant customer memories. If omitted, returns the most recent and highest-confidence customer-scoped memories.
max_results
integer
Maximum number of memory items to return. Defaults to 10. Maximum 50.
types
string[]
Filter results to specific memory types. If omitted, all types are included.
ValueDescription
factFactual information about the customer organization
preferenceCustomer organizational preferences
episodeSignificant events within the customer organization
emotionSentiment and emotional context within the organization
temporal_eventTime-bound events (project deadlines, fiscal year, etc.)
mode
string
Retrieval mode that controls the speed-quality tradeoff.
ValueDescription
fastVector search only. Lowest latency (~50-100ms). Default.
accurateFull vector + graph + re-ranking. Highest quality (~200-500ms).

Returns

A ContextResponse with the following fields:
facts
array
Array of fact memories relevant to the query.
preferences
array
Array of preference memories.
episodes
array
Array of episode memories.
emotions
array
Array of emotion memories.
metadata
object
Response metadata including total_results, query_time_ms, tokens_used, scope, and mode.

Example

from maximem_synap import MaximemSynapSDK

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

context = await sdk.customer.context.fetch(
    customer_id="cust_acme_corp",
    search_query=["project management tools", "engineering stack"],
    max_results=5,
    types=["fact", "preference"],
    mode="accurate",
)

for fact in context.facts:
    print(f"[{fact.confidence:.2f}] {fact.content}")
Response
{
  "facts": [
    {
      "id": "mem_cust_f1a2b3c4",
      "content": "Acme Corp uses Jira for project management and Slack for communication",
      "confidence": 0.94,
      "entities": [
        { "canonical_name": "Acme Corp", "type": "organization", "entity_id": "ent_acme001" }
      ],
      "source": {
        "ingestion_id": "ing_cust_7a8b9c0d",
        "document_type": "ai-chat-conversation",
        "document_created_at": "2025-01-12T14:30:00Z"
      },
      "relevance_score": 0.92,
      "scope": "customer"
    },
    {
      "id": "mem_cust_d5e6f7a8",
      "content": "Engineering team uses Python 3.11 and PostgreSQL for all services",
      "confidence": 0.91,
      "entities": [
        { "canonical_name": "Acme Corp Engineering", "type": "team", "entity_id": "ent_acme_eng" }
      ],
      "source": {
        "ingestion_id": "ing_cust_0a9b8c7d",
        "document_type": "document",
        "document_created_at": "2025-01-08T09:00:00Z"
      },
      "relevance_score": 0.88,
      "scope": "customer"
    }
  ],
  "preferences": [
    {
      "id": "mem_cust_b9c0d1e2",
      "content": "Team prefers detailed code reviews over quick approvals",
      "confidence": 0.87,
      "entities": [],
      "source": {
        "ingestion_id": "ing_cust_7a8b9c0d",
        "document_type": "ai-chat-conversation",
        "document_created_at": "2025-01-12T14:30:00Z"
      },
      "relevance_score": 0.79,
      "scope": "customer"
    }
  ],
  "episodes": [],
  "emotions": [],
  "metadata": {
    "total_results": 3,
    "query_time_ms": 187,
    "tokens_used": 456,
    "scope": {
      "customer_id": "cust_acme_corp",
      "client_id": "cli_a1b2c3d4e5f67890"
    },
    "mode": "accurate"
  }
}
Customer-scoped memories take priority over client-scoped memories when they cover the same topic, following the scope chain priority rules. To merge customer and client context in a single call, use sdk.context.fetch.

Raises

  • InvalidInputError — when mode is not "fast" or "accurate".
  • SDKNotInitializedError — when called before await sdk.initialize().
  • AuthenticationError — when the API key is invalid or revoked.
  • ContextNotFoundError — when customer_id does not exist for this instance.

See also