BerriAI/litellm · error · HTTPException

Unable to find team object in database. Team ID: {data.team_

Error message

Unable to find team object in database. Team ID: {data.team_id}

What it means

Error "Unable to find team object in database. Team ID: {data.team_id}" thrown in BerriAI/litellm.

Source

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

def key_generation_check(
    team_table: LiteLLM_TeamTableCachedObj | None,
    user_api_key_dict: UserAPIKeyAuth,
    data: GenerateKeyRequest,
    route: KeyManagementRoutes,
) -> bool:
    """
    Check if admin has restricted key creation to certain roles for teams or individuals
    """

    ## check if key is for team or individual
    is_team_key: Final = _is_team_key(data=data)
    _is_admin: Final = (
        user_api_key_dict.user_role is not None and user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value
    )
    if is_team_key:
        if team_table is None and litellm.key_generation_settings is not None:
            raise HTTPException(
                status_code=400,
                detail=f"Unable to find team object in database. Team ID: {data.team_id}",
            )
        elif team_table is None:
            if _is_admin:
                return True  # admins can assign team_id without team table
            # Non-admin callers must have a valid team (LIT-1884)
            raise HTTPException(
                status_code=400,
                detail=f"Unable to find team object in database. Team ID: {data.team_id}",
            )
        return _team_key_generation_check(
            team_table=team_table,
            user_api_key_dict=user_api_key_dict,
            data=data,
            route=route,
        )
    else:

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Verify the team_id exists via /team/list before creating the key.
  2. Create the team first, then retry key creation.

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/key_management_endpoints.py:505 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/572a9d4b16976649. Report an issue: GitHub.