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.1.tar.gz (9.8 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.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: whiteboxhq-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 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.1.tar.gz
Algorithm Hash digest
SHA256 70c3044b5872184b4a0eb0ae5b562787c80b190c9c99fec402ebdbb2bc81ce06
MD5 40c830b1dd84ceeb18b4791d83456c57
BLAKE2b-256 53de4304b8b142fb7c147901802feb61e149f7dfd5d96e84e643ef358b013cd6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: whiteboxhq-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bc2400cdef4f5954491a742d5937fabfdbe46f68d677ceb173c46ae725bcad56
MD5 d879aadc39c7f37631ea4598a323c1e0
BLAKE2b-256 8b17d6b3fa47235556dcdc24a7352b2fd8a443d3bcb651906d8153fbe601d29d

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