> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.livingbrain.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.livingbrain.com/_mcp/server.

# Python SDK

Generated by Fern

## Install

```bash
pip install livingbrain
```

Requires Python 3.8+.

## Usage

```python
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:

```python
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

| Namespace          | Covers                                                       |
| ------------------ | ------------------------------------------------------------ |
| `client.brains`    | Create, list, update, delete brains; stats; daily briefs     |
| `client.captures`  | Push captures; manage ingest sources                         |
| `client.workspace` | Pages, buckets, connections, changes, search, score, profile |
| `client.webhooks`  | Webhook subscriptions                                        |
| `client.slack`     | Slack installation, OAuth, and channel bindings              |
| `client.telegram`  | Telegram 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:

```python
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:

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

## Errors

```python
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](/docs/errors) for the full table.

## Request options

```python
from livingbrain.core.request_options import RequestOptions

client.brains.list(
    request_options=RequestOptions(max_retries=5, timeout_in_seconds=30)
)
```

## Raw responses

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

## Custom httpx client

```python
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),
)
```