BerriAI/litellm · error · HTTPException

LLM router not found. Please set it up by passing in a valid

Error message

LLM router not found. Please set it up by passing in a valid config.yaml or adding models via the UI.

What it means

Changing a key's team via /key/update triggers validate_key_team_change, which checks the key's models/budget against the new team and therefore needs the model router. If the proxy was started without any models configured (llm_router is None), that validation cannot run and LiteLLM refuses the team change with HTTP 400 telling you to set up a valid config.yaml or add models via the UI. Team changes are the specific operation affected -- other updates work without a router.

Source

Thrown at litellm/proxy/management_endpoints/key_management_endpoints.py:2317

    if update_key_request.team_id is not None:
        team_obj = await get_team_object(
            team_id=update_key_request.team_id,
            prisma_client=prisma_client,
            user_api_key_cache=user_api_key_cache,
            check_db_only=True,
        )

        if team_obj is not None and prisma_client is not None:
            await _check_team_key_limits(
                team_table=team_obj,
                data=update_key_request,
                prisma_client=prisma_client,
            )

    # Validate team change if team is being changed
    if is_different_team(data=update_key_request, existing_key_row=existing_key_row):
        if llm_router is None:
            raise HTTPException(
                status_code=400,
                detail={
                    "error": "LLM router not found. Please set it up by passing in a valid config.yaml or adding models via the UI."
                },
            )
        if team_obj is None:
            raise HTTPException(
                status_code=500,
                detail={"error": "Team object not found for team change validation"},
            )
        await validate_key_team_change(
            key=existing_key_row,
            team=team_obj,
            change_initiated_by=user_api_key_dict,
            llm_router=llm_router,
        )

    # Prepare update data

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Start the proxy with a config.yaml containing model_list (at least one deployment), or add models via the UI/POST /model/new
  2. If models live in the DB, ensure store_model_in_db: true so the router initializes from the DB
  3. Point the team-change request at a proxy instance that has the router loaded
  4. If the team change isn't required, drop team_id from the update payload to avoid validation entirely

Example fix

# config.yaml (before)
general_settings:
  database_url: postgresql://...
# no model_list / no models

# after
model_list:
  - model_name: gpt-4o
    litellm_params:
      model: openai/gpt-4o
general_settings:
  database_url: postgresql://...
  store_model_in_db: true
Defensive patterns

Strategy: validation

Validate before calling

models = await client.get("/v1/models")
if not models.json().get("data"):
    raise RuntimeError("proxy has no models configured; team-change validation requires llm_router")
# only then attempt the team_id change

Try / catch

try:
    r = await client.post("/key/update", json=payload)
except httpx.HTTPStatusError as e:
    if e.response.status_code == 400 and "LLM router not found" in e.response.text:
        raise RuntimeError("configure model_list (or store_model_in_db) on the proxy, restart, then retry") from e
    raise

Prevention

When it happens

Trigger: POST /key/update changing team_id on a proxy running in DB-only/auth-only mode (no model_list in config and no models added); models were expected from the DB (store_model_in_db) but that feature isn't enabled/loaded; config.yaml model_list is empty or malformed so the router never initialized; UI/Config removed all models earlier.

Common situations: Using LiteLLM purely as a virtual-key/spend gateway in front of another router; splitting model config from key management into different instances and sending key updates to the wrong one; misconfigured store_model_in_db where models exist in DB but this proxy wasn't started with the flag.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/8556b3e815a6df55. Report an issue: GitHub.