Skip to main content

Official Python SDK for the Libro AI memory infrastructure.

Project description

Libro Logo

Libro Python SDK

The official Python SDK for Libro — The User Context Layer for AI Applications.
Transform conversations into structured, evolving user understanding. Build AI agents with infinite memory using our zero-cost local vectorization, semantic deduplication, and drop-in SDK.

PyPI Version Python Versions License


✨ Features

  • ⚡️ Blazing Fast Ingestion: Edge-optimized architecture guarantees <300ms ingestion latency.
  • 🧠 Zero Pipeline Changes: Seamlessly retrieve memories to pass into your LangChain or LlamaIndex prompts.
  • 🛡️ Full Privacy Control: Bring your own Supabase. We don't store your vectors, you do.
  • ⏱️ Automated Context Trimming: Never overflow your LLM context window again.

📦 Installation

pip install libro-sdk

🚀 Quick Start

1. Initialize the Client

from libro import LibroClient
import os

# Initialize the client with your API key
client = LibroClient(
    api_key=os.environ.get("LIBRO_API_KEY"), 
    base_url="https://libro.co.in" # Optional: defaults to production
)

2. Ingest Memory

Save facts, preferences, or chunks of conversation into a user's memory brain.

response = client.ingest(
    user_id="user-12345",
    text="User prefers Python over Java for machine learning.",
    metadata={"source": "slack_integration"}
)

print(response["memory"]["id"]) # 'f3b974d0-...'

3. Retrieve Context

Retrieve the most relevant memories for a user before passing context to an LLM like GPT-4 or Claude.

context_data = client.get_context(
    user_id="user-12345",
    query="What programming language should I use for their new ML project?"
)

print(context_data["context"]) 
# -> "[Memory 1] (Relevance: 85.2%): User prefers Python over Java for machine learning."

4. Update Memory

When a user's preferences change, update their specific memory block directly.

client.update(
    memory_id="memory-uuid-1234",
    content="User prefers Python for ML, but uses Rust for high-performance systems."
)

5. Forget (GDPR Compliance)

Fully delete a user's memory or specific blocks to comply with data deletion requests.

# Delete a specific memory
client.forget(memory_id="memory-uuid-1234")

# Delete ALL memories for a user (GDPR "Right to be Forgotten")
client.forget(user_id="user-12345")

🏗️ How It Works Under The Hood

Unlike managed monoliths, Libro uses an Edge-first architecture. Our SDK hits your API, and the vectorization happens instantly on the edge via a lightweight embedding sidecar (nomic-embed-text-v1.5), before being stored directly in your own Supabase instance using pgvector HNSW indexes.

Zero vendor lock-in. Full data sovereignty.


Libro — Memory that never forgets.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libro_sdk-0.1.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libro_sdk-0.1.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file libro_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: libro_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for libro_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 dc82f97aff0846624e17d78e34f40d278eca241b770288c090af0405a47e66ea
MD5 1374c19c5dd0723b2b31bdaaa1305aea
BLAKE2b-256 86c03dbd727ad024381d10b9c8f475d47fb0ab2452e01b1093c7e11be2501f75

See more details on using hashes here.

File details

Details for the file libro_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: libro_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for libro_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f12817383a3684d94bf1eeb9757fc78502ce7d699e860e6d7de8c16a9150c2f
MD5 a695e34a1a72e2756bcefe5522e5d27e
BLAKE2b-256 5ef5b1d4c3065a81bb791b78f27083d2a30ee3c40bd6b7fb4b53cb76ca440438

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page