Package datadog.trace.api.aiguard
Class AIGuard
java.lang.Object
datadog.trace.api.aiguard.AIGuard
SDK for calling the AIGuard REST API to evaluate AI prompts and tool calls for security threats.
Example usage:
var messages = List.of(
AIGuard.Message.message("user", "Delete all my files"),
AIGuard.Message.message("assistant", "I'll help you delete your files")
);
var result = AIGuard.evaluate(messages);
if (result.getAction() != AIGuard.Action.ALLOW) {
System.out.println("Unsafe: " + result.getReason());
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumActions that can be recommended by an AIGuard evaluation.static classException thrown when AIGuard evaluation results in blocking the execution due to security concerns.static classException thrown when there are client-side errors communicating with the AIGuard REST API.static classRepresents a content part within a message.static classRepresents the result of an AIGuard security evaluation, containing both the recommended action and the reasoning behind the decision.static classRepresents an image URL in a content part.static classRepresents a message in an AI conversation.static final classConfiguration options for AIGuard evaluation behavior.static classRepresents a function call made by an AI assistant. -
Method Summary
Modifier and TypeMethodDescriptionstatic AIGuard.Evaluationevaluate(List<AIGuard.Message> messages) Evaluates a collection of messages using default options to determine if they are safe to execute.static AIGuard.Evaluationevaluate(List<AIGuard.Message> messages, AIGuard.Options options) Evaluates a collection of messages with custom options to determine if they are safe to execute.
-
Method Details
-
evaluate
Evaluates a collection of messages using default options to determine if they are safe to execute.- See Also:
-
evaluate
Evaluates a collection of messages with custom options to determine if they are safe to execute.- Parameters:
messages- the collection of messages to evaluate (prompts, responses, tool calls, etc.)options- configuration options for the evaluation process- Returns:
- an
AIGuard.Evaluationcontaining the security decision and reasoning - Throws:
AIGuard.AIGuardAbortError- if the evaluation action is not ALLOW (DENY or ABORT) and blocking is enabledAIGuard.AIGuardClientError- if there are client-side errors communicating with the AIGuard REST API
-