qbrixqbrix

SDKs

Official client libraries for integrating qbrix into your applications.

LanguagePackageStatus
PythonqbrixAvailable
JavaScript / TypeScript@qbrix/sdkComing soon

Python SDK

Typed sync and async clients for pool/experiment/gate management and the agent select/feedback loop.

Installation

pip install qbrix

Requires Python 3.10+.

Module-Level Usage

Set your credentials as environment variables and call resources directly — no client instantiation needed:

export QBRIX_API_KEY="optiq_xxx"
export QBRIX_BASE_URL="https://cloud.qbrix.io"
import qbrix
 
pool = qbrix.pool.create(
    name="homepage-buttons",
    arms=[{"name": "blue"}, {"name": "green"}, {"name": "red"}],
)
 
exp = qbrix.experiment.create(
    name="button-color-test",
    pool_id=pool.id,
    policy="BetaTSPolicy",
)
 
result = qbrix.agent.select(
    experiment_id=exp.id,
    context={"id": "user-123", "metadata": {"country": "US"}},
)
 
qbrix.agent.feedback(request_id=result.request_id, reward=1.0)

Explicit Client

For full control over configuration or lifecycle, instantiate the client directly:

from qbrix import Qbrix
 
with Qbrix(api_key="optiq_xxx", base_url="https://cloud.qbrix.io") as client:
    pool = client.pool.create(
        name="homepage-buttons",
        arms=[{"name": "blue"}, {"name": "green"}, {"name": "red"}],
    )
    result = client.agent.select(
        experiment_id="exp-uuid",
        context={"id": "user-123"},
    )
    client.agent.feedback(request_id=result.request_id, reward=1.0)

Async

from qbrix import AsyncQbrix
 
async with AsyncQbrix(api_key="optiq_xxx") as client:
    result = await client.agent.select(
        experiment_id="exp-uuid",
        context={"id": "user-456"},
    )
    await client.agent.feedback(request_id=result.request_id, reward=1.0)

Configuration

Constructor kwargs take priority over environment variables, which take priority over defaults.

Env VarDefaultDescription
QBRIX_API_KEYNoneAPI key
QBRIX_BASE_URLhttp://localhost:8080Proxy service URL
QBRIX_TIMEOUT30.0Request timeout (seconds)
QBRIX_MAX_RETRIES3Retry count on 429/5xx

Feature Gates

Attach a feature gate to control rollout before the bandit kicks in:

import qbrix
 
qbrix.gate.create(
    experiment_id=exp.id,
    enabled=True,
    rollout_percentage=80.0,
    default_arm_id=pool.arms[0].id,
    rules=[
        {"key": "plan", "operator": "==", "value": "enterprise", "arm_id": pool.arms[1].id},
    ],
)
 
result = qbrix.agent.select(
    experiment_id=exp.id,
    context={"id": "user-789", "metadata": {"plan": "enterprise"}},
)
print(result.is_default)  # True — gate matched

Error Handling

import qbrix
from qbrix import NotFoundError, RateLimitedError
 
try:
    exp = qbrix.experiment.get("nonexistent-id")
except NotFoundError as e:
    print(f"Not found: {e.detail}")
except RateLimitedError as e:
    print(f"Retry after {e.retry_after}s")

Resources

ResourceMethods
poolcreate, get, list, delete
experimentcreate, get, list, delete
gatecreate, get, update, delete
agentselect, feedback

JavaScript / TypeScript SDK

Coming soon. The JS SDK will provide the same resource coverage as the Python SDK with full TypeScript types.