BerriAI/litellm · error · ValueError
Router not initialized
Error message
Router not initialized
What it means
Runtime guard when executing a guardrail via the router: llm_router on proxy_server is None, meaning no models (and hence no router) were configured — typically the proxy started with an empty config or the router failed to initialize. Guardrail resolution cannot proceed without it.
Source
Thrown at litellm/proxy/utils.py:1065
) -> object:
"""
Execute a guardrail using the router's load balancing.
Args:
guardrail_name: Name of the guardrail
hook_type: One of "pre_call", "during_call", "post_call"
data: Request data
user_api_key_dict: User API key auth
call_type: Type of call
response: Response object (for post_call hooks)
Returns:
Result from the guardrail execution
"""
from litellm.proxy.proxy_server import llm_router
if llm_router is None:
raise ValueError("Router not initialized")
# Select guardrail using router's load balancing
selected_guardrail: Final = llm_router.get_available_guardrail(guardrail_name=guardrail_name)
callback: Final[CustomGuardrail | None] = selected_guardrail.get("callback")
if callback is None:
raise ValueError(f"No callback found for guardrail: {guardrail_name}")
return await self._execute_guardrail_hook(
callback=callback,
hook_type=hook_type,
data=data,
user_api_key_dict=user_api_key_dict,
call_type=call_type,
response=response,
)
async def _process_guardrail_callback(View on GitHub (pinned to 77b7c6c40c)
Solutions
- Ensure the proxy/router finished initializing before invoking this code path; check startup logs for errors.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/utils.py:1065 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/6f2e7f28ae98460b.
Report an issue: GitHub.