SDKs & API

Python

The MemLab Python SDK wraps the gateway REST API with typed helpers for ingesting Episodic Memory and running hybrid retrieval. Mint an API key in the dashboard, then follow the steps below.

  1. 1

    Install the SDK

    Add MemLab to your project with pip.

    bash
    pip install memlab-ai
  2. 2

    Initialize the client

    Configure the client with the API key you minted in the dashboard.

    python
    from memlab import MemLabClient
    
    client = MemLabClient(
        api_key="your-api-key",
        base_url="https://duevlcjdbpgye.cloudfront.net",
    )
  3. 3

    Ingest an Episodic Memory

    Send raw content to be extracted into Semantic Memory.

    python
    result = client.add(
        content="My name is Alice and I love hiking.",
        episodic_memory_type="MESSAGE",
    )
    print(result)
  4. 4

    Search Semantic Memory

    Query for facts ranked by relevance.

    python
    results = client.semantic_memories.search(query="What do I like?")
    for r in results:
        print(r["semantic_memory"]["content"])