Skip to main content

The Brixo Python SDK

Project description

Brixo Python SDK

The Brixo Python SDK lets you instrument AI agents and capture high-quality interaction traces for analysis in the Brixo platform. It is designed to be lightweight, explicit, and easy to integrate into existing agent code.


Compatibility

  • Python 3.10+

Security advisory (January 27, 2026)

We currently ignore CVE-2026-0994 in pip-audit because there is no fixed protobuf release yet. The advisory reports the issue affects all protobuf versions up to 6.33.4, and PyPI shows 6.33.4 as the latest release (uploaded January 12, 2026). We will remove the ignore once a patched release is available.

References:


Installation

Install the SDK from PyPI:

pip install brixo

Authentication

Create an API key

  1. Create a Brixo account @ https://app.brixo.com/sign_up
  2. Once logged in, generate a new API key from the instructions page
  3. Export it as an environment variable:
export BRIXO_API_KEY=<your_api_key>

The Brixo SDK will automatically read this value at runtime.


Quickstart (copy/paste)

Create a minimal file that instruments a single interaction:

export BRIXO_API_KEY=<your_api_key>
cat > main.py <<'PY'
from brixo import Brixo

Brixo.init(
    app_name="my-app",
    environment="development",
    agent_version="1.0.0",
)

@Brixo.interaction("Hello World Interaction")
def handle_user_input(user_input: str):
    Brixo.begin_context(
        user={"id": "1", "name": "Jane Doe"},
        input=user_input,
    )
    response = f"You said: {user_input}"
    Brixo.end_context(output=response)
    print(response)

def main():
    while True:
        user_input = input("User: ")
        handle_user_input(user_input)

if __name__ == "__main__":
    main()
PY
python main.py

What you should see:


Instrumentation Quickstart

The typical flow is:

  1. Initialize Brixo once at application startup
  2. Wrap each user interaction with @Brixo.interaction
  3. Attach context (user, customer, session, input, output)
  4. Let the interaction finish so traces can be flushed

Example

Below is a minimal but complete example that instruments a single agent interaction loop.

Create a file called main.py:

# --- Brixo SDK import ---
# Import the Brixo SDK so we can instrument and send interaction traces to Brixo.
from brixo import Brixo
from my_agent import agent

# --- Brixo interaction boundary ---
# Mark ONE bounded user interaction (one request -> one response) so Brixo can group
# spans/attributes into a single trace and flush it when this function returns.

@Brixo.interaction("Main Agent Execution")
def handle_user_input(user_input: str):

    # --- Brixo context start ---
    # Attach contextual metadata to the current trace
    Brixo.begin_context(
        account={"id": "1", "name": "ACME, Inc."},
        user={"id": "1", "name": "John Doe"},
        session_id="session-123",
        metadata={"foo": "bar"},
        input=user_input,
    )

    response = agent.invoke(
        {"messages": [{"role": "user", "content": user_input}]}
    )

    handle_agent_response(response)


def handle_agent_response(response):
    """Extracts the final agent output and updates the trace."""

    final_text = response["messages"][-1].content

    # --- Brixo context update ---
    # Add/update attributes after the agent has produced output.
    Brixo.end_context(output=final_text)

def main():
    # --- Brixo SDK initialization ---
    # Initialize once at startup, before any instrumented code runs.
    Brixo.init(
        app_name="my-app",
        environment="production",
        agent_version="1.0.0",
    )

    while True:
        user_input = input("User: ")
        handle_user_input(user_input)

if __name__ == "__main__":
    main()

Run the example:

python main.py

Key Concepts

Concepts at a glance

  • Interaction boundary: one user request -> one response
  • Context lifecycle: begin_context early, update_context for mid-flight, end_context to close
  • Flush timing: traces are exported when the interaction function returns

Brixo.init(...)

Initializes the SDK. Call once at application startup.

Arguments and value formats:

  • app_name: str logical name for your application or agent; cannot be None
  • environment: str such as development, staging, production; cannot be None
  • api_key: str or None; defaults to BRIXO_API_KEY
  • agent_version: str or None agent version identifier
  • filter_openinference_spans: bool or None to drop OpenInference spans on export
  • filter_traceloop_spans: bool or None to drop Traceloop spans on export

Usage:

Brixo.init(
    app_name="my-app",
    environment="production",
    api_key="brx_123456",
    agent_version="1.0.0",
    filter_openinference_spans=True,
    filter_traceloop_spans=True,
)

@Brixo.interaction(name)

Marks a single, bounded user interaction.

Arguments and value formats:

  • name: str or None descriptive interaction name

Usage:

@Brixo.interaction("Main Agent Execution")
def handle_user_input(user_input: str):
    ...

Guidelines:

  • Use one interaction per user request
  • The function must terminate (no infinite loops)
  • Choose descriptive names - they improve trace readability

Brixo.begin_context(...)

Attaches structured metadata to the current interaction trace.

Arguments and value formats:

  • account: dict or None with any of: id, name, logo_url, website_url (all str)
  • user: dict or None with any of: id, name, email (all str)
  • session_id: str or None logical session identifier
  • metadata: dict or None of arbitrary key/value data
  • input: str or None raw user input
  • output: str or None output if available at start

Usage:

Brixo.begin_context(
    account={
        "id": "acct_123",
        "name": "ACME, Inc.",
        "logo_url": "https://example.com/logo.png",
        "website_url": "https://acme.com",
    },
    user={
        "id": "user_456",
        "name": "Jane Doe",
        "email": "jane@example.com",
    },
    session_id="session-123",
    metadata={"plan": "pro", "feature": "search"},
    input="Find me the latest quarterly report.",
    output="",
)

Brixo.update_context(...)

Adds or updates attributes after the interaction has started and leaves the interaction context open.

Arguments and value formats:

  • account: dict or None with any of: id, name, logo_url, website_url (all str)
  • user: dict or None with any of: id, name, email (all str)
  • session_id: str or None logical session identifier
  • metadata: dict or None of arbitrary key/value data
  • input: str or None raw user input
  • output: str or None output or intermediate result

Usage:

Brixo.update_context(
    account={
        "id": "acct_123",
        "name": "ACME, Inc.",
        "logo_url": "https://example.com/logo.png",
        "website_url": "https://acme.com",
    },
    user={
        "id": "user_456",
        "name": "Jane Doe",
        "email": "jane@example.com",
    },
    session_id="session-123",
    metadata={"latency_ms": 1200, "tool": "search"},
    input="Find me the latest quarterly report.",
    output="Intermediate tool summary...",
)

Typical use cases:

  • Derived metrics
  • Tool results or summaries

Brixo.end_context(...)

Adds or updates attributes after the interaction has started and then explicitly closes the interaction context.

Arguments and value formats:

  • account: dict or None with any of: id, name, logo_url, website_url (all str)
  • user: dict or None with any of: id, name, email (all str)
  • session_id: str or None logical session identifier
  • metadata: dict or None of arbitrary key/value data
  • input: str or None raw user input
  • output: str or None final agent output

Usage:

Brixo.end_context(
    account={
        "id": "acct_123",
        "name": "ACME, Inc.",
        "logo_url": "https://example.com/logo.png",
        "website_url": "https://acme.com",
    },
    user={
        "id": "user_456",
        "name": "Jane Doe",
        "email": "jane@example.com",
    },
    session_id="session-123",
    metadata={"feedback_score": 5},
    input="Find me the latest quarterly report.",
    output="Here is the latest quarterly report summary...",
)

Typical use cases:

  • Final agent output

Best Practices

  • One interaction = one user request
  • Keep interaction functions short and bounded
  • Use descriptive interaction names
  • Attach inputs early and outputs late
  • Initialize Brixo early at startup; if you rely on auto-instrumentation, import those libraries after Brixo.init(...)

Troubleshooting

  • Missing traces: Confirm BRIXO_API_KEY is set and that Brixo.init(...) runs before instrumented code.
  • Nothing in Live View: Check https://app.brixo.com/traces/live and allow a few seconds after each interaction.
  • No internet or proxy issues: Ensure your runtime can reach app.brixo.com.

Support

If you have questions or run into issues:

Happy instrumenting 🚀

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brixo-0.1.6.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brixo-0.1.6-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file brixo-0.1.6.tar.gz.

File metadata

  • Download URL: brixo-0.1.6.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for brixo-0.1.6.tar.gz
Algorithm Hash digest
SHA256 301b98ae22e586016c2708fc7edc86f4723e7d9b4b7b71cfc0eb68c883aee468
MD5 81de61b9d910327f73bb23916cd7ef11
BLAKE2b-256 d72e2b755a7e68353558ee44a5abd3c45536ffcb89596216b732d67e5ffe64ea

See more details on using hashes here.

File details

Details for the file brixo-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: brixo-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for brixo-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ea61b9cb993015a5adfd3e88bc5d2d6fd3628841b31839e51f915c14b6d6fff6
MD5 e50d140fb77a3de12187f90f34763743
BLAKE2b-256 dbf6fa8e535a6edfc38910501908a9e2ea112c491732afb0f17d1c428cfb7637

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page