SDKs
Official client libraries for integrating qbrix into your applications.
| Language | Package | Status |
|---|---|---|
| Python | qbrix | Available |
| JavaScript / TypeScript | @qbrix/sdk | Coming soon |
Python SDK
Typed sync and async clients for pool/experiment/gate management and the agent select/feedback loop.
Installation
pip install qbrixRequires 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 Var | Default | Description |
|---|---|---|
QBRIX_API_KEY | None | API key |
QBRIX_BASE_URL | http://localhost:8080 | Proxy service URL |
QBRIX_TIMEOUT | 30.0 | Request timeout (seconds) |
QBRIX_MAX_RETRIES | 3 | Retry 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 matchedError 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
| Resource | Methods |
|---|---|
pool | create, get, list, delete |
experiment | create, get, list, delete |
gate | create, get, update, delete |
agent | select, feedback |
JavaScript / TypeScript SDK
Coming soon. The JS SDK will provide the same resource coverage as the Python SDK with full TypeScript types.