Skip to navigation

Python SDK

livingbrain — sync and async clients with Pydantic v2 models.

Generated by Fern

Install

pip install livingbrain

Requires Python 3.8+.

Usage

import os
from livingbrain import LivingBrain
client = LivingBrain(
api_key=os.environ["LIVING_BRAIN_API_KEY"],
subject_id="3f2b8c1e-7a4d-4e9b-9c2a-5d6e7f8a9b0c",
)
brain = client.brains.create(name="Research")
client.captures.capture(
brain_id=brain.id,
kind="note",
content="Worth remembering.",
)
for page in client.workspace.list_pages(brain_id=brain.id):
print(page.title)

Async

AsyncLivingBrain mirrors the sync surface exactly:

import asyncio
from livingbrain import AsyncLivingBrain
async def main():
client = AsyncLivingBrain(subject_id="3f2b8c1e-7a4d-4e9b-9c2a-5d6e7f8a9b0c")
brains = await client.brains.list()
async for page in await client.workspace.list_pages(brain_id=brains[0].id):
print(page.title)
asyncio.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.slackSlack installation, OAuth, and channel bindings
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:

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

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

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

Errors

from livingbrain.core.api_error import ApiError
from livingbrain.errors import NotFoundError
try:
client.workspace.get_page(brain_id=brain_id, slug=slug)
except NotFoundError:
page = None
except ApiError as err:
print(err.status_code, err.body)

See Errors for the full table.

Request options

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

Raw responses

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

Custom httpx client

import httpx
from livingbrain import LivingBrain
client = LivingBrain(
api_key=api_key,
subject_id="3f2b8c1e-7a4d-4e9b-9c2a-5d6e7f8a9b0c",
httpx_client=httpx.Client(proxy="http://localhost:8080", timeout=20.0),
)