Lightweight connectivity check for a provider endpoint.
(base_url: str, api_key: str)
| 796 | |
| 797 | |
| 798 | async def _check_provider(base_url: str, api_key: str) -> bool: |
| 799 | """Lightweight connectivity check for a provider endpoint.""" |
| 800 | import httpx |
| 801 | try: |
| 802 | async with httpx.AsyncClient(timeout=httpx.Timeout(5.0, connect=3.0)) as client: |
| 803 | resp = await client.get( |
| 804 | f"{base_url.rstrip('/')}/models", |
| 805 | headers={ |
| 806 | "authorization": f"Bearer {api_key}", |
| 807 | "user-agent": "uncommon-route/provider-check", |
| 808 | }, |
| 809 | ) |
| 810 | return resp.status_code == 200 |
| 811 | except Exception: # noqa: BLE001 |
| 812 | return False |
| 813 | |
| 814 | |
| 815 | def _cmd_logs(args: list[str]) -> None: |