Skip to main content

AI Guard | Python SDK

AI Guard service client.

AIGuard(token, config, logger_name, config_id)

Initializes a new AI Guard client.

required parameters

str

Pangea API token.

optional parameters

PangeaConfig | None

Pangea service configuration.

str

Logger name.

str | None

Configuration ID.

from pangea import PangeaConfig
from pangea.services import AIGuard

config = PangeaConfig(domain="aws.us.pangea.cloud")
ai_guard = AIGuard(token="pangea_token", config=config)

Download file

AIGuard.download_file(url, filename)

Download a file from the specified URL and save it with the given filename.

required parameters

str

URL of the file to download

optional parameters

str | None

Name to save the downloaded file as. If not provided, the filename will be determined from the Content-Disposition header or the URL.

Text guard (Beta)

AIGuard.guard_text(text, recipe, debug)

Guard text.

How to install a Beta release.

required parameters

str

Text.

optional parameters

str

Recipe.

bool

Debug.

response = ai_guard.guard_text("text")

Poll result

AIGuard.poll_result(exception)

Returns request's result that has been accepted by the server

optional parameters

Optional[AcceptedRequestException]

Exception that was previously raised by the SDK on a call that is being processed.

Response Object

PangeaResponse

response = service.poll_result(exception)