guardrails_ai.sdk.guards_api ============================ .. py:module:: guardrails_ai.sdk.guards_api Classes ------- .. autoapisummary:: guardrails_ai.sdk.guards_api.GuardsApi Module Contents --------------- .. py:class:: GuardsApi(*, http_client: httpx.AsyncClient, headers: dict[str, str], max_retries: int) Bases: :py:obj:`guardrails_ai.sdk.abstract_client.Client` API for managing Guards and running validations. Accessed via ``client.guards``. .. py:method:: create(guard: guardrails_ai.types.CreateGuardRequest) -> guardrails_ai.types.Guard :async: Creates a Guard on the Guardrails API. Retries with exponential back-off up to ``max_retries`` times on failure. :param guard: The request body of the Guard to create. :returns: A validated ``Guard`` instance. :raises tenacity.RetryError: If all retry attempts are exhausted. .. py:method:: delete(id: str) -> guardrails_ai.types.Guard :async: Deletes a Guard on the Guardrails API. Retries with exponential back-off up to ``max_retries`` times on failure. :param id: The unique id of the Guard to delete. :returns: A validated ``Guard`` instance. :raises tenacity.RetryError: If all retry attempts are exhausted. .. py:method:: list(*, name: Optional[str] = None) -> list[guardrails_ai.types.Guard] :async: List Guards from the Guardrails API. Retries with exponential back-off up to ``max_retries`` times on failure. :param name: If provided, will fetch guards only with the designated name. Defaults to None. :returns: A validated list of ``Guard`` instances. :raises tenacity.RetryError: If all retry attempts are exhausted. .. py:method:: retrieve(id: str) -> guardrails_ai.types.Guard :async: Fetch a Guard by id from the Guardrails API. Retries with exponential back-off up to ``max_retries`` times on failure. :param id: The id of the Guard to retrieve. :returns: A validated ``Guard`` instance. :raises tenacity.RetryError: If all retry attempts are exhausted. .. py:method:: update(guard: guardrails_ai.types.Guard) -> guardrails_ai.types.Guard :async: Updates a Guard on the Guardrails API. Retries with exponential back-off up to ``max_retries`` times on failure. :param guard: The updated Guard to persist. :returns: A validated ``Guard`` instance. :raises tenacity.RetryError: If all retry attempts are exhausted. .. py:method:: validate(id: str, content: str, **kwargs) -> guardrails_ai.types.ValidationOutcome :async: Validate content against a Guard. Retries with exponential back-off up to ``max_retries`` times on failure. :param id: The unique id of the Guard to validate against. :param content: The text content (typically LLM output) to validate. :param \*\*kwargs: Additional fields merged into the request body. :returns: A ``ValidationOutcome`` describing whether validation passed and, if so, the validated output. :raises tenacity.RetryError: If all retry attempts are exhausted. .. py:attribute:: chat :type: guardrails_ai.sdk.chat_completions_api.ChatApi .. py:attribute:: headers :type: dict[str, str] .. py:attribute:: http_client :type: httpx.AsyncClient .. py:attribute:: max_retries :type: int