BerriAI/litellm · error · HTTPException
Router not initialized. Cannot use model-based routing.
Error message
Router not initialized. Cannot use model-based routing.
What it means
HTTPException(500) from the model-credential resolver in the files/batch proxy utils: llm_router is None — the proxy has no LiteLLM Router initialized (no models loaded) — so model-based routing to fetch provider credentials is impossible. The operator must add models to the proxy config.
Source
Thrown at litellm/proxy/openai_files_endpoints/common_utils.py:310
):
"""
Retrieve API credentials for a model from the LLM Router.
Args:
llm_router: LiteLLM Router instance
model_id: Model name or deployment ID
operation_context: Description for error messages (e.g., "file upload", "batch creation")
Returns:
Dictionary with credentials (api_key, api_base, custom_llm_provider, etc.)
Raises:
HTTPException: If router not initialized or model not found
"""
from fastapi import HTTPException
if llm_router is None:
raise HTTPException(
status_code=500,
detail={"error": "Router not initialized. Cannot use model-based routing."},
)
credentials: Final = llm_router.get_deployment_credentials_with_provider(model_id=model_id)
if credentials is None:
raise HTTPException(
status_code=400,
detail={"error": f"Model '{model_id}' not found in model_list. Please check your config.yaml."},
)
return credentials
def get_team_provider_credentials(
llm_router: Optional["Router"],
user_api_key_dict: "UserAPIKeyAuth",View on GitHub (pinned to 77b7c6c40c)
Solutions
- Add models to the proxy config so the router is initialized, or avoid model-based routing for this request.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/openai_files_endpoints/common_utils.py:310 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/238cc841eaf4e0d8.
Report an issue: GitHub.