Integration · SDK
Python
The Python client ships on PyPI as offpolicy. asyncio-native, type-hinted, and includes the off-policy estimator library (IPS / SNIPS / DM / DR / Switch-DR) under the offpolicy[estimators] extra so growth-data teams can verify our doubly-robust readout on their own warehouse.
The contract
What flows in
- Decide requests: experiment, user_id, context dict (frozen at decision time)
- Reward events: user_id, experiment, reward_spec key, value (idempotent by event_id)
- Health pings: kept open for clock-drift detection
What flows out
- Variant assignment + propensity logged atomically with the decision
- Batch decide for slate ranking · up to 256 decisions per round-trip
Setup
- 01pip install offpolicy (add [estimators] if you want to verify our DR readout)
- 02Initialise with your live or test API key — health check verifies clock drift on init
- 03Replace your existing assignment call with client.decide(experiment, user_id, context)
- 04Emit rewards through client.reward(user_id, experiment, reward_spec, value)
- 05Verify reproduces our DR estimate locally via offpolicy.estimators.dr(...)
When to reach for it
Use the Python client whenever your decision is made server-side — FastAPI route handlers, Django views, Celery workers, or notebook-driven batch jobs. Both async (recommended) and sync entry points are exposed; the async client uses httpx and aligns with FastAPI's event loop.
For client-side decisions on a Python-running data-plane (rare), use the same client — the wire format is identical.
Estimator library
The estimator suite ships open-source under MIT. offpolicy.estimators contains ips, snips, dm, dr, and switch_dr with 1,000-bootstrap CIs and ESS computation included.
Customers commonly reproduce our doubly-robust lift number on a Snowflake or BigQuery extract before signing the first invoice. The math is textbook (Horvitz-Thompson, Dudík, Wang — cited in the source); the moat is the propensity-logged production stack, not the formulas.
Other sdk integrations
Wire Python in a 30-minute call.
We pair with your engineer, ship the integration live, and run the first decision on your stack.