Skip to content

strands.vended_tools.http_request.http_request

HTTP request tool for making raw HTTP calls to external APIs.

Provides :func:make_http_request (a factory that lets the tool operator supply a custom HTTP client) and :data:http_request (a default instance).

The tool is a thin shim over httpx.AsyncClient. It delegates all networking to the client instance provided by the operator, giving full control over transport configuration, authentication, proxies, timeouts, redirects, and connection pooling.

The parent agent’s cancel signal (Agent._cancel_signal) is propagated so an in-flight fetch aborts when the agent is cancelled. Cancellation is signalled with :class:asyncio.CancelledError.

class HttpRequestError(RuntimeError)

Defined in: src/strands/vended_tools/http_request/http_request.py:32

Raised when a request fails.

def make_http_request(
*,
name: str = "http_request",
description: str = DEFAULT_HTTP_REQUEST_DESCRIPTION,
client: httpx.AsyncClient | None = None) -> DecoratedFunctionTool

Defined in: src/strands/vended_tools/http_request/http_request.py:36

Create an HTTP request tool.

Arguments:

  • name - Tool name shown to the model.
  • description - Tool description shown to the model.
  • client - Optional httpx.AsyncClient instance to use for requests. When provided, the tool uses this client directly — timeouts, redirects, proxies, auth, and all other transport settings are controlled by the client. The tool will not close it. When None, a new client is created per request with httpx defaults.

Returns:

A decorated tool that makes HTTP requests.

Default HTTP request tool.