Skip to content

pixano.inference.providers.base

HTTPProvider(url)

Bases: InferenceProvider

Base class for HTTP-based inference providers.

This class provides common HTTP client functionality that can be shared by providers that communicate over HTTP.

Attributes:

Name Type Description
url str

The base URL of the inference server.

Parameters:

Name Type Description Default
url str

The base URL of the inference server.

required
Source code in pixano/inference/providers/base.py
def __init__(self, url: str):
    """Initialize the HTTP provider.

    Args:
        url: The base URL of the inference server.
    """
    self._url = url.rstrip("/")
    self._client: httpx.AsyncClient | None = None

name abstractmethod property

Provider name.

url property

The base URL of the inference server.

close() async

Close the HTTP client.

Source code in pixano/inference/providers/base.py
async def close(self) -> None:
    """Close the HTTP client."""
    if self._client is not None and not self._client.is_closed:
        await self._client.aclose()
        self._client = None

delete(path, timeout=60, **kwargs) async

Perform a DELETE request.

Parameters:

Name Type Description Default
path str

URL path.

required
timeout int | float

Request timeout.

60
**kwargs Any

Additional request arguments.

{}

Returns:

Type Description
Response

The HTTP response.

Source code in pixano/inference/providers/base.py
async def delete(self, path: str, timeout: int | float = 60, **kwargs: Any) -> httpx.Response:
    """Perform a DELETE request.

    Args:
        path: URL path.
        timeout: Request timeout.
        **kwargs: Additional request arguments.

    Returns:
        The HTTP response.
    """
    return await self._request("DELETE", path, timeout=timeout, **kwargs)

get(path, timeout=60, **kwargs) async

Perform a GET request.

Parameters:

Name Type Description Default
path str

URL path.

required
timeout int | float

Request timeout.

60
**kwargs Any

Additional request arguments.

{}

Returns:

Type Description
Response

The HTTP response.

Source code in pixano/inference/providers/base.py
async def get(self, path: str, timeout: int | float = 60, **kwargs: Any) -> httpx.Response:
    """Perform a GET request.

    Args:
        path: URL path.
        timeout: Request timeout.
        **kwargs: Additional request arguments.

    Returns:
        The HTTP response.
    """
    return await self._request("GET", path, timeout=timeout, **kwargs)

post(path, timeout=60, **kwargs) async

Perform a POST request.

Parameters:

Name Type Description Default
path str

URL path.

required
timeout int | float

Request timeout.

60
**kwargs Any

Additional request arguments.

{}

Returns:

Type Description
Response

The HTTP response.

Source code in pixano/inference/providers/base.py
async def post(self, path: str, timeout: int | float = 60, **kwargs: Any) -> httpx.Response:
    """Perform a POST request.

    Args:
        path: URL path.
        timeout: Request timeout.
        **kwargs: Additional request arguments.

    Returns:
        The HTTP response.
    """
    return await self._request("POST", path, timeout=timeout, **kwargs)

put(path, timeout=60, **kwargs) async

Perform a PUT request.

Parameters:

Name Type Description Default
path str

URL path.

required
timeout int | float

Request timeout.

60
**kwargs Any

Additional request arguments.

{}

Returns:

Type Description
Response

The HTTP response.

Source code in pixano/inference/providers/base.py
async def put(self, path: str, timeout: int | float = 60, **kwargs: Any) -> httpx.Response:
    """Perform a PUT request.

    Args:
        path: URL path.
        timeout: Request timeout.
        **kwargs: Additional request arguments.

    Returns:
        The HTTP response.
    """
    return await self._request("PUT", path, timeout=timeout, **kwargs)