HTTPTransport class enables agents to communicate with remote agents via HTTP/REST, following the standardized wire protocol. This is the primary way to connect agents deployed across different servers, serverless functions, or microservices.
Import
Constructor
Parameters
str
default:""
Base URL for agent endpoints. If provided, agent IDs are appended to form full URLs.
If empty, agent_id is treated as a full URL.
dict[str, str] | None
default:"None"
Default HTTP headers sent with all requests (e.g., Authorization, User-Agent).
httpx.AsyncClient | None
default:"None"
Optional existing httpx client to reuse. If not provided, creates a new client.
Examples
Methods
invoke
Parameters
str
required
Target agent ID. Combined with base_url to form the endpoint URL.
dict[str, Any]
required
Request payload to send to the agent.
float
default:"30.0"
Request timeout in seconds.
Returns
Example
Wire Protocol
Sends:POST {base_url}/{agent_id}
chat
Parameters
str
required
Target agent ID.
str
required
Chat message to send.
float
default:"30.0"
Request timeout in seconds.
Returns
Example
Wire Protocol
Sends:POST {base_url}/{agent_id}/chat
stream
Parameters
str
required
Target agent ID.
str
required
Chat message to send.
float
default:"30.0"
Request timeout in seconds.
Returns
Example
Wire Protocol
Sends:POST {base_url}/{agent_id}/chat with streaming flag
text/event-stream with data: {...} chunks