Skip to content

ZenHTTPClient

Base classes

Name Children Inherits
AsyncClient
httpx2
An asynchronous HTTP client, with connection pooling, HTTP/2, redirects,

⋔ Inheritance diagram

graph TD
  2298013283["zen_provider.ZenHTTPClient"]
  2592624997["httpx2.AsyncClient"]
  3730132019["_client.BaseClient"]
  2751680898["builtins.object"]
  2592624997 --> 2298013283
  3730132019 --> 2592624997
  2751680898 --> 3730132019

🛈 DocStrings

Bases: AsyncClient

Custom client that adds opencode headers before each request.

Source code in src/llmling_models/providers/zen_provider.py
class ZenHTTPClient(AsyncHTTPClient):
    """Custom client that adds opencode headers before each request."""

    def __init__(self, session_id: str, project_id: str, **kwargs: Any) -> None:
        super().__init__(**kwargs)
        self._session_id = session_id
        self._project_id = project_id

    async def send(self, request: Request, *args: Any, **kwargs: Any) -> Response:
        request.headers["User-Agent"] = "opencode/latest/1.3.15/cli"
        request.headers["x-opencode-client"] = "cli"
        request.headers["x-opencode-session"] = self._session_id
        request.headers["x-opencode-project"] = self._project_id
        request.headers["x-opencode-request"] = secrets.token_hex(14)
        return await super().send(request, *args, **kwargs)

:fa-brands-github: Show source on GitHub