Skip to main content

Python SDK for the WhiteBox AI decision observability API

Project description

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

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

whiteboxhq-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

whiteboxhq-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file whiteboxhq-0.1.0.tar.gz.

File metadata

  • Download URL: whiteboxhq-0.1.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for whiteboxhq-0.1.0.tar.gz
Algorithm Hash digest
SHA256 caf63f1755ddbc2b209163fb760eeae2c41544aa6612ccda50f4b7cb7d3066c3
MD5 fe18067caecda3c7a49f952a42b1a0bd
BLAKE2b-256 94be100ca8366a6ce7013bb78053805b34c5c14a327e699a09e78d6f23d30257

See more details on using hashes here.

File details

Details for the file whiteboxhq-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: whiteboxhq-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for whiteboxhq-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2e846b683b0a7f180be74431d5ea90a69c65fd86918e711c60788b60858b565
MD5 0238fc091e0eec25fec2c7984744cc40
BLAKE2b-256 3dc1f06775bed7d5721f652c8b2128e79ae315768d4b2d71fe905eb5c8f15b20

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