Skip to main content
The 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

Send a structured invoke request to a remote agent.

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}
Receives:

chat

Send a chat message to a remote agent.

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
Receives:

stream

Stream a chat response from a remote agent via Server-Sent Events.

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
Receives: text/event-stream with data: {...} chunks

close

Close the underlying HTTP client if this transport owns it.

Example


Complete Examples

Serverless Agent Integration

Multi-Agent Communication

Error Handling and Timeouts