From a756256a76822ae99519e3d91715a95efce304fd Mon Sep 17 00:00:00 2001 From: Himanjan Pati Date: Fri, 29 May 2026 15:26:50 +0000 Subject: [PATCH] fix: sync model_list with models_by_provider 25 model groups were present in models_by_provider but missing from model_list, causing visible inconsistency (e.g. bedrock showed only 7 models in model_list vs 450+ in models_by_provider). Also added ai21_chat_models to models_by_provider["ai21"] and a docker_model_runner entry which existed in model_list but had no models_by_provider key. Added a regression test to catch future drift between the two. Fixes #29274 --- litellm/__init__.py | 28 ++++++++++++++++++++++++- tests/litellm_utils_tests/test_utils.py | 15 +++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/litellm/__init__.py b/litellm/__init__.py index 56d516536e8..58e5d1ce4e8 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -1031,6 +1031,31 @@ model_list = list( | reducto_models | bedrock_mantle_models | set(clarifai_models) + | set(petals_models) + | bedrock_converse_models + | vertex_anthropic_models + | vertex_vision_models + | vertex_deepseek_models + | vertex_minimax_models + | vertex_moonshot_models + | vertex_zai_models + | fireworks_ai_models + | fireworks_ai_embedding_models + | mistral_chat_models + | sambanova_embedding_models + | nebius_models + | nebius_embedding_models + | aiml_models + | hyperbolic_models + | amazon_nova_models + | stability_models + | github_copilot_models + | chatgpt_models + | minimax_models + | aws_polly_models + | gigachat_models + | llamagate_models + | ovhcloud_embedding_models ) model_list_set = set(model_list) @@ -1060,7 +1085,7 @@ models_by_provider: dict = { | vertex_minimax_models | vertex_moonshot_models | vertex_zai_models, - "ai21": ai21_models, + "ai21": ai21_models | ai21_chat_models, "bedrock": bedrock_models | bedrock_converse_models, "petals": petals_models, "ollama": ollama_models, @@ -1137,6 +1162,7 @@ models_by_provider: dict = { "llamagate": llamagate_models, "reducto": reducto_models, "bedrock_mantle": bedrock_mantle_models, + "docker_model_runner": docker_model_runner_models, } # mapping for those models which have larger equivalents diff --git a/tests/litellm_utils_tests/test_utils.py b/tests/litellm_utils_tests/test_utils.py index d64633413a0..1849c0d506c 100644 --- a/tests/litellm_utils_tests/test_utils.py +++ b/tests/litellm_utils_tests/test_utils.py @@ -2516,3 +2516,18 @@ def test_get_base_model_from_metadata(): # Test 6: None input result = _get_base_model_from_metadata(None) assert result is None, f"Expected None for None input, got {result}" + + +def test_model_list_models_by_provider_in_sync(): + model_list_set = set(litellm.model_list) + missing_from_model_list = [] + for provider, models in litellm.models_by_provider.items(): + model_set = set(models) if isinstance(models, list) else models + for model in model_set: + if model not in model_list_set: + missing_from_model_list.append(f"{provider}: {model}") + + assert not missing_from_model_list, ( + f"{len(missing_from_model_list)} models in models_by_provider are missing from model_list:\n" + + "\n".join(missing_from_model_list[:20]) + )