The `guard` API endpoint is the integration point for GenAI applications using AI Guardrails. It allows you to call on all of AI Guardrails' defenses with a single API call.
For an overview and integration guidance please see [here](../../../docs/api/guard).
Using `guard`, you can submit the content of an LLM interaction to AI Guardrails. This include inputs from the user, reference documents, and the LLM output. The guardrails configured in the policy will screen the interaction, and a flagging response will indicate whether any threats were detected, in line with your policy.
Your application can then be programmed to take mitigating action based on the flagging response, such as blocking the interaction, warning the end user, or generating an internal security alert.
Request
This endpoint expects an object.
messageslist of objectsRequired
List of messages comprising the interaction history with the LLM in OpenAI API Chat Completions format.
Can be multiple messages of any role: user, assistant, system, tool, or developer.
project_idstringOptional
ID of the relevant project. The request will be screened according to the policy assigned to the project.
If no project ID is passed then the AI Guardrails Default Policy will be used for screening.
payloadbooleanOptional
When true the response will return a payload object containing any PII, profanity or custom detector
regex matches detected, along with their location within the contents.
breakdownbooleanOptional
When true the response will return a breakdown list of the detectors that were run, as defined in the policy,
and whether each of them detected something or not.
metadataobjectOptional
Metadata tags can be attached to screening requests as an object that can contain any arbitrary key-value pairs.
Common use cases include specifying the user or session ID.
dev_infobooleanOptional
When true the response will return an object with developer information about the build of AI Guardrails.
Response
Screening result
flaggedboolean
Whether any threats were detected with sufficient confidence
payloadlist of objects
Contains detected PII, profanity, or custom regex matches with their locations.
Only returned if payload=true in request.
breakdownlist of objects
List of detectors run and their results.
Only returned if breakdown=true in request.
dev_infoobject
Build information. Only returned if dev_info=true in request.
metadataobject
Metadata returned from the request