Skip to main content

Flight recorder SDK for AI agents — zero-dependency BLACKBOX client

Project description

BLACKBOX SDK

Zero-dependency Python SDK for recording AI agent runs into BLACKBOX — the flight recorder for AI agents.

Install

pip install blackbox-sdk

Or from source:

cd sdk && pip install -e .

Two-line integration

import blackbox_sdk as bb

bb.configure(api_url="https://your-blackbox.railway.app", api_key="<agent-key>")

with bb.run("invoice_review_4821", model="claude-sonnet-4-6", system_prompt="You are…") as run:
    run.reasoning("Analyzing the invoice for anomalies…")
    result = call_tool("ocr_extract", path="/tmp/invoice.pdf")
    run.tool_call("ocr_extract", {"path": "/tmp/invoice.pdf"}, result=result)
    run.output("Total: $4,200. No anomalies detected.", tokens_in=512, tokens_out=38, cost_usd=0.0024)
    run.seal()

Every event is hashed and chained. Replay, diff, and audit any run in the BLACKBOX UI.

Configuration

Method Priority
bb.configure(api_url=..., api_key=...) 1 (highest)
BLACKBOX_API_URL / BLACKBOX_AGENT_KEY env vars 2
Defaults (http://localhost:8000, no key) 3

API reference

bb.run(run_id?, *, model, system_prompt, tools, sampling, policy_pack)

Returns a RunRecorder context manager. The genesis event is recorded on __enter__. Unhandled exceptions automatically record a fault event before re-raising.

RunRecorder methods

Method Description
run.genesis() Called automatically on enter
run.reasoning(text) Chain-of-thought step
run.tool_call(tool, inputs, result?, latency_ms?) Tool invocation
run.retrieval(query, results, source?) RAG retrieval
run.decision(text) Policy/routing decision
run.output(text, tokens_in?, tokens_out?, cost_usd?, latency_ms?) Final output
run.fault(claim, fault_class?, severity?, description?) Detected hallucination
run.seal(summary?) Close the run chain
run.timed_tool_call(tool, inputs, fn, *args, **kwargs) Auto-timed tool call

Fault classes

Class Meaning
C1 Fabricated value
C2 Fabricated source / citation
C3 Out-of-scope claim
C4 Contradiction with prior context

Environment variables

BLACKBOX_API_URL=https://your-blackbox.railway.app
BLACKBOX_AGENT_KEY=bb_agent_...

OpenTelemetry

BLACKBOX also accepts standard OTLP traces at /v1/otel/traces. See the OTel setup guide.

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

blackbox_sdk-0.3.0.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

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

blackbox_sdk-0.3.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file blackbox_sdk-0.3.0.tar.gz.

File metadata

  • Download URL: blackbox_sdk-0.3.0.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for blackbox_sdk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 46e47d99ff9daafd915bf59aacc53eb2cbb66134ac9cdd370f4030c0830a3349
MD5 7ce9bb33a20e678293aced6b6e0fa788
BLAKE2b-256 443411f8cb1a0a3d7bcbd0736bf22cff194cf51e7bd99372838cd7ecefed49a7

See more details on using hashes here.

File details

Details for the file blackbox_sdk-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: blackbox_sdk-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for blackbox_sdk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e55622a1255bb3a8abbb05e98b9a6bf250fc6a3cd43ed5d76e05910de7442b06
MD5 84ea59c39edf9bf7856fe33e1634b920
BLAKE2b-256 c9e7f4ca3767ee096be04a8164e7bb2e3d7960461042f7a9d1da8710969af839

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