mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
Azure Managed Batches - api key error (#14932)
* added qwen models and gpt-5-codex * fix flaky test * fix failing test * Added retries to prisma client state * fix: prisma client state retries in pods * Revert "fix failing test" This reverts commitdbec4988a2. * Revert "fix flaky test" This reverts commitb0ac2f2dc3. * Revert "added qwen models and gpt-5-codex" This reverts commit9a8a8f2d47. * Revert "fix: prisma client state retries in pods" This reverts commit04e58e5ca1. * fix lint * Revert "fix lint" This reverts commit5303d52a5e. * fixed lint * fix: azure api key managed batch files
This commit is contained in:
parent
2973ff8be9
commit
b039374c71
3 changed files with 21 additions and 10 deletions
|
|
@ -62,7 +62,7 @@ class AzureBatchesAPI(BaseAzureLLM):
|
|||
)
|
||||
if azure_client is None:
|
||||
raise ValueError(
|
||||
"OpenAI client is not initialized. Make sure api_key is passed or OPENAI_API_KEY is set in the environment."
|
||||
"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY/AZURE_OPENAI_API_KEY is set in the environment."
|
||||
)
|
||||
|
||||
if _is_async is True:
|
||||
|
|
@ -108,7 +108,7 @@ class AzureBatchesAPI(BaseAzureLLM):
|
|||
)
|
||||
if azure_client is None:
|
||||
raise ValueError(
|
||||
"OpenAI client is not initialized. Make sure api_key is passed or OPENAI_API_KEY is set in the environment."
|
||||
"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY/AZURE_OPENAI_API_KEY is set in the environment."
|
||||
)
|
||||
|
||||
if _is_async is True:
|
||||
|
|
@ -156,7 +156,7 @@ class AzureBatchesAPI(BaseAzureLLM):
|
|||
)
|
||||
if azure_client is None:
|
||||
raise ValueError(
|
||||
"OpenAI client is not initialized. Make sure api_key is passed or OPENAI_API_KEY is set in the environment."
|
||||
"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY/AZURE_OPENAI_API_KEY is set in the environment."
|
||||
)
|
||||
response = azure_client.batches.cancel(**cancel_batch_data)
|
||||
return response
|
||||
|
|
@ -195,7 +195,7 @@ class AzureBatchesAPI(BaseAzureLLM):
|
|||
)
|
||||
if azure_client is None:
|
||||
raise ValueError(
|
||||
"OpenAI client is not initialized. Make sure api_key is passed or OPENAI_API_KEY is set in the environment."
|
||||
"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY/AZURE_OPENAI_API_KEY is set in the environment."
|
||||
)
|
||||
|
||||
if _is_async is True:
|
||||
|
|
|
|||
|
|
@ -576,8 +576,19 @@ class BaseAzureLLM(BaseOpenAILLM):
|
|||
verbose_logger.debug(
|
||||
f"Initializing Azure OpenAI Client for {model_name}, Api Base: {str(api_base)}, Api Key:{_api_key}"
|
||||
)
|
||||
|
||||
# Extract API key from multiple sources with proper precedence
|
||||
resolved_api_key = (
|
||||
api_key
|
||||
or litellm_params.get("api_key")
|
||||
or litellm.api_key
|
||||
or litellm.azure_key
|
||||
or get_secret_str("AZURE_OPENAI_API_KEY")
|
||||
or get_secret_str("AZURE_API_KEY")
|
||||
)
|
||||
|
||||
azure_client_params = {
|
||||
"api_key": api_key,
|
||||
"api_key": resolved_api_key,
|
||||
"azure_endpoint": api_base,
|
||||
"api_version": api_version,
|
||||
"azure_ad_token": azure_ad_token,
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class AzureOpenAIFilesAPI(BaseAzureLLM):
|
|||
)
|
||||
if openai_client is None:
|
||||
raise ValueError(
|
||||
"AzureOpenAI client is not initialized. Make sure api_key is passed or OPENAI_API_KEY is set in the environment."
|
||||
"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY/AZURE_OPENAI_API_KEY is set in the environment."
|
||||
)
|
||||
|
||||
if _is_async is True:
|
||||
|
|
@ -106,7 +106,7 @@ class AzureOpenAIFilesAPI(BaseAzureLLM):
|
|||
)
|
||||
if openai_client is None:
|
||||
raise ValueError(
|
||||
"AzureOpenAI client is not initialized. Make sure api_key is passed or OPENAI_API_KEY is set in the environment."
|
||||
"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY/AZURE_OPENAI_API_KEY is set in the environment."
|
||||
)
|
||||
|
||||
if _is_async is True:
|
||||
|
|
@ -156,7 +156,7 @@ class AzureOpenAIFilesAPI(BaseAzureLLM):
|
|||
)
|
||||
if openai_client is None:
|
||||
raise ValueError(
|
||||
"AzureOpenAI client is not initialized. Make sure api_key is passed or OPENAI_API_KEY is set in the environment."
|
||||
"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY/AZURE_OPENAI_API_KEY is set in the environment."
|
||||
)
|
||||
|
||||
if _is_async is True:
|
||||
|
|
@ -208,7 +208,7 @@ class AzureOpenAIFilesAPI(BaseAzureLLM):
|
|||
)
|
||||
if openai_client is None:
|
||||
raise ValueError(
|
||||
"AzureOpenAI client is not initialized. Make sure api_key is passed or OPENAI_API_KEY is set in the environment."
|
||||
"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY/AZURE_OPENAI_API_KEY is set in the environment."
|
||||
)
|
||||
|
||||
if _is_async is True:
|
||||
|
|
@ -262,7 +262,7 @@ class AzureOpenAIFilesAPI(BaseAzureLLM):
|
|||
)
|
||||
if openai_client is None:
|
||||
raise ValueError(
|
||||
"AzureOpenAI client is not initialized. Make sure api_key is passed or OPENAI_API_KEY is set in the environment."
|
||||
"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY/AZURE_OPENAI_API_KEY is set in the environment."
|
||||
)
|
||||
|
||||
if _is_async is True:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue