The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Support returning virtual key in custom auth + Handle provider-specific optional params for embedding calls (#11346)
Krish Dholakia4611b821ecb1
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex dd98498e3be..46bb1348dc5 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -24,7 +24,7 @@ repos:rev: 7.0.0 # The version of flake8 to usehooks:- id: flake8- exclude: ^litellm/tests/|^litellm/proxy/tests/|^litellm/tests/test_litellm/|^tests/test_litellm/+ exclude: ^litellm/tests/|^litellm/proxy/tests/|^litellm/tests/test_litellm/|^tests/test_litellm/|^tests/enterprise/additional_dependencies: [flake8-print]files: (litellm/|litellm_proxy_extras/|enterprise/).*\.py- repo: https://github.com/python-poetry/poetrydiff --git a/litellm/constants.py b/litellm/constants.pyindex 1d69302f5d7..1cf5bef521b 100644--- a/litellm/constants.py+++ b/litellm/constants.py@@ -298,6 +298,15 @@ OPENAI_TRANSCRIPTION_PARAMS = ["timestamp_granularities",]+OPENAI_EMBEDDING_PARAMS = ["dimensions", "encoding_format", "user"]++DEFAULT_EMBEDDING_PARAM_VALUES = {+ **{k: None for k in OPENAI_EMBEDDING_PARAMS},+ "model": None,+ "custom_llm_provider": "",+ "input": None,+}+DEFAULT_CHAT_COMPLETION_PARAM_VALUES = {"functions": None,"function_call": None,diff --git a/litellm/litellm_core_utils/mock_functions.py b/litellm/litellm_core_utils/mock_functions.pyindex 9f62e0479b2..0083a2b1454 100644--- a/litellm/litellm_core_utils/mock_functions.py+++ b/litellm/litellm_core_utils/mock_functions.py@@ -12,6 +12,8 @@ from ..types.utils import (def mock_embedding(model: str, mock_response: Optional[List[float]]):if mock_response is None:mock_response = [0.0] * 1536+ elif mock_response == "error":+ raise Exception("Mock error")return EmbeddingResponse(model=model,data=[Embedding(embedding=mock_response, index=0, object="embedding")],diff --git a/litellm/proxy/auth/user_api_key_auth.py b/litellm/proxy/auth/user_api_key_auth.pyindex ec680f8461f..31f33d92e89 100644--- a/litellm/proxy/auth/user_api_key_auth.py+++ b/litellm/proxy/auth/user_api_key_auth.py@@ -286,6 +286,53 @@ def get_api_key(return api_key, passed_in_key+async def check_api_key_for_custom_headers_or_pass_through_endpoints(+ request: Request,+ route: str,+ pass_through_endpoints: Optional[List[dict]],+ api_key: str,+) -> Union[UserAPIKeyAuth, str]:+ is_mapped_pass_through_route: bool = False+ for mapped_route in LiteLLMRoutes.mapped_pass_through_routes.value: # type: ignore+ if route.startswith(mapped_route):+ is_mapped_pass_through_route = True+ if is_mapped_pass_through_route:+ if request.headers.get("litellm_user_api_key") is not None:+ api_key = request.headers.get("litellm_user_api_key") or ""+ if pass_through_endpoints is not None:+ for endpoint in pass_through_endpoints:+ if isinstance(endpoint, dict) and endpoint.get("path", "") == route:+ ## IF AUTH DISABLED+ if endpoint.get("auth") is not True:+ return UserAPIKeyAuth()+ ## IF AUTH ENABLED+ ### IF CUSTOM PARSER REQUIRED+ if (+ endpoint.get("custom_auth_parser") is not None+ and endpoint.get("custom_auth_parser") == "langfuse"+ ):+ """+ - langfuse returns {'Authorization': 'Basic YW55dGhpbmc6YW55dGhpbmc'}+ - check the langfuse public key if it contains the litellm api key+ """+ import base64++ api_key = api_key.replace("Basic ", "").strip()+ decoded_bytes = base64.b64decode(api_key)+ decoded_str = decoded_bytes.decode("utf-8")+ api_key = decoded_str.split(":")[0]+ else:+ headers = endpoint.get("headers", None)+ if headers is not None:+ header_key = headers.get("litellm_user_api_key", "")+ if (+ isinstance(request.headers, dict)+ and request.headers.get(key=header_key) is not None # type: ignore+ ):+ api_key = request.headers.get(key=header_key) # type: ignore+ return api_key++async def _user_api_key_auth_builder( # noqa: PLR0915request: Request,api_key: str,@@ -315,6 +362,7 @@ async def _user_api_key_auth_builder( # noqa: PLR0915start_time = datetime.now()route: str = get_request_route(request=request)valid_token: Optional[UserAPIKeyAuth] = None+ custom_auth_api_key: bool = Falsetry:# get the request body@@ -361,8 +409,11 @@ async def _user_api_key_auth_builder( # noqa: PLR0915response = await enterprise_custom_auth(request=request, api_key=api_key, user_custom_auth=user_custom_auth)- if response is not None:+ if response is not None and isinstance(response, UserAPIKeyAuth):return UserAPIKeyAuth.model_validate(response)+ elif response is not None and isinstance(response, str):+ api_key = response+ custom_auth_api_key = Trueelif user_custom_auth is not None:response = await user_custom_auth(request=request, api_key=api_key) # type: ignorereturn UserAPIKeyAuth.model_validate(response)@@ -492,44 +543,17 @@ async def _user_api_key_auth_builder( # noqa: PLR0915#### ELSE ###### CHECK PASS-THROUGH ENDPOINTS ##- is_mapped_pass_through_route: bool = False- for mapped_route in LiteLLMRoutes.mapped_pass_through_routes.value: # type: ignore- if route.startswith(mapped_route):- is_mapped_pass_through_route = True- if is_mapped_pass_through_route:- if request.headers.get("litellm_user_api_key") is not None:- api_key = request.headers.get("litellm_user_api_key") or ""- if pass_through_endpoints is not None:- for endpoint in pass_through_endpoints:- if isinstance(endpoint, dict) and endpoint.get("path", "") == route:- ## IF AUTH DISABLED- if endpoint.get("auth") is not True:- return UserAPIKeyAuth()- ## IF AUTH ENABLED- ### IF CUSTOM PARSER REQUIRED- if (- endpoint.get("custom_auth_parser") is not None- and endpoint.get("custom_auth_parser") == "langfuse"- ):- """- - langfuse returns {'Authorization': 'Basic YW55dGhpbmc6YW55dGhpbmc'}- - check the langfuse public key if it contains the litellm api key- """- import base64-- api_key = api_key.replace("Basic ", "").strip()- decoded_bytes = base64.b64decode(api_key)- decoded_str = decoded_bytes.decode("utf-8")- api_key = decoded_str.split(":")[0]- else:- headers = endpoint.get("headers", None)- if headers is not None:- header_key = headers.get("litellm_user_api_key", "")- if (- isinstance(request.headers, dict)- and request.headers.get(key=header_key) is not None # type: ignore- ):- api_key = request.headers.get(key=header_key) # type: ignore+ if not custom_auth_api_key:+ response = await check_api_key_for_custom_headers_or_pass_through_endpoints(+ request=request,+ route=route,+ pass_through_endpoints=pass_through_endpoints,+ api_key=api_key,+ )+ if isinstance(response, str):+ api_key = response+ elif isinstance(response, UserAPIKeyAuth):+ return responseif master_key is None:if isinstance(api_key, str):return UserAPIKeyAuth(diff --git a/litellm/proxy/custom_auth_auto.py b/litellm/proxy/custom_auth_auto.pyindex df6391021c1..47889e61e57 100644--- a/litellm/proxy/custom_auth_auto.py+++ b/litellm/proxy/custom_auth_auto.py@@ -3,15 +3,19 @@ Example custom auth function.This will allow all keys starting with "my-custom-key" to pass through."""+from typing import Union+from fastapi import Requestfrom litellm.proxy._types import UserAPIKeyAuth-async def user_api_key_auth(request: Request, api_key: str) -> UserAPIKeyAuth:+async def user_api_key_auth(+ request: Request, api_key: str+) -> Union[UserAPIKeyAuth, str]:try:if api_key.startswith("my-custom-key"):- return UserAPIKeyAuth(api_key=api_key)+ return "sk-P1zJMdsqCPNN54alZd_ETw"else:raise Exception("Invalid API key")except Exception:diff --git a/litellm/utils.py b/litellm/utils.pyindex d80be1900fb..97d0b104f57 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -64,6 +64,7 @@ from litellm.caching.caching import DualCachefrom litellm.caching.caching_handler import CachingHandlerResponse, LLMCachingHandlerfrom litellm.constants import (DEFAULT_CHAT_COMPLETION_PARAM_VALUES,+ DEFAULT_EMBEDDING_PARAM_VALUES,DEFAULT_MAX_LRU_CACHE_SIZE,DEFAULT_TRIM_RATIO,FUNCTION_DEFINITION_TOKEN_COUNT,@@ -72,6 +73,7 @@ from litellm.constants import (MAX_RETRY_DELAY,MAX_TOKEN_TRIMMING_ATTEMPTS,MINIMUM_PROMPT_CACHE_TOKEN_COUNT,+ OPENAI_EMBEDDING_PARAMS,TOOL_CHOICE_OBJECT_TOKEN_COUNT,)from litellm.integrations.custom_guardrail import CustomGuardrail@@ -2400,21 +2402,17 @@ def get_optional_params_embeddings( # noqa: PLR0915dimensions: Optional[int] = None,custom_llm_provider="",drop_params: Optional[bool] = None,- additional_drop_params: Optional[bool] = None,+ additional_drop_params: Optional[List[str]] = None,**kwargs,):# retrieve all parameters passed to the functionpassed_params = locals()custom_llm_provider = passed_params.pop("custom_llm_provider", None)special_params = passed_params.pop("kwargs")- for k, v in special_params.items():- passed_params[k] = vdrop_params = passed_params.pop("drop_params", None)additional_drop_params = passed_params.pop("additional_drop_params", None)- default_params = {"user": None, "encoding_format": None, "dimensions": None}-def _check_valid_arg(supported_params: Optional[list]):if supported_params is None:return@@ -2433,14 +2431,19 @@ def get_optional_params_embeddings( # noqa: PLR0915message=f"{custom_llm_provider} does not support parameters: {unsupported_params}, for model={model}. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n",)- non_default_params = _get_non_default_params(- passed_params=passed_params,- default_params=default_params,- additional_drop_params=additional_drop_params,+ non_default_params = (+ PreProcessNonDefaultParams.embedding_pre_process_non_default_params(+ passed_params=passed_params,+ special_params=special_params,+ custom_llm_provider=custom_llm_provider,+ additional_drop_params=additional_drop_params,+ model=model,+ ))provider_config: Optional[BaseEmbeddingConfig] = None+ optional_params = {}if (custom_llm_provider is not Noneand custom_llm_provider in LlmProviders._member_map_.values()@@ -2461,8 +2464,6 @@ def get_optional_params_embeddings( # noqa: PLR0915model=model,drop_params=drop_params if drop_params is not None else False,)- final_params = {**optional_params, **kwargs}- return final_params## raise exception if non-default value passed for non-openai/azure embedding callselif custom_llm_provider == "openai":# 'dimensions` is only supported in `text-embedding-3` and later models@@ -2476,6 +2477,8 @@ def get_optional_params_embeddings( # noqa: PLR0915status_code=500,message="Setting dimensions is not supported for OpenAI `text-embedding-3` and later models. To drop it from the call, set `litellm.drop_params = True`.",)+ else:+ optional_params = non_default_paramselif custom_llm_provider == "triton":supported_params = get_supported_openai_params(model=model,@@ -2489,8 +2492,6 @@ def get_optional_params_embeddings( # noqa: PLR0915model=model,drop_params=drop_params if drop_params is not None else False,)- final_params = {**optional_params, **kwargs}- return final_paramselif custom_llm_provider == "databricks":supported_params = get_supported_openai_params(model=model or "",@@ -2501,8 +2502,7 @@ def get_optional_params_embeddings( # noqa: PLR0915optional_params = litellm.DatabricksEmbeddingConfig().map_openai_params(non_default_params=non_default_params, optional_params={})- final_params = {**optional_params, **kwargs}- return final_params+elif custom_llm_provider == "nvidia_nim":supported_params = get_supported_openai_params(model=model or "",@@ -2513,7 +2513,6 @@ def get_optional_params_embeddings( # noqa: PLR0915optional_params = litellm.nvidiaNimEmbeddingConfig.map_openai_params(non_default_params=non_default_params, optional_params={}, kwargs=kwargs)- return optional_paramselif custom_llm_provider == "vertex_ai" or custom_llm_provider == "gemini":supported_params = get_supported_openai_params(model=model,@@ -2527,8 +2526,6 @@ def get_optional_params_embeddings( # noqa: PLR0915) = litellm.VertexAITextEmbeddingConfig().map_openai_params(non_default_params=non_default_params, optional_params={}, kwargs=kwargs)- final_params = {**optional_params, **kwargs}- return final_paramselif custom_llm_provider == "lm_studio":supported_params = (litellm.LmStudioEmbeddingConfig().get_supported_openai_params()@@ -2537,8 +2534,6 @@ def get_optional_params_embeddings( # noqa: PLR0915optional_params = litellm.LmStudioEmbeddingConfig().map_openai_params(non_default_params=non_default_params, optional_params={})- final_params = {**optional_params, **kwargs}- return final_paramselif custom_llm_provider == "bedrock":# if dimensions is in non_default_params -> pass it for model=bedrock/amazon.titan-embed-text-v2if "amazon.titan-embed-text-v1" in model:@@ -2560,8 +2555,6 @@ def get_optional_params_embeddings( # noqa: PLR0915optional_params = object.map_openai_params(non_default_params=non_default_params, optional_params={})- final_params = {**optional_params, **kwargs}- return final_paramselif custom_llm_provider == "mistral":supported_params = get_supported_openai_params(model=model,@@ -2572,8 +2565,6 @@ def get_optional_params_embeddings( # noqa: PLR0915optional_params = litellm.MistralEmbeddingConfig().map_openai_params(non_default_params=non_default_params, optional_params={})- final_params = {**optional_params, **kwargs}- return final_paramselif custom_llm_provider == "jina_ai":supported_params = get_supported_openai_params(model=model,@@ -2584,8 +2575,6 @@ def get_optional_params_embeddings( # noqa: PLR0915optional_params = litellm.JinaAIEmbeddingConfig().map_openai_params(non_default_params=non_default_params, optional_params={})- final_params = {**optional_params, **kwargs}- return final_paramselif custom_llm_provider == "voyage":supported_params = get_supported_openai_params(model=model,@@ -2599,8 +2588,6 @@ def get_optional_params_embeddings( # noqa: PLR0915model=model,drop_params=drop_params if drop_params is not None else False,)- final_params = {**optional_params, **kwargs}- return final_paramselif custom_llm_provider == "infinity":supported_params = get_supported_openai_params(model=model,@@ -2614,8 +2601,6 @@ def get_optional_params_embeddings( # noqa: PLR0915model=model,drop_params=drop_params if drop_params is not None else False,)- final_params = {**optional_params, **kwargs}- return final_paramselif custom_llm_provider == "fireworks_ai":supported_params = get_supported_openai_params(model=model,@@ -2626,8 +2611,6 @@ def get_optional_params_embeddings( # noqa: PLR0915optional_params = litellm.FireworksAIEmbeddingConfig().map_openai_params(non_default_params=non_default_params, optional_params={}, model=model)- final_params = {**optional_params, **kwargs}- return final_paramselif (custom_llm_provider != "openai"@@ -2646,8 +2629,21 @@ def get_optional_params_embeddings( # noqa: PLR0915status_code=500,message=f"Setting {non_default_params} is not supported by {custom_llm_provider}. To drop it from the call, set `litellm.drop_params = True`.",)+ else:+ optional_params = non_default_params+ else:+ optional_params = non_default_params++ final_params = add_provider_specific_params_to_optional_params(+ optional_params=optional_params,+ passed_params=passed_params,+ custom_llm_provider=custom_llm_provider,+ openai_params=list(DEFAULT_EMBEDDING_PARAM_VALUES.keys()),+ additional_drop_params=kwargs.get("additional_drop_params", None),+ )- final_params = {**non_default_params, **kwargs}+ if "extra_body" in final_params and len(final_params["extra_body"]) == 0:+ final_params.pop("extra_body", None)return final_params@@ -2713,6 +2709,79 @@ def _remove_unsupported_params(return non_default_params+class PreProcessNonDefaultParams:+ @staticmethod+ def base_pre_process_non_default_params(+ passed_params: dict,+ special_params: dict,+ custom_llm_provider: str,+ additional_drop_params: Optional[List[str]],+ default_param_values: dict,+ additional_endpoint_specific_params: List[str],+ ) -> dict:+ for k, v in special_params.items():+ if k.startswith("aws_") and (+ custom_llm_provider != "bedrock"+ and not custom_llm_provider.startswith("sagemaker")+ ): # allow dynamically setting boto3 init logic+ continue+ elif k == "hf_model_name" and custom_llm_provider != "sagemaker":+ continue+ elif (+ k.startswith("vertex_")+ and custom_llm_provider != "vertex_ai"+ and custom_llm_provider != "vertex_ai_beta"+ ): # allow dynamically setting vertex ai init logic+ continue+ passed_params[k] = v++ # filter out those parameters that were passed with non-default values+ non_default_params = {+ k: v+ for k, v in passed_params.items()+ if (+ k != "model"+ and k != "custom_llm_provider"+ and k != "api_version"+ and k != "drop_params"+ and k != "allowed_openai_params"+ and k != "additional_drop_params"+ and k not in additional_endpoint_specific_params+ and k in default_param_values+ and v != default_param_values[k]+ and _should_drop_param(+ k=k, additional_drop_params=additional_drop_params+ )+ is False+ )+ }++ return non_default_params++ @staticmethod+ def embedding_pre_process_non_default_params(+ passed_params: dict,+ special_params: dict,+ custom_llm_provider: str,+ additional_drop_params: Optional[List[str]],+ model: str,+ remove_sensitive_keys: bool = False,+ add_provider_specific_params: bool = False,+ ) -> dict:+ non_default_params = (+ PreProcessNonDefaultParams.base_pre_process_non_default_params(+ passed_params=passed_params,+ special_params=special_params,+ custom_llm_provider=custom_llm_provider,+ additional_drop_params=additional_drop_params,+ default_param_values={k: None for k in OPENAI_EMBEDDING_PARAMS},+ additional_endpoint_specific_params=["input"],+ )+ )++ return non_default_params++def pre_process_non_default_params(passed_params: dict,special_params: dict,@@ -2727,41 +2796,14 @@ def pre_process_non_default_params("""# retrieve all parameters passed to the function- for k, v in special_params.items():- if k.startswith("aws_") and (- custom_llm_provider != "bedrock"- and not custom_llm_provider.startswith("sagemaker")- ): # allow dynamically setting boto3 init logic- continue- elif k == "hf_model_name" and custom_llm_provider != "sagemaker":- continue- elif (- k.startswith("vertex_")- and custom_llm_provider != "vertex_ai"- and custom_llm_provider != "vertex_ai_beta"- ): # allow dynamically setting vertex ai init logic- continue- passed_params[k] = v-- # filter out those parameters that were passed with non-default values-- non_default_params = {- k: v- for k, v in passed_params.items()- if (- k != "model"- and k != "custom_llm_provider"- and k != "api_version"- and k != "drop_params"- and k != "allowed_openai_params"- and k != "additional_drop_params"- and k != "messages"- and k in DEFAULT_CHAT_COMPLETION_PARAM_VALUES- and v != DEFAULT_CHAT_COMPLETION_PARAM_VALUES[k]- and _should_drop_param(k=k, additional_drop_params=additional_drop_params)- is False- )- }+ non_default_params = PreProcessNonDefaultParams.base_pre_process_non_default_params(+ passed_params=passed_params,+ special_params=special_params,+ custom_llm_provider=custom_llm_provider,+ additional_drop_params=additional_drop_params,+ default_param_values=DEFAULT_CHAT_COMPLETION_PARAM_VALUES,+ additional_endpoint_specific_params=["messages"],+ )provider_config: Optional[BaseConfig] = Noneif custom_llm_provider is not None and custom_llm_provider in [diff --git a/tests/enterprise/litellm_enterprise/proxy/auth/test_user_api_key_auth.py b/tests/enterprise/litellm_enterprise/proxy/auth/test_user_api_key_auth.pyindex ed91b30030e..a45df5df008 100644--- a/tests/enterprise/litellm_enterprise/proxy/auth/test_user_api_key_auth.py+++ b/tests/enterprise/litellm_enterprise/proxy/auth/test_user_api_key_auth.py@@ -39,3 +39,52 @@ async def test_enterprise_custom_auth_mode_auto_with_error():result = await enterprise_custom_auth(request, "test-api-key", mock_user_auth)assert result is Nonemock_user_auth.assert_called_once_with(request, "test-api-key")+++async def test_enterprise_custom_auth_returns_string():+ from litellm.proxy._types import hash_token++ # Test when enterprise_custom_auth returns a string (LiteLLM virtual key)+ mock_user_auth = AsyncMock(return_value="sk-test-key")+ request = MagicMock(spec=Request)++ with patch(+ "litellm.proxy.auth.user_api_key_auth.enterprise_custom_auth", mock_user_auth+ ), patch("litellm.proxy.proxy_server.master_key", "sk-1234"), patch(+ "litellm.proxy.proxy_server.prisma_client", MagicMock()+ ):+ # Verify the key is correctly handled in _user_api_key_auth_builder+ with patch(+ "litellm.proxy.auth.user_api_key_auth.get_key_object"+ ) as mock_get_key_object:+ mock_get_key_object.return_value = MagicMock(+ token="sk-test-key",+ user_role="internal_user",+ team_id=None,+ user_id="test-user",+ )++ # Call _user_api_key_auth_builder with the returned key+ from litellm.proxy.auth.user_api_key_auth import _user_api_key_auth_builder++ try:+ auth_obj = await _user_api_key_auth_builder(+ request=request,+ api_key="my-custom-key",+ azure_api_key_header="",+ anthropic_api_key_header=None,+ google_ai_studio_api_key_header=None,+ azure_apim_header=None,+ request_data={},+ custom_litellm_key_header=None,+ )+ except Exception as e:+ print("error:", e)++ # Verify get_key_object was called with the correct key+ mock_get_key_object.assert_called_once()+ # The key should be hashed before being passed to get_key_object+ assert mock_get_key_object.call_args[1]["hashed_token"] == hash_token(+ "sk-test-key"+ )diff --git a/tests/llm_translation/test_optional_params.py b/tests/llm_translation/test_optional_params.pyindex 6e5a7f0ac26..79a1dec7449 100644--- a/tests/llm_translation/test_optional_params.py+++ b/tests/llm_translation/test_optional_params.py@@ -1499,4 +1499,14 @@ def test_optional_params_with_additional_drop_params():)print(f"optional_params: {optional_params}")assert "red" not in optional_params- assert "red" not in optional_params["extra_body"]\ No newline at end of file+ assert "red" not in optional_params["extra_body"]++def test_azure_ai_cohere_embed_input_type_param():+ optional_params = get_optional_params_embeddings(+ model="embed-v-4-0",+ custom_llm_provider="azure_ai",+ input_type="text",+ dimensions=1536+ )+ assert optional_params["dimensions"] == 1536+ assert optional_params["extra_body"]["input_type"] == "text"\ No newline at end of filediff --git a/tests/local_testing/test_exceptions.py b/tests/local_testing/test_exceptions.pyindex f4b0b4b6403..32f0a4f84af 100644--- a/tests/local_testing/test_exceptions.py+++ b/tests/local_testing/test_exceptions.py@@ -284,17 +284,14 @@ def test_azure_embedding_exceptions():response = litellm.embedding(model="azure/azure-embedding-model",input="hello",- messages="hello",+ mock_response="error",)pytest.fail(f"Bad request this should have failed but got {response}")except Exception as e:print(vars(e))# CRUCIAL Test - Ensures our exceptions are readable and not overly complicated. some users have complained exceptions will randomly have another exception raised in our exception mapping- assert (- e.message- == "litellm.APIError: AzureException APIError - Embeddings.create() got an unexpected keyword argument 'messages'"- )+ assert str(e) == "Mock error"async def asynctest_completion_azure_exception():