Skip to content

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]

Extract 'thinking' from nova response + Add 'drop_params' support for gpt-image-1 (#10680)

Krish Dholakiad6bdd0473a52
diff --git a/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py b/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py
index ca355fe0ed3..5055b5db5a8 100644
--- a/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py
+++ b/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py
@@ -255,7 +255,9 @@ def _parse_content_for_reasoning(
if not message_text:
return None, message_text
- reasoning_match = re.match(r"<think>(.*?)</think>(.*)", message_text, re.DOTALL)
+ reasoning_match = re.match(
+ r"<(?:think|thinking)>(.*?)</(?:think|thinking)>(.*)", message_text, re.DOTALL
+ )
if reasoning_match:
return reasoning_match.group(1), reasoning_match.group(2)
diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py
index 6ec793a11a2..ced66528c97 100644
--- a/litellm/litellm_core_utils/prompt_templates/factory.py
+++ b/litellm/litellm_core_utils/prompt_templates/factory.py
@@ -3158,6 +3158,37 @@ class BedrockConverseMessagesProcessor:
image_url=cast(str, file_id or file_data), format=format
)
+ @staticmethod
+ def add_thinking_blocks_to_assistant_content(
+ thinking_blocks: List[BedrockContentBlock],
+ assistant_parts: List[BedrockContentBlock],
+ ) -> List[BedrockContentBlock]:
+ """
+ If contains 'signature', it is a thinking block.
+ If missing 'signature', it is a text block - e.g. when using a non-anthropic model.
+
+ Handle error raised by bedrock if thinking blocks are provided for a non-thinking model (e.g. nova with tool use)
+
+ Relevant Issue: https://github.com/BerriAI/litellm/issues/9063
+ """
+ filtered_thinking_blocks = []
+ for block in thinking_blocks:
+ reasoning_content = block.get("reasoningContent", None)
+ reasoning_text = (
+ reasoning_content.get("reasoningText", None)
+ if reasoning_content is not None
+ else None
+ )
+ if reasoning_text and not reasoning_text.get("signature"):
+ reasoning_text_text = reasoning_text["text"]
+ assistants_part = BedrockContentBlock(text=reasoning_text_text)
+ assistant_parts.append(assistants_part)
+ else:
+ filtered_thinking_blocks.append(block)
+ if len(filtered_thinking_blocks) > 0:
+ assistant_parts.extend(filtered_thinking_blocks)
+ return assistant_parts
+
def _bedrock_converse_messages_pt( # noqa: PLR0915
messages: List,
@@ -3325,10 +3356,12 @@ def _bedrock_converse_messages_pt( # noqa: PLR0915
)
if thinking_blocks is not None:
- assistant_content.extend(
- BedrockConverseMessagesProcessor.translate_thinking_blocks_to_reasoning_content_blocks(
- thinking_blocks
- )
+ converted_thinking_blocks = BedrockConverseMessagesProcessor.translate_thinking_blocks_to_reasoning_content_blocks(
+ thinking_blocks
+ )
+ assistant_content = BedrockConverseMessagesProcessor.add_thinking_blocks_to_assistant_content(
+ thinking_blocks=converted_thinking_blocks,
+ assistant_parts=assistant_content,
)
if _assistant_content is not None and isinstance(_assistant_content, list):
@@ -3341,7 +3374,10 @@ def _bedrock_converse_messages_pt( # noqa: PLR0915
cast(ChatCompletionThinkingBlock, element)
]
)
- assistants_parts.extend(thinking_block)
+ assistants_parts = BedrockConverseMessagesProcessor.add_thinking_blocks_to_assistant_content(
+ thinking_blocks=thinking_block,
+ assistant_parts=assistants_parts,
+ )
elif element["type"] == "text":
assistants_part = BedrockContentBlock(text=element["text"])
assistants_parts.append(assistants_part)
diff --git a/litellm/llms/base_llm/__init__.py b/litellm/llms/base_llm/__init__.py
new file mode 100644
index 00000000000..cd682a0dbea
--- /dev/null
+++ b/litellm/llms/base_llm/__init__.py
@@ -0,0 +1,13 @@
+from .anthropic_messages.transformation import BaseAnthropicMessagesConfig
+from .audio_transcription.transformation import BaseAudioTranscriptionConfig
+from .chat.transformation import BaseConfig
+from .embedding.transformation import BaseEmbeddingConfig
+from .image_generation.transformation import BaseImageGenerationConfig
+
+__all__ = [
+ "BaseImageGenerationConfig",
+ "BaseConfig",
+ "BaseAudioTranscriptionConfig",
+ "BaseAnthropicMessagesConfig",
+ "BaseEmbeddingConfig",
+]
diff --git a/litellm/llms/base_llm/image_generation/transformation.py b/litellm/llms/base_llm/image_generation/transformation.py
new file mode 100644
index 00000000000..134c95b1c8e
--- /dev/null
+++ b/litellm/llms/base_llm/image_generation/transformation.py
@@ -0,0 +1,95 @@
+from abc import ABC, abstractmethod
+from typing import TYPE_CHECKING, Any, List, Optional, Union
+
+import httpx
+
+from litellm.llms.base_llm.chat.transformation import BaseConfig, BaseLLMException
+from litellm.types.llms.openai import (
+ AllMessageValues,
+ OpenAIImageGenerationOptionalParams,
+)
+from litellm.types.utils import ModelResponse
+
+if TYPE_CHECKING:
+ from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj
+
+ LiteLLMLoggingObj = _LiteLLMLoggingObj
+else:
+ LiteLLMLoggingObj = Any
+
+
+class BaseImageGenerationConfig(BaseConfig, ABC):
+ @abstractmethod
+ def get_supported_openai_params(
+ self, model: str
+ ) -> List[OpenAIImageGenerationOptionalParams]:
+ pass
+
+ def get_complete_url(
+ self,
+ api_base: Optional[str],
+ api_key: Optional[str],
+ model: str,
+ optional_params: dict,
+ litellm_params: dict,
+ stream: Optional[bool] = None,
+ ) -> str:
+ """
+ OPTIONAL
+
+ Get the complete url for the request
+
+ Some providers need `model` in `api_base`
+ """
+ return api_base or ""
+
+ def validate_environment(
+ self,
+ headers: dict,
+ model: str,
+ messages: List[AllMessageValues],
+ optional_params: dict,
+ litellm_params: dict,
+ api_key: Optional[str] = None,
+ api_base: Optional[str] = None,
+ ) -> dict:
+ return {}
+
+ def get_error_class(
+ self, error_message: str, status_code: int, headers: Union[dict, httpx.Headers]
+ ) -> BaseLLMException:
+ raise BaseLLMException(
+ status_code=status_code,
+ message=error_message,
+ headers=headers,
+ )
+
+ def transform_request(
+ self,
+ model: str,
+ messages: List[AllMessageValues],
+ optional_params: dict,
+ litellm_params: dict,
+ headers: dict,
+ ) -> dict:
+ raise NotImplementedError(
+ "ImageVariationConfig implementa 'transform_request_image_variation' for image variation models"
+ )
+
+ def transform_response(
+ self,
+ model: str,
+ raw_response: httpx.Response,
+ model_response: ModelResponse,
+ logging_obj: LiteLLMLoggingObj,
+ request_data: dict,
+ messages: List[AllMessageValues],
+ optional_params: dict,
+ litellm_params: dict,
+ encoding: Any,
+ api_key: Optional[str] = None,
+ json_mode: Optional[bool] = None,
+ ) -> ModelResponse:
+ raise NotImplementedError(
+ "ImageVariationConfig implements 'transform_response_image_variation' for image variation models"
+ )
diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py
index 46fee677b90..7dad73d871d 100644
--- a/litellm/llms/bedrock/chat/converse_transformation.py
+++ b/litellm/llms/bedrock/chat/converse_transformation.py
@@ -12,6 +12,9 @@ import httpx
import litellm
from litellm.litellm_core_utils.core_helpers import map_finish_reason
from litellm.litellm_core_utils.litellm_logging import Logging
+from litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response import (
+ _parse_content_for_reasoning,
+)
from litellm.litellm_core_utils.prompt_templates.factory import (
BedrockConverseMessagesProcessor,
_bedrock_converse_messages_pt,
@@ -756,6 +759,73 @@ class AmazonConverseConfig(BaseConfig):
return message, returned_finish_reason
+ def _translate_message_content(
+ self, content_blocks: List[ContentBlock]
+ ) -> Tuple[
+ str,
+ List[ChatCompletionToolCallChunk],
+ Optional[List[BedrockConverseReasoningContentBlock]],
+ ]:
+ """
+ Translate the message content to a string and a list of tool calls and reasoning content blocks
+
+ Returns:
+ content_str: str
+ tools: List[ChatCompletionToolCallChunk]
+ reasoningContentBlocks: Optional[List[BedrockConverseReasoningContentBlock]]
+ """
+ content_str = ""
+ tools: List[ChatCompletionToolCallChunk] = []
+ reasoningContentBlocks: Optional[
+ List[BedrockConverseReasoningContentBlock]
+ ] = None
+ for idx, content in enumerate(content_blocks):
+ """
+ - Content is either a tool response or text
+ """
+ extracted_reasoning_content_str: Optional[str] = None
+ if "text" in content:
+ (
+ extracted_reasoning_content_str,
+ _content_str,
+ ) = _parse_content_for_reasoning(content["text"])
+ if _content_str is not None:
+ content_str += _content_str
+ if "toolUse" in content:
+ ## check tool name was formatted by litellm
+ _response_tool_name = content["toolUse"]["name"]
+ response_tool_name = get_bedrock_tool_name(
+ response_tool_name=_response_tool_name
+ )
+ _function_chunk = ChatCompletionToolCallFunctionChunk(
+ name=response_tool_name,
+ arguments=json.dumps(content["toolUse"]["input"]),
+ )
+
+ _tool_response_chunk = ChatCompletionToolCallChunk(
+ id=content["toolUse"]["toolUseId"],
+ type="function",
+ function=_function_chunk,
+ index=idx,
+ )
+ tools.append(_tool_response_chunk)
+ if extracted_reasoning_content_str is not None:
+ if reasoningContentBlocks is None:
+ reasoningContentBlocks = []
+ reasoningContentBlocks.append(
+ BedrockConverseReasoningContentBlock(
+ reasoningText=BedrockConverseReasoningTextBlock(
+ text=extracted_reasoning_content_str,
+ )
+ )
+ )
+ if "reasoningContent" in content:
+ if reasoningContentBlocks is None:
+ reasoningContentBlocks = []
+ reasoningContentBlocks.append(content["reasoningContent"])
+
+ return content_str, tools, reasoningContentBlocks
+
def _transform_response(
self,
model: str,
@@ -834,34 +904,11 @@ class AmazonConverseConfig(BaseConfig):
] = None
if message is not None:
- for idx, content in enumerate(message["content"]):
- """
- - Content is either a tool response or text
- """
- if "text" in content:
- content_str += content["text"]
- if "toolUse" in content:
- ## check tool name was formatted by litellm
- _response_tool_name = content["toolUse"]["name"]
- response_tool_name = get_bedrock_tool_name(
- response_tool_name=_response_tool_name
- )
- _function_chunk = ChatCompletionToolCallFunctionChunk(
- name=response_tool_name,
- arguments=json.dumps(content["toolUse"]["input"]),
- )
-
- _tool_response_chunk = ChatCompletionToolCallChunk(
- id=content["toolUse"]["toolUseId"],
- type="function",
- function=_function_chunk,
- index=idx,
- )
- tools.append(_tool_response_chunk)
- if "reasoningContent" in content:
- if reasoningContentBlocks is None:
- reasoningContentBlocks = []
- reasoningContentBlocks.append(content["reasoningContent"])
+ (
+ content_str,
+ tools,
+ reasoningContentBlocks,
+ ) = self._translate_message_content(message["content"])
if reasoningContentBlocks is not None:
chat_completion_message["provider_specific_fields"] = {
diff --git a/litellm/llms/openai/image_generation/__init__.py b/litellm/llms/openai/image_generation/__init__.py
new file mode 100644
index 00000000000..7e6ca6e7ae6
--- /dev/null
+++ b/litellm/llms/openai/image_generation/__init__.py
@@ -0,0 +1,22 @@
+from litellm.llms.base_llm.image_generation.transformation import (
+ BaseImageGenerationConfig,
+)
+
+from .dall_e_2_transformation import DallE2ImageGenerationConfig
+from .dall_e_3_transformation import DallE3ImageGenerationConfig
+from .gpt_transformation import GPTImageGenerationConfig
+
+__all__ = [
+ "DallE2ImageGenerationConfig",
+ "DallE3ImageGenerationConfig",
+ "GPTImageGenerationConfig",
+]
+
+
+def get_openai_image_generation_config(model: str) -> BaseImageGenerationConfig:
+ if model.startswith("dall-e-2"):
+ return DallE2ImageGenerationConfig()
+ elif model.startswith("dall-e-3"):
+ return DallE3ImageGenerationConfig()
+ else:
+ return GPTImageGenerationConfig()
diff --git a/litellm/llms/openai/image_generation/dall_e_2_transformation.py b/litellm/llms/openai/image_generation/dall_e_2_transformation.py
new file mode 100644
index 00000000000..8e306a83375
--- /dev/null
+++ b/litellm/llms/openai/image_generation/dall_e_2_transformation.py
@@ -0,0 +1,38 @@
+from typing import List
+
+from litellm.llms.base_llm.image_generation.transformation import (
+ BaseImageGenerationConfig,
+)
+from litellm.types.llms.openai import OpenAIImageGenerationOptionalParams
+
+
+class DallE2ImageGenerationConfig(BaseImageGenerationConfig):
+ """
+ OpenAI dall-e-2 image generation config
+ """
+
+ def get_supported_openai_params(
+ self, model: str
+ ) -> List[OpenAIImageGenerationOptionalParams]:
+ return ["n", "response_format", "quality", "size", "user"]
+
+ def map_openai_params(
+ self,
+ non_default_params: dict,
+ optional_params: dict,
+ model: str,
+ drop_params: bool,
+ ) -> dict:
+ supported_params = self.get_supported_openai_params(model)
+ for k in non_default_params.keys():
+ if k not in optional_params.keys():
+ if k in supported_params:
+ optional_params[k] = non_default_params[k]
+ elif drop_params:
+ pass
+ else:
+ raise ValueError(
+ f"Parameter {k} is not supported for model {model}. Supported parameters are {supported_params}. Set drop_params=True to drop unsupported parameters."
+ )
+
+ return optional_params
diff --git a/litellm/llms/openai/image_generation/dall_e_3_transformation.py b/litellm/llms/openai/image_generation/dall_e_3_transformation.py
new file mode 100644
index 00000000000..c4b0b66e112
--- /dev/null
+++ b/litellm/llms/openai/image_generation/dall_e_3_transformation.py
@@ -0,0 +1,38 @@
+from typing import List
+
+from litellm.llms.base_llm.image_generation.transformation import (
+ BaseImageGenerationConfig,
+)
+from litellm.types.llms.openai import OpenAIImageGenerationOptionalParams
+
+
+class DallE3ImageGenerationConfig(BaseImageGenerationConfig):
+ """
+ OpenAI dall-e-3 image generation config
+ """
+
+ def get_supported_openai_params(
+ self, model: str
+ ) -> List[OpenAIImageGenerationOptionalParams]:
+ return ["n", "response_format", "quality", "size", "user", "style"]
+
+ def map_openai_params(
+ self,
+ non_default_params: dict,
+ optional_params: dict,
+ model: str,
+ drop_params: bool,
+ ) -> dict:
+ supported_params = self.get_supported_openai_params(model)
+ for k in non_default_params.keys():
+ if k not in optional_params.keys():
+ if k in supported_params:
+ optional_params[k] = non_default_params[k]
+ elif drop_params:
+ pass
+ else:
+ raise ValueError(
+ f"Parameter {k} is not supported for model {model}. Supported parameters are {supported_params}. Set drop_params=True to drop unsupported parameters."
+ )
+
+ return optional_params
diff --git a/litellm/llms/openai/image_generation/gpt_transformation.py b/litellm/llms/openai/image_generation/gpt_transformation.py
new file mode 100644
index 00000000000..1cee13784e7
--- /dev/null
+++ b/litellm/llms/openai/image_generation/gpt_transformation.py
@@ -0,0 +1,47 @@
+from typing import List
+
+from litellm.llms.base_llm.image_generation.transformation import (
+ BaseImageGenerationConfig,
+)
+from litellm.types.llms.openai import OpenAIImageGenerationOptionalParams
+
+
+class GPTImageGenerationConfig(BaseImageGenerationConfig):
+ """
+ OpenAI gpt-image-1 image generation config
+ """
+
+ def get_supported_openai_params(
+ self, model: str
+ ) -> List[OpenAIImageGenerationOptionalParams]:
+ return [
+ "background",
+ "moderation",
+ "n",
+ "output_compression",
+ "output_format",
+ "quality",
+ "size",
+ "user",
+ ]
+
+ def map_openai_params(
+ self,
+ non_default_params: dict,
+ optional_params: dict,
+ model: str,
+ drop_params: bool,
+ ) -> dict:
+ supported_params = self.get_supported_openai_params(model)
+ for k in non_default_params.keys():
+ if k not in optional_params.keys():
+ if k in supported_params:
+ optional_params[k] = non_default_params[k]
+ elif drop_params:
+ pass
+ else:
+ raise ValueError(
+ f"Parameter {k} is not supported for model {model}. Supported parameters are {supported_params}. Set drop_params=True to drop unsupported parameters."
+ )
+
+ return optional_params
diff --git a/litellm/main.py b/litellm/main.py
index 2fb495ab8fc..5198cc7b0a0 100644
--- a/litellm/main.py
+++ b/litellm/main.py
@@ -34,6 +34,7 @@ from typing import (
Type,
Union,
cast,
+ get_args,
)
import dotenv
@@ -73,7 +74,7 @@ from litellm.litellm_core_utils.mock_functions import (
from litellm.litellm_core_utils.prompt_templates.common_utils import (
get_content_from_model_response,
)
-from litellm.llms.base_llm.chat.transformation import BaseConfig
+from litellm.llms.base_llm import BaseConfig, BaseImageGenerationConfig
from litellm.llms.bedrock.common_utils import BedrockModelInfo
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler
from litellm.realtime_api.main import _realtime_health_check
@@ -4661,6 +4662,7 @@ def image_generation( # noqa: PLR0915
if extra_headers is not None:
headers.update(extra_headers)
model_response: ImageResponse = litellm.utils.ImageResponse()
+ dynamic_api_key: Optional[str] = None
if model is not None or custom_llm_provider is not None:
model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider(
model=model, # type: ignore
@@ -4694,6 +4696,18 @@ def image_generation( # noqa: PLR0915
k: v for k, v in kwargs.items() if k not in default_params
} # model-specific params - pass them straight to the model/provider
+ image_generation_config: Optional[BaseImageGenerationConfig] = None
+ if (
+ custom_llm_provider is not None
+ and custom_llm_provider in LlmProviders._member_map_.values()
+ ):
+ image_generation_config = (
+ ProviderConfigManager.get_provider_image_generation_config(
+ model=model,
+ provider=LlmProviders(custom_llm_provider),
+ )
+ )
+
optional_params = get_optional_params_image_gen(
model=model,
n=n,
@@ -4703,6 +4717,7 @@ def image_generation( # noqa: PLR0915
style=style,
user=user,
custom_llm_provider=custom_llm_provider,
+ provider_config=image_generation_config,
**non_default_params,
)
diff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yaml
index da1a17094f1..732265548d6 100644
--- a/litellm/proxy/_new_secret_config.yaml
+++ b/litellm/proxy/_new_secret_config.yaml
@@ -51,11 +51,9 @@ model_list:
model_info:
input_cost_per_token: 0.75
output_cost_per_token: 3
- - model_name: "gpt-3.5-turbo"
+ - model_name: gpt-image-1
litellm_params:
- model: gpt-3.5-turbo
- - model_name: gpt-4o-realtime-preview
- litellm_params:
- model: azure/gpt-4o-realtime-preview
- api_key: os.environ/AZURE_SWEDEN_API_KEY
- api_base: os.environ/AZURE_SWEDEN_API_BASE
\ No newline at end of file
+ model: gpt-image-1
+ api_key: os.environ/OPENAI_API_KEY
+ # drop_params: true
+
diff --git a/litellm/types/llms/openai.py b/litellm/types/llms/openai.py
index 73957a67671..a8090c41086 100644
--- a/litellm/types/llms/openai.py
+++ b/litellm/types/llms/openai.py
@@ -900,6 +900,20 @@ OpenAIAudioTranscriptionOptionalParams = Literal[
OpenAIImageVariationOptionalParams = Literal["n", "size", "response_format", "user"]
+OpenAIImageGenerationOptionalParams = Literal[
+ "background",
+ "moderation",
+ "n",
+ "output_compression",
+ "output_format",
+ "quality",
+ "response_format",
+ "size",
+ "style",
+ "user",
+]
+
+
class ComputerToolParam(TypedDict, total=False):
display_height: Required[float]
"""The height of the computer display."""
diff --git a/litellm/utils.py b/litellm/utils.py
index 4c2c36ed8e1..376eb7899f7 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -228,6 +228,9 @@ from litellm.llms.base_llm.chat.transformation import BaseConfig
from litellm.llms.base_llm.completion.transformation import BaseTextCompletionConfig
from litellm.llms.base_llm.embedding.transformation import BaseEmbeddingConfig
from litellm.llms.base_llm.files.transformation import BaseFilesConfig
+from litellm.llms.base_llm.image_generation.transformation import (
+ BaseImageGenerationConfig,
+)
from litellm.llms.base_llm.image_variations.transformation import (
BaseImageVariationConfig,
)
@@ -2210,12 +2213,16 @@ def get_optional_params_image_gen(
user: Optional[str] = None,
custom_llm_provider: Optional[str] = None,
additional_drop_params: Optional[bool] = None,
+ provider_config: Optional[BaseImageGenerationConfig] = None,
+ drop_params: Optional[bool] = None,
**kwargs,
):
# retrieve all parameters passed to the function
passed_params = locals()
model = passed_params.pop("model", None)
custom_llm_provider = passed_params.pop("custom_llm_provider")
+ provider_config = passed_params.pop("provider_config", None)
+ drop_params = passed_params.pop("drop_params", None)
additional_drop_params = passed_params.pop("additional_drop_params", None)
special_params = passed_params.pop("kwargs")
for k, v in special_params.items():
@@ -2247,7 +2254,7 @@ def get_optional_params_image_gen(
default_params=default_params,
additional_drop_params=additional_drop_params,
)
- optional_params = {}
+ optional_params: Dict[str, Any] = {}
## raise exception if non-default value passed for non-openai/azure embedding calls
def _check_valid_arg(supported_params):
@@ -2255,8 +2262,8 @@ def get_optional_params_image_gen(
keys = list(non_default_params.keys())
for k in keys:
if (
- litellm.drop_params is True and k not in supported_params
- ): # drop the unsupported non-default values
+ litellm.drop_params is True or drop_params is True
+ ) and k not in supported_params: # drop the unsupported non-default values
non_default_params.pop(k, None)
elif k not in supported_params:
raise UnsupportedParamsError(
@@ -2265,7 +2272,18 @@ def get_optional_params_image_gen(
)
return non_default_params
- if (
+ if provider_config is not None:
+ supported_params = provider_config.get_supported_openai_params(
+ model=model or ""
+ )
+ _check_valid_arg(supported_params=supported_params)
+ optional_params = provider_config.map_openai_params(
+ non_default_params=non_default_params,
+ optional_params=optional_params,
+ model=model or "",
+ drop_params=drop_params if drop_params is not None else False,
+ )
+ elif (
custom_llm_provider == "openai"
or custom_llm_provider == "azure"
or custom_llm_provider in litellm.openai_compatible_providers
@@ -6540,6 +6558,19 @@ class ProviderConfigManager:
return BedrockVectorStore.get_initialized_custom_logger()
return None
+ @staticmethod
+ def get_provider_image_generation_config(
+ model: str,
+ provider: LlmProviders,
+ ) -> Optional[BaseImageGenerationConfig]:
+ if LlmProviders.OPENAI == provider:
+ from litellm.llms.openai.image_generation import (
+ get_openai_image_generation_config,
+ )
+
+ return get_openai_image_generation_config(model)
+ return None
+
def get_end_user_id_for_cost_tracking(
litellm_params: dict,
diff --git a/tests/llm_translation/base_llm_unit_tests.py b/tests/llm_translation/base_llm_unit_tests.py
index a50c3c51649..6dc6fea96d8 100644
--- a/tests/llm_translation/base_llm_unit_tests.py
+++ b/tests/llm_translation/base_llm_unit_tests.py
@@ -907,6 +907,8 @@ class BaseLLMChatTest(ABC):
except Exception as e:
print(f"Error: {e}")
pass
+ if "<thinking>" in response.choices[0].message.content and "</thinking>" in response.choices[0].message.content:
+ pytest.fail("Thinking block returned in content instead of separate reasoning_content")
if response.choices[0].message.tool_calls is None:
return
# Add any assertions here to check the response
diff --git a/tests/llm_translation/test_bedrock_completion.py b/tests/llm_translation/test_bedrock_completion.py
index 101e72e3db6..e9eefe1f8e2 100644
--- a/tests/llm_translation/test_bedrock_completion.py
+++ b/tests/llm_translation/test_bedrock_completion.py
@@ -3028,3 +3028,5 @@ def test_bedrock_application_inference_profile():
"https://bedrock-runtime.eu-central-1.amazonaws.com/"
)
assert mock_post2.call_args.kwargs["url"] == mock_post.call_args.kwargs["url"]
+
+
diff --git a/tests/llm_translation/test_bedrock_nova_json.py b/tests/llm_translation/test_bedrock_nova_json.py
index 3b543756659..dbb28b0c05a 100644
--- a/tests/llm_translation/test_bedrock_nova_json.py
+++ b/tests/llm_translation/test_bedrock_nova_json.py
@@ -26,9 +26,15 @@ class TestBedrockNovaJson(BaseLLMChatTest):
"""Test that tool calls with no arguments is translated correctly. Relevant issue: https://github.com/BerriAI/litellm/issues/6833"""
pass
- @pytest.fixture(autouse=True)
- def skip_non_json_tests(self, request):
- if not "json" in request.function.__name__.lower():
- pytest.skip(
- f"Skipping non-JSON test: {request.function.__name__} does not contain 'json'"
- )
+ def test_prompt_caching(self):
+ """
+ Remove override once we have access to Bedrock prompt caching
+ """
+ pass
+
+ # @pytest.fixture(autouse=True)
+ # def skip_non_json_tests(self, request):
+ # if not "json" in request.function.__name__.lower():
+ # pytest.skip(
+ # f"Skipping non-JSON test: {request.function.__name__} does not contain 'json'"
+ # )