from fastapi import APIRouter from services.gpu_monitor import get_gpu_info from services.registry import registry router = APIRouter(tags=["health"]) @router.get("/health") async def health(): gpu = await get_gpu_info() return { "status": "ok", "backends": registry.get_health_summary(), "gpu": gpu, } @router.get("/health/{backend_id}") async def backend_health(backend_id: str): backend = registry.backends.get(backend_id) if not backend: return {"error": {"message": f"Backend '{backend_id}' not found"}} return { "id": backend.id, "type": backend.type, "status": "healthy" if backend.healthy else "down", "models": [m.id for m in backend.models], "latency_ms": backend.latency_ms, }