Package org.a2aproject.sdk.client.http


@NullMarked package org.a2aproject.sdk.client.http
HTTP client utilities for A2A protocol communication.

This package provides a pluggable HTTP client abstraction for making HTTP requests to A2A agents, including support for fetching agent cards, synchronous requests, and Server-Sent Events (SSE) streaming.

Core Components

Provider System

The module uses a ServiceLoader-based provider system allowing different HTTP client implementations to be plugged in:

  • JdkA2AHttpClient - Default implementation using JDK 11+ HttpClient (priority 0)
  • VertxA2AHttpClient - Vertx-based implementation when available (priority 100)

Usage Example


 // Fetch an agent card
 A2ACardResolver resolver = A2ACardResolver.builder().baseUrl("http://localhost:9999").build();
 AgentCard card = resolver.getAgentCard();

 // Make HTTP requests
 A2AHttpClient client = A2AHttpClientFactory.create();
 A2AHttpResponse response = client.createGet()
     .url("http://localhost:9999/api/endpoint")
     .addHeader("Authorization", "Bearer token")
     .get();

 // Server-Sent Events (SSE) streaming
 client.createPost()
     .url("http://localhost:9999/message:stream")
     .body(jsonBody)
     .postAsyncSSE(
         message -> System.out.println("Received: " + message),
         error -> System.err.println("Error: " + error),
         () -> System.out.println("Stream complete")
     );
 

Agent Card Resolution

Agent cards are fetched from the standard /.well-known/agent-card.json endpoint by default, with support for tenant-specific paths and custom authentication headers.

See Also: