Skip to content

Calling a detector

Once you have created a detector, you can use it by calling it through our Python library.

An detector’s ID is listed on the dashboard. It will look something like this:

68211f82-da64-43f9-85de-35e073c4e3fd

After installing the Haize Labs library, a detector can be called with the following code:

Python
from haizelabs.client import HaizeClient
client = HaizeClient(api_key="<your_api_key>")
response = client.detectors.call(
detector_ids=["68211f82-da64-43f9-85de-35e073c4e3fd"],
messages=[{"role": "user", "content": "hello from haize labs!"}]
)

We get the following response back. Since our input was Hello world, none of the detectors were triggered.

Response
[
DetectorCallResponse(
content_id='478557227c764dc78426478199309824',
detected=False,
detector_id='7c14403c-77c1-4c91-bc6d-a2a9a8f86aad',
score=0.0
)
]

We can now use this response to filter out unwanted content and monitor content categories.