Cookbook
Short recipes for the whitecircle Python SDK. Every snippet uses the real API; concepts and the HTTP reference
live at https://whitecircle.com/docs.
Read this in two minutes
- Skim "The model" below: it is everything the SDK assumes you know.
- Read Getting started for configuration and how to read a result.
- Jump to the page for your task in the table. Pages are independent.
- If a check returns no verdict (
result.checkedisFalse), read Metadata and Conditions.
The model
- You send Events: a user message, an assistant reply, a tool call, an agent step, an image.
- Each Event belongs to an Environment (
environment_id, required on every Events call). - Active Conditions on that Environment match the Event's
metadataand select Policies. No match, no Policies, no verdict. - You get
result.flagged, a result per Policy inresult.policies, andresult.checkedto tell "passed" from "not checked". - Events with the same
external_session_idform a conversation: earlier Events are context for later ones.
Python
from whitecircle import Event, WhiteCircle
client = WhiteCircle() # WHITECIRCLE_API_KEY, WHITECIRCLE_ENVIRONMENT_ID
result = client.events.check(
Event.user("Can you prescribe antibiotics?", metadata={"app": "pharmacy-bot"}),
external_session_id="conversation_456",
)
print(result.checked, result.flagged, result.note)