Coverage for .venv/lib/python3.13/site-packages/litellm/proxy/client/health.py: 0%
10 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:01 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:01 +0000
1from typing import Any, Final
3from .http_client import HTTPClient
6class HealthManagementClient:
7 """
8 Client for interacting with the health endpoints of the LiteLLM proxy server.
9 """
11 def __init__(self, base_url: str, api_key: str | None = None, timeout: int = 30):
12 """
13 Initialize the HealthManagementClient.
15 Args:
16 base_url (str): The base URL of the LiteLLM proxy server (e.g., "http://localhost:4000")
17 api_key (Optional[str]): API key for authentication. If provided, it will be sent as a Bearer token.
18 timeout (int): Request timeout in seconds (default: 30)
19 """
20 self._http = HTTPClient(base_url=base_url, api_key=api_key, timeout=timeout)
22 def get_readiness(self) -> dict[str, Any]:
23 """
24 Check the readiness of the LiteLLM proxy server.
26 Returns:
27 Dict[str, Any]: The readiness status and details from the server.
29 Raises:
30 requests.exceptions.RequestException: If the request fails
31 ValueError: If the response is not valid JSON
32 """
33 return self._http.request("GET", "/health/readiness")
35 def get_server_version(self) -> str | None:
36 """
37 Get the LiteLLM server version from the readiness endpoint.
39 Returns:
40 Optional[str]: The server version if available, otherwise None.
41 """
42 readiness: Final = self.get_readiness()
43 return readiness.get("litellm_version")