fix(azure/common_utils.py): generify api version logic

This commit is contained in:
Krrish Dholakia 2025-08-11 22:54:44 -07:00
parent ca642d32e1
commit 72c7e82ef8
2 changed files with 9 additions and 3 deletions

View File

@ -694,6 +694,7 @@ class BaseAzureLLM(BaseOpenAILLM):
api_base: Optional[str],
litellm_params: Optional[Union[GenericLiteLLMParams, Dict[str, Any]]],
route: Literal["/openai/responses", "/openai/vector_stores"],
default_api_version: Optional[str] = None,
) -> str:
from litellm.constants import AZURE_DEFAULT_RESPONSES_API_VERSION
@ -708,14 +709,14 @@ class BaseAzureLLM(BaseOpenAILLM):
litellm_params = litellm_params or {}
api_version = (
cast(Optional[str], litellm_params.get("api_version"))
or AZURE_DEFAULT_RESPONSES_API_VERSION
or default_api_version
)
# Create a new dictionary with existing params
query_params = dict(original_url.params)
# Add api_version if needed
if "api-version" not in query_params:
if "api-version" not in query_params and api_version:
query_params["api-version"] = api_version
# Add the path to the base URL

View File

@ -70,8 +70,13 @@ class AzureOpenAIResponsesAPIConfig(OpenAIResponsesAPIConfig):
- A complete URL string, e.g.,
"https://litellm8397336933.openai.azure.com/openai/responses?api-version=2024-05-01-preview"
"""
from litellm.constants import AZURE_DEFAULT_RESPONSES_API_VERSION
return BaseAzureLLM._get_base_azure_url(
api_base=api_base, litellm_params=litellm_params, route="/openai/responses"
api_base=api_base,
litellm_params=litellm_params,
route="/openai/responses",
default_api_version=AZURE_DEFAULT_RESPONSES_API_VERSION,
)
#########################################################