Class AntsAnthropic

java.lang.Object
com.ants.platform.guardrails.providers.AntsAnthropic

public class AntsAnthropic extends Object
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"))
 );
 
  • Method Details

    • builder

      public static AntsAnthropic.Builder 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 response
      messages - 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 ID
      maxTokens - maximum tokens in the response
      messages - list of message maps with "role" and "content" keys
      systemPrompt - optional system prompt (may be null)
      Returns:
      raw JSON response from the Anthropic Messages API