a2a-client
Rust HTTP client for calling remote A2A v1.0 agents. Supports both HTTP+JSON and JSON-RPC 2.0 transports, streaming via SSE, and agent discovery from an agent card.
Installation
[]
= "0.2.0"
= "0.2.0"
Quick start
use A2AClient;
use ;
async
Streaming
use A2AClient;
use ;
use StreamExt;
async
API
Constructors
| Method | Description |
|---|---|
from_card_url(url) |
Fetch agent card from /.well-known/agent-card.json and build client |
from_card_url_with_client(url, client) |
Same, with a custom reqwest::Client |
from_card(card) |
Build from an already-fetched AgentCard |
from_card_with_client(card, client) |
Same, with a custom reqwest::Client |
from_card_with_headers(card, headers) |
Build with custom default headers (e.g. API keys) |
.with_auth_token(token) |
Attach a Bearer token (builder pattern) |
Core methods
| Method | Returns |
|---|---|
send_message(SendMessageRequest) |
SendMessageResponse |
send_streaming_message(SendMessageRequest) |
Stream<Item = Result<StreamResponse>> |
get_task(GetTaskRequest) |
Task |
list_tasks(ListTasksRequest) |
ListTasksResponse |
cancel_task(CancelTaskRequest) |
Task |
subscribe_to_task(SubscribeToTaskRequest) |
Stream<Item = Result<StreamResponse>> |
get_extended_agent_card(GetExtendedAgentCardRequest) |
AgentCard |
fetch_extended_agent_card_if_available() |
Option<AgentCard> — checks capability flag first, no-ops if not advertised |
Push notification methods
create_task_push_notification_config, get_task_push_notification_config, list_task_push_notification_configs, delete_task_push_notification_config — all guarded by capabilities.push_notifications.
Transport behaviour
- Prefers HTTP+JSON when the agent card advertises it (
protocol_binding: "HTTP+JSON"), falls back to JSON-RPC 2.0 otherwise. - Non-empty
tenanton a request is sent asX-A2A-Tenantheader, not as a URL path segment. - SSE streams validate
Content-Type: text/event-stream; JSON responses validateContent-Type: application/json. - Default timeout: 30 seconds (override by passing a custom
reqwest::Client). - JSON-RPC response IDs are validated against the request ID; a mismatch is a hard error.
- W3C
traceparent/tracestateheaders are injected automatically for distributed tracing.
Version compatibility
| Crate version | A2A protocol version |
|---|---|
| 0.1.x | 1.0 |
| 0.2.x | 1.0 — flat a2a_types::* namespace, protocol compliance fixes |
License
MIT