diff --git a/litellm/__init__.py b/litellm/__init__.py index 055dd74241..5ef78dce4d 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -583,6 +583,7 @@ from .utils import ( completion_cost, supports_function_calling, supports_parallel_function_calling, + supports_vision, get_litellm_params, Logging, acreate, diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.py index eba8e27ea3..2bb15552cb 100644 --- a/litellm/llms/prompt_templates/factory.py +++ b/litellm/llms/prompt_templates/factory.py @@ -1286,7 +1286,11 @@ def prompt_factory( messages=messages, prompt_format=prompt_format, chat_template=chat_template ) elif custom_llm_provider == "gemini": - if model == "gemini-pro-vision": + if ( + model == "gemini-pro-vision" + or litellm.supports_vision(model=model) + or litellm.supports_vision(model=custom_llm_provider + "/" + model) + ): return _gemini_vision_convert_messages(messages=messages) else: return gemini_text_image_pt(messages=messages)