Python SDK

livingbrain — sync and async clients with Pydantic v2 models.

Generated by Fern

Install

$pip install livingbrain

Requires Python 3.8+.

Usage

1import os
2from livingbrain import LivingBrain
3
4client = LivingBrain(
5 api_key=os.environ["LIVING_BRAIN_API_KEY"],
6 subject_id="user_123",
7)
8
9brain = client.brains.create(name="Research")
10
11client.captures.capture(
12 brain_id=brain.id,
13 kind="note",
14 content="Worth remembering.",
15)
16
17for page in client.workspace.list_pages(brain_id=brain.id):
18 print(page.title)

Async

AsyncLivingBrain mirrors the sync surface exactly:

1import asyncio
2from livingbrain import AsyncLivingBrain
3
4async def main():
5 client = AsyncLivingBrain(subject_id="user_123")
6 brains = await client.brains.list()
7
8 async for page in await client.workspace.list_pages(brain_id=brains[0].id):
9 print(page.title)
10
11asyncio.run(main())

Namespaces

NamespaceCovers
client.brainsCreate, list, update, delete brains; stats; daily briefs
client.capturesPush captures; manage ingest sources
client.workspacePages, buckets, connections, changes, search, score, profile
client.webhooksWebhook subscriptions
client.telegramTelegram bot connection

Models

Responses are Pydantic v2 models. Attributes are snake_case; the wire format stays camelCase, and model_dump(by_alias=True) round-trips it:

1from livingbrain.types import Page
2
3page = client.workspace.get_page(brain_id=brain_id, slug="my-page")
4
5page.last_referenced_at # datetime
6page.model_dump(by_alias=True) # {"lastReferencedAt": ..., "brainId": ...}

Request bodies are flattened into keyword arguments, so you rarely construct a model by hand:

1client.brains.update(brain_id=brain_id, name="Renamed", description="")

Errors

1from livingbrain.core.api_error import ApiError
2from livingbrain.errors import NotFoundError
3
4try:
5 client.workspace.get_page(brain_id=brain_id, slug=slug)
6except NotFoundError:
7 page = None
8except ApiError as err:
9 print(err.status_code, err.body)

See Errors for the full table.

Request options

1from livingbrain.core.request_options import RequestOptions
2
3client.brains.list(
4 request_options=RequestOptions(max_retries=5, timeout_in_seconds=30)
5)

Raw responses

1response = client.brains.with_raw_response.list()
2print(response.headers.get("x-request-id"))
3print(response.data)

Custom httpx client

1import httpx
2from livingbrain import LivingBrain
3
4client = LivingBrain(
5 api_key=api_key,
6 subject_id="user_123",
7 httpx_client=httpx.Client(proxy="http://localhost:8080", timeout=20.0),
8)