Guardrails
Rules on what is sent to a model (input) and what it returns (output).
Access it as client.ai.guardrails on a Strongly client, or the same path on AsyncStrongly with await. All methods exist on both with identical signatures.
Quick start
from strongly import Strongly
client = Strongly()
# Retrieve one by id
item = client.ai.guardrails.retrieve("<id>")
Methods
Core
retrieve
retrieve(model_id: str) -> ModelGuardrails
Get a model's guardrails.
Other
judge_models
judge_models(model_id: str) -> SyncPaginator[GuardrailJudgeModel]
List the chat models that may judge this model's answers.
Pass one's id as a Hallucination Detector rule's judge_model_id: models you may
use, other than the model itself.
list_models
list_models(*, limit: int | None = None) -> SyncPaginator[GuardrailModel]
List the models guardrails can check, each with its guardrails and last 24 hours.
The totals across them are statistics.
Parameters
limit(int | None, optional): The most models to return; all of them when omitted.
logs
logs(model_id: str, *, search: str | None = None, sort: str | None = None, limit: int | None = None) -> SyncPaginator[GuardrailLog]
List what a model's guardrails did, newest first unless sorted.
Parameters
model_id(str): The model.search(str | None, optional): Only records whose direction, request id, user id, rule name or action contains this text.sort(str | None, optional):-timestamp(default),timestamp,direction,outcome(blocked, then changed),userIdorrequestId(-for descending).limit(int | None, optional): The most records to return;Nonereturns every one.
replace
replace(model_id: str, *, enabled: bool, rules: Sequence[Mapping[str, Any]]) -> ModelGuardrails
Replace a model's guardrails with the state given.
Parameters
enabled(bool): Whether the guardrails are on.rules(Sequence[Mapping[str, Any]]): Every rule the model is to have:id,template,name,enabled,priorityandconfig(the template's settings by direction, every setting given, in snake_case). A rule the template cannot apply is refused, naming it.
set_enabled
set_enabled(model_id: str, enabled: bool) -> ModelGuardrails
Turn a model's guardrails on or off, keeping its rules.
statistics
statistics() -> GuardrailTotals
Count what guardrails did across your models in the last 24 hours.
templates
templates() -> list[GuardrailTemplate]
List the rule templates, with whether the gateway can apply each.
test
test(model_id: str, *, input: str, direction: str, rules: Sequence[Mapping[str, Any]], grounding: str | None = None) -> GuardrailTestResult
Run rules on a sample text as the gateway would, without a model call or a record.
direction is input (sent to the model) or output (returned by it).
grounding is the context a hallucination-detector rule checks the text against
(what the request sent the model): required with such a rule, refused without one. The
detector asks its judge model, a request recorded against that model.