Screen content for threats

The guard API endpoint is the integration point for GenAI applications using Lakera Guard. It allows you to call on all of Lakera Guard’s defenses with a single API call.

Using guard, you can submit the text content of an LLM interaction to Lakera Guard. The configured detectors 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.

Headers

AuthorizationstringRequired

Bearer authentication of the form Bearer <token>, where token is your auth token.

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, or system.

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 Lakera Guard 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.

metadatamap from strings to anyOptional

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 Lakera Guard.

Response

Screening result

flaggedbooleanOptional

Whether any threats were detected with sufficient confidence

payloadlist of objectsOptional

Contains detected PII, profanity, or custom regex matches with their locations. Only returned if payload=true in request.

breakdownlist of objectsOptional

List of detectors run and their results. Only returned if breakdown=true in request.

dev_infoobjectOptional

Build information. Only returned if dev_info=true in request.

Errors