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]

fix(bedrock): avoid unchecked cast in token clamp

Devin AI3673327fc425
diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py
index 4ef42664b9f..2b1d9619743 100644
--- a/litellm/llms/bedrock/chat/converse_transformation.py
+++ b/litellm/llms/bedrock/chat/converse_transformation.py
@@ -1007,8 +1007,8 @@ class AmazonConverseConfig(BaseConfig):
)
if param == "max_tokens" or param == "max_completion_tokens":
optional_params["maxTokens"] = (
- self._enforce_min_max_tokens(cast(object, value))
- if self._is_openai_gpt_reasoning_model(model)
+ self._enforce_min_max_tokens(value)
+ if self._is_openai_gpt_reasoning_model(model) and isinstance(value, int)
else value
)
if param == "stream":