WhiteBox Python SDK
Python client for the WhiteBox AI decision observability API.
Installation
pip install whitebox
Quick Start
from whitebox import Whitebox
client = Whitebox(api_key="wb_your_api_key")
# Make a single decision
decision = client.decide(
input="The customer wants to cancel their subscription and get a refund",
options=["approve_refund", "offer_discount", "escalate_to_manager"],
)
print(decision.value) # "approve_refund"
print(decision.confidence) # 0.92
print(decision.verdict) # "consensus"
Fast Mode
Use fast mode for lower-latency decisions with fewer model runs:
decision = client.decide_fast(
input="Is this email spam?",
options=["spam", "not_spam"],
)
Bulk Decisions
Submit up to 100 decisions in a single request:
batch = client.decide_bulk(
items=[
{"input": "Unauthorized charge on my card"},
{"input": "When does my subscription renew?"},
{"input": "I want to upgrade my plan"},
],
options=["billing", "account", "upgrade"],
webhook_url="https://example.com/webhook",
)
print(batch.id) # "batch_abc123"
print(batch.total) # 3
# Poll for results
batch = client.get_batch(batch.id)
if batch.status == "completed":
results = client.get_batch_results(batch.id)
Human Review
When a decision is escalated (low confidence), resolve it manually:
reviews = client.list_reviews()
for review in reviews:
print(review.input, review.options, review.confidence)
# Resolve a review
client.resolve_review(review_id=42, answer="approve_refund")
Error Handling
from whitebox import (
WhiteboxError,
AuthenticationError,
RateLimitError,
InsufficientCreditsError,
)
try:
decision = client.decide(input="...", options=["a", "b"])
except AuthenticationError:
print("Check your API key")
except InsufficientCreditsError:
print("Add credits at https://whiteboxhq.ai/billing")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except WhiteboxError as e:
print(f"API error {e.status_code}: {e}")
Documentation
Full API docs: https://whiteboxhq.ai/docs
Metadata
Release files for whiteboxhq 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| whiteboxhq-0.1.1.tar.gz | 9.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| whiteboxhq-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.6 kB
Release files / whiteboxhq-0.1.1.tar.gz
| Download URL | whiteboxhq-0.1.1.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70c3044b5872184b4a0eb0ae5b562787c80b190c9c99fec402ebdbb2bc81ce06
|
|
BLAKE2b-256 checksum How to use checksums |
53de4304b8b142fb7c147901802feb61e149f7dfd5d96e84e643ef358b013cd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / whiteboxhq-0.1.1-py3-none-any.whl
| Download URL | whiteboxhq-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc2400cdef4f5954491a742d5937fabfdbe46f68d677ceb173c46ae725bcad56
|
|
BLAKE2b-256 checksum How to use checksums |
8b17d6b3fa47235556dcdc24a7352b2fd8a443d3bcb651906d8153fbe601d29d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|