Class AntsAnthropic
java.lang.Object
com.ants.platform.guardrails.providers.AntsAnthropic
Anthropic Messages API wrapper with guardrail enforcement and trace logging.
var client = AntsAnthropic.builder()
.anthropicApiKey("sk-ant-...")
.antsApiKey("pk:sk")
.agentId("agent_123")
.build();
JsonNode response = client.createMessage(
"claude-sonnet-4-20250514", 1024,
List.of(Map.of("role", "user", "content", "Hello"))
);
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic AntsAnthropic.Builderbuilder()com.fasterxml.jackson.databind.JsonNodeSend a message creation request with guardrail checks on input and output.com.fasterxml.jackson.databind.JsonNodeSend a message creation request with an optional system prompt.
-
Method Details
-
builder
-
createMessage
public com.fasterxml.jackson.databind.JsonNode createMessage(String model, int maxTokens, List<Map<String, String>> messages) Send a message creation request with guardrail checks on input and output. A trace is logged asynchronously after each call.- Parameters:
model- Anthropic model ID (e.g. "claude-sonnet-4-20250514")maxTokens- maximum tokens in the responsemessages- list of message maps with "role" and "content" keys- Returns:
- raw JSON response from the Anthropic Messages API
-
createMessage
public com.fasterxml.jackson.databind.JsonNode createMessage(String model, int maxTokens, List<Map<String, String>> messages, String systemPrompt) Send a message creation request with an optional system prompt.- Parameters:
model- Anthropic model IDmaxTokens- maximum tokens in the responsemessages- list of message maps with "role" and "content" keyssystemPrompt- optional system prompt (may be null)- Returns:
- raw JSON response from the Anthropic Messages API
-