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

1from typing import Any, Final 

2 

3from .http_client import HTTPClient 

4 

5 

6class HealthManagementClient: 

7 """ 

8 Client for interacting with the health endpoints of the LiteLLM proxy server. 

9 """ 

10 

11 def __init__(self, base_url: str, api_key: str | None = None, timeout: int = 30): 

12 """ 

13 Initialize the HealthManagementClient. 

14 

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) 

21 

22 def get_readiness(self) -> dict[str, Any]: 

23 """ 

24 Check the readiness of the LiteLLM proxy server. 

25 

26 Returns: 

27 Dict[str, Any]: The readiness status and details from the server. 

28 

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") 

34 

35 def get_server_version(self) -> str | None: 

36 """ 

37 Get the LiteLLM server version from the readiness endpoint. 

38 

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")