Skip to main content

Function

Tool identifier http_request. http_request makes a generic HTTP or HTTPS request on behalf of the agent, suitable for calling open HTTP APIs, submitting forms, or downloading resources of bounded size. It includes SSRF protection, redirect validation, sensitive-header handling, and a response size cap, and it cannot reach internal addresses. Import path: from veadk.tools.builtin_tools.http_request import http_request

Prerequisites

Environment variables:
  • MODEL_AGENT_API_KEY: API key for the agent’s reasoning model (the http_request tool itself needs no extra credentials)
  • TOOL_HTTP_ALLOWLIST: optional host allowlist as comma-separated domains; when set, only exact matches and their subdomains can be requested

Usage

examples/tools/http_request/agent.py
For direct calls, a header value can be read from an environment variable with env:NAME, avoiding plaintext secrets in the arguments:

Parameters

Success returns {"status_code", "url", "headers", "content_type", "body", "bytes", "truncated"}; response header names are lowercased and body is text decoded with the response encoding. HEAD responses carry no body. A rejected request or network failure returns {"error": ...}.

Notes

Security boundaries:
  • SSRF protection: after DNS resolution, private, loopback, link-local, and reserved addresses are blocked; when redirects are enabled every hop is re-validated, with at most 3 hops.
  • Sensitive headers: Authorization, Cookie, Proxy-Authorization, and every header resolved via env: are dropped on cross-origin redirects and on HTTPS-to-HTTP downgrades; they are kept for same-origin hops and same-host HTTP-to-HTTPS upgrades.
  • The host and content-length headers cannot be set, and header names or values containing CR/LF characters are rejected.
  • When TOOL_HTTP_ALLOWLIST is set and the target host is not listed, the request returns an error; an unset environment variable referenced by env:NAME likewise returns an error.
Last modified on November 20, 2026