Class AntsPlatformClient

java.lang.Object
com.ants.platform.client.AntsPlatformClient

public class AntsPlatformClient extends Object
  • Field Details

  • Constructor Details

    • AntsPlatformClient

      public AntsPlatformClient(ClientOptions clientOptions)
      Legacy constructor for backward compatibility.
    • AntsPlatformClient

      public AntsPlatformClient(ClientOptions clientOptions, String publicKey)
      SDK v3.4.0: Constructor with public key for agent identification.
  • Method Details

    • getProjectId

      public String getProjectId()
      SDK v3.4.0: Get the project ID fetched from the API. This returns the actual project ID from the Ants Platform API, not the UUID from the public key. This ensures consistent agent_id generation across Python, JS, and Java SDKs.
      Returns:
      the project ID, or null if not available
    • setProjectId

      public AntsPlatformClient setProjectId(String projectId)
      SDK v3.4.0: Manually set the project ID. Use this method when the API fetch fails or when you want to explicitly set the project ID. This is useful for: - Environments where the API is not accessible during initialization - Testing scenarios - When you know the project ID in advance
      Parameters:
      projectId - the project ID to use for agent_id generation
      Returns:
      this client instance for method chaining
    • generateAgentId

      public String generateAgentId(String agentName)
      SDK v3.4.0: Generate a deterministic agent ID from an agent name. Uses BLAKE2b-64 hash of (agentName + projectId) to produce a 16-char hex ID.

      This method handles all the complexity of agent ID generation internally:

      • Extracts project_id from the public key provided during client construction
      • Computes BLAKE2b-64 hash of agentName + projectId
      • Returns a deterministic 16-character hex string

      Example:

      
       AntsPlatformClient client = AntsPlatformClient.builder()
           .credentials(publicKey, secretKey)
           .url("http://localhost:3000")
           .build();
      
       String agentId = client.generateAgentId("qa_agent");
       // Returns: "1fdb77db0603771f" (deterministic 16-char hex)
       
      Parameters:
      agentName - the agent name (immutable identifier)
      Returns:
      the generated agent ID (16-char hex string)
      Throws:
      IllegalStateException - if project ID is not available
      IllegalArgumentException - if agentName is null or empty
    • generateAgentId

      public String generateAgentId(String agentName, String projectId)
      SDK v3.4.0: Generate a deterministic agent ID from an agent name and project ID. This overload allows you to explicitly provide the project ID, which is useful when: - The automatic project ID fetch failed - You want to use a specific project ID - You're testing with a known project ID
      Parameters:
      agentName - the agent name (immutable identifier)
      projectId - the project ID to use for agent_id generation
      Returns:
      the generated agent ID (16-char hex string)
      Throws:
      IllegalArgumentException - if agentName or projectId is null or empty
    • updateAgentDisplayName

      public boolean updateAgentDisplayName(String agentId, String displayName)
      SDK v3.4.0: Updates the mutable display name for an agent.

      The display name is a user-friendly label shown in the UI, while the agent ID (derived from agent_name + project_id) remains immutable. This allows renaming agents without breaking historical trace associations.

      Example:

      
       AntsPlatformClient client = AntsPlatformClient.builder()
           .credentials(publicKey, secretKey)
           .url("http://localhost:3000")
           .build();
      
       // Update display name using the agent's immutable ID
       client.updateAgentDisplayName("5d15c8e8b4aee83a", "QA Agent v2.0");
       
      Parameters:
      agentId - the immutable agent identifier (16-character hex string from generateAgentId)
      displayName - the new UI-friendly display name for the agent
      Returns:
      true if the update was successful, false otherwise
      Throws:
      IllegalArgumentException - if agentId is invalid or displayName is empty/null
    • annotationQueues

      public AnnotationQueuesClient annotationQueues()
    • comments

      public CommentsClient comments()
    • datasetItems

      public DatasetItemsClient datasetItems()
    • datasetRunItems

      public DatasetRunItemsClient datasetRunItems()
    • datasets

      public DatasetsClient datasets()
    • health

      public HealthClient health()
    • ingestion

      public IngestionClient ingestion()
    • media

      public MediaClient media()
    • metrics

      public MetricsClient metrics()
    • models

      public ModelsClient models()
    • observations

      public ObservationsClient observations()
    • organizations

      public OrganizationsClient organizations()
    • projects

      public ProjectsClient projects()
    • promptVersion

      public PromptVersionClient promptVersion()
    • prompts

      public PromptsClient prompts()
    • scim

      public ScimClient scim()
    • scoreConfigs

      public ScoreConfigsClient scoreConfigs()
    • scoreV2

      public ScoreV2Client scoreV2()
    • score

      public ScoreClient score()
    • sessions

      public SessionsClient sessions()
    • trace

      public TraceClient trace()
    • builder

      public static AntsPlatformClientBuilder builder()