NewMCP ServerView docs
API

Python SDK

Official Python SDK for LH42 with full support for async operations and type hints.

8 min readUpdated 2026-01-19

Python SDK

The official Python SDK for LH42 provides a clean, Pythonic interface to all API features.

Installation

bash
pip install lakehouse42-sdk

Quick Start

python
from lakehouse42 import LakehouseClient

client = LakehouseClient(api_key="YOUR_API_KEY")

# Search
results = client.search("quarterly revenue")
for r in results:
    print(f"{r.title}: {r.score}")

Async Support

python
from lakehouse42 import AsyncLakehouseClient
import asyncio

async def main():
    client = AsyncLakehouseClient(api_key="YOUR_API_KEY")
    results = await client.search("quarterly revenue")
    return results

asyncio.run(main())

Type Hints

Full type annotations for IDE support:

python
from lakehouse42 import LakehouseClient, SearchResult

client = LakehouseClient()
results: list[SearchResult] = client.search("query")

Error Handling

python
from lakehouse42 import LakehouseClient, LakehouseError, RateLimitError

try:
    results = client.search("query")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except LakehouseError as e:
    print(f"API error: {e.message}")

Configuration

python
client = LakehouseClient(
    api_key="...",
    base_url="https://custom.endpoint.com",
    timeout=30,
    max_retries=3
)

Document Management

python
# Upload
with open("doc.pdf", "rb") as f:
    doc = client.documents.upload(f, metadata={"dept": "legal"})

# List
docs = client.documents.list(limit=10)

# Delete
client.documents.delete("doc_123")