Skip to main content

littlebigbrain Python SDK

Python client for little big brain, a search platform for AI applications such as chatbots, search tools, and agents. Load facts, query their relationships, and keep the data version behind an answer so you can check it later.

The package supports Python 3.10+ and provides synchronous and asynchronous clients built on httpx. Generated Pydantic models are available in lbb.models.

Documentation · Quickstart · Issues

Install

pip install littlebigbrain

The package is installed as littlebigbrain and imported as lbb.

Load facts and run a query

Create a stack in the console and open Connect. Copy its complete endpoint and a stack API key:

export LBB_URL="https://<your-complete-stack-host>"
export LBB_API_KEY="<your-stack-api-key>"

This example creates a graph named quickstart on its first write. It stores three facts: a service writes to a database, and each has a label. The data uses Resource Description Framework (RDF), where each line names a subject, a relationship, and a value or another record. SPARQL is the query language for those facts.

Save as quickstart.py, then run python3 quickstart.py:

import os

from lbb import LbbClient

facts = """
<https://example.org/auth-service> <https://example.org/writesTo> <https://example.org/user-db> .
<https://example.org/auth-service> <http://www.w3.org/2000/01/rdf-schema#label> "Auth Service" .
<https://example.org/user-db> <http://www.w3.org/2000/01/rdf-schema#label> "User Database" .
"""

query = """
    SELECT ?service ?database WHERE {
        ?s <https://example.org/writesTo> ?db .
        ?s <http://www.w3.org/2000/01/rdf-schema#label> ?service .
        ?db <http://www.w3.org/2000/01/rdf-schema#label> ?database .
    } ORDER BY ?service ?database LIMIT 10
"""

with LbbClient(
    os.environ["LBB_URL"],
    api_key=os.environ["LBB_API_KEY"],
    graph="quickstart",
) as lbb:
    imported = lbb.graph("quickstart").facts.import_rdf(
        facts, format="ntriples", idempotency_key="sdk-quickstart-v1"
    )

    results = lbb.sparql(
        query,
        consistency="strong",
        min_indexed_seq=imported["committed_commit_seq"],
    )
    for row in results:
        print(f"{row['service']} -> {row['database']}")

On a fresh graph, this prints:

Auth Service -> User Database

The query follows the stored relationship between the service and database. consistency="strong" makes the new facts available to this read without waiting for a background index job. Reads default to eventual consistency, so omit this option only when an earlier version is acceptable.

The idempotency key makes repeating the same import safe. Use a new key if you change the data.

Async client

AsyncLbbClient provides the same methods with await. After running the quickstart, this script reads its data:

import asyncio
import os

from lbb import AsyncLbbClient


async def main():
    async with AsyncLbbClient(
        os.environ["LBB_URL"],
        api_key=os.environ["LBB_API_KEY"],
        graph="quickstart",
    ) as lbb:
        result = await lbb.sparql(
            "ASK { ?s <https://example.org/writesTo> ?db }",
            consistency="strong",
        )
        print(result.boolean)  # True


asyncio.run(main())

Next steps

The RDF and JSON guides use different write workflows. Choose one when creating a graph; a graph first written through RDF import does not accept facts.create or JSON record imports.

Errors and retries

Failed HTTP requests raise LbbError, with a status, error code, message, and request ID. Use raw_request() when you also need response headers or timing.

Safe reads and writes with an idempotency key retry rate limits, retryable server errors, and network failures. Retries respect Retry-After and use a 60-second budget by default. See the client reference for timeout and retry options.

Development

From a clone of this repository:

python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/python -m ruff check lbb tests
.venv/bin/python -m mypy lbb
.venv/bin/python -m pytest tests

lbb/models.py is generated from the API contract. See CONTRIBUTING.md for changes to generated models.

License

Apache-2.0.

Release files for littlebigbrain 0.15.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for littlebigbrain 0.15.0
File Size Uploaded
littlebigbrain-0.15.0.tar.gz 125.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for littlebigbrain 0.15.0
File Interpreter ABI Platform
littlebigbrain-0.15.0-py3-none-any.whl Python 3 none any Details

Total release size: 232.6 kB

Release files / littlebigbrain-0.15.0.tar.gz

Download URL littlebigbrain-0.15.0.tar.gz
Size 125.8 kB
Tags Source
SHA-256 checksum
How to use checksums
bd3a7f83b0fd562262770236082c25c75807ec87ac8fd6563af6412c3b6a2574
BLAKE2b-256 checksum
How to use checksums
5bba5b626907b040ab2834a6b0b748e3a7f3cbcce387dd672acc1b0adab51cf4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / littlebigbrain-0.15.0-py3-none-any.whl

Download URL littlebigbrain-0.15.0-py3-none-any.whl
Size 106.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2ed78efba781b4cac38a8e123df6696aab1cfe4c06e5b8b24ac330acc62cea4
BLAKE2b-256 checksum
How to use checksums
6cc6f79b73f761bbfaa01dcb419ac07a2e5830e331e1f9313f519ab6e9cd789a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.15.0 This release

2 release files

0.14.0

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page