Guardrail¶
- class opik.guardrails.guardrail.Guardrail(guards: List[Guard], guardrail_timeout: int | None = None)¶
Bases:
object
Client for the Opik Guardrails API.
This class provides a way to validate text against a set of guardrails.
- validate(text: str) ValidationResponse ¶
Validate text against all configured guardrails.
- Parameters:
text – Text to validate
- Returns:
API response containing validation results
- Return type:
- Raises:
opik.exceptions.GuardrailValidationFailed – If validation fails
httpx.HTTPStatusError – If the API returns an error status code