guard

Screen content for threats

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.

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.

A request must contain messages, tools, or both. Send tools on its own to screen tool definitions independently of a conversation.

post/v2/guard

Request

  • Base URL: https://api.lakera.ai
  • URL: https://api.lakera.ai/v2/guard
  • Auth: HTTP bearer

Request body

project_idstring

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.

payloadboolean

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.

breakdownboolean

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.

dev_infoboolean

When true the response will return an object with developer information about the build of AI Guardrails.

Response

Screening result

flaggedboolean

Depends on the action configured for the project. If action is enforce, flagged is true if any threats were detected with sufficient confidence. But if action is detect, flagged is always false. See Project Mode for more details.

action'detect' | 'enforce'

The action configured for the project screening this request. enforce means full enforcement: the top-level flagged is true whenever a detector triggers. detect surfaces detections in the breakdown but forces the top-level flagged to false, letting you observe detector behavior without blocking traffic. Configured on the project level.

Changes

No recorded changes to this operation across all 1 revision of this API.