Implementation:AISecurityLab Hackagent HTTP Client
| Knowledge Sources | |
|---|---|
| Domains | Storage, HTTP_Client |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete httpx-based HTTP client (pydantic model) with sync and async client management, SSL, timeout, cookie/header management, and context-manager support, provided by the HackAgent storage HTTP package.
Description
Client is a pydantic BaseModel wrapping httpx.Client and httpx.AsyncClient. It holds base_url, cookies, headers, timeout, verify_ssl, follow_redirects, and httpx_args. Methods get_httpx_client() / get_async_httpx_client() lazily construct the underlying clients. with_headers(), with_cookies(), with_timeout() return new copies with updated settings. Both sync and async context managers are supported. Used by the generated API client methods to talk to the HackAgent storage API.
Usage
- RemoteBackend: The remote storage backend uses Client to make HTTP API calls.
- Generated API methods: All _http/api/ endpoint functions accept a Client instance.
Code Reference
Source Location
- Repository: AISecurityLab_Hackagent
- File: hackagent/storage/_http/client.py
Signature
class Client(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)
raise_on_unexpected_status: bool = False
base_url: str
cookies: dict[str, str] = {}
headers: dict[str, str] = {}
timeout: Optional[httpx.Timeout] = None
verify_ssl: Union[str, bool, ssl.SSLContext] = True
follow_redirects: bool = False
httpx_args: dict[str, Any] = {}
def get_httpx_client(self) -> httpx.Client: ...
def get_async_httpx_client(self) -> httpx.AsyncClient: ...
def with_headers(self, headers: dict[str, str]) -> "Client": ...
def with_cookies(self, cookies: dict[str, str]) -> "Client": ...
def with_timeout(self, timeout: httpx.Timeout) -> "Client": ...
Import
from hackagent.storage._http.client import Client
Usage Examples
Create and Use a Client
from hackagent.storage._http.client import Client
client = Client(base_url="https://api.hackagent.dev")
response = client.get_httpx_client().get("/v1/runs")