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]

refactor: build the Converse beta list once and keep the OpenAPI snapshot as CI generates it

mateo-berri3d3a46fc1fcd
diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py
index d1047c8d86c..b213b5e30ba 100644
--- a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py
+++ b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py
@@ -198,6 +198,15 @@ def target_supports_mid_conversation_system(model: str | None, custom_llm_provid
return supports_mid_conversation_system(model=model, custom_llm_provider=custom_llm_provider)
+def _chat_tool_param(function_chunk: ChatCompletionToolParamFunctionChunk, tool: object) -> ChatCompletionToolParam:
+ eager_input_streaming: Final = eager_input_streaming_flag(tool)
+ if eager_input_streaming is None:
+ return ChatCompletionToolParam(type="function", function=function_chunk)
+ return ChatCompletionToolParam(
+ type="function", function=function_chunk, eager_input_streaming=eager_input_streaming
+ )
+
+
class AnthropicAdapter:
def __init__(self) -> None:
pass
@@ -810,14 +819,7 @@ class LiteLLMAnthropicMessagesAdapter:
for k, v in tool.items():
if k not in mapped_tool_params: # pass additional computer kwargs
function_chunk.setdefault("parameters", {}).update({k: v})
- eager_input_streaming = eager_input_streaming_flag(tool)
- tool_param = (
- ChatCompletionToolParam(type="function", function=function_chunk)
- if eager_input_streaming is None
- else ChatCompletionToolParam(
- type="function", function=function_chunk, eager_input_streaming=eager_input_streaming
- )
- )
+ tool_param = _chat_tool_param(function_chunk, tool)
self._add_cache_control_if_applicable(tool, tool_param, model)
new_tools.append(tool_param)
diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py
index 87e28054817..1a32fec45e3 100644
--- a/litellm/llms/bedrock/chat/converse_transformation.py
+++ b/litellm/llms/bedrock/chat/converse_transformation.py
@@ -1518,9 +1518,6 @@ class AmazonConverseConfig(BaseConfig):
"""Process tools and collect anthropic_beta values."""
bedrock_tools: list[ToolBlock] = []
- # Collect anthropic_beta values from user headers
- anthropic_beta_list: Final = list(get_anthropic_beta_from_headers(headers or {}))
-
# Separate pre-formatted Bedrock tools (e.g. systemTool from web_search_options)
# from OpenAI-format tools that need transformation via _bedrock_tools_pt
filtered_tools: Final = []
@@ -1540,6 +1537,17 @@ class AmazonConverseConfig(BaseConfig):
continue
filtered_tools.append(tool)
+ base_model: Final = BedrockModelInfo.get_base_model(model)
+ client_beta_list: Final = get_anthropic_beta_from_headers(headers or {})
+ eager_beta: Final = (
+ (ANTHROPIC_FINE_GRAINED_TOOL_STREAMING_BETA_HEADER,)
+ if base_model.startswith("anthropic")
+ and AnthropicModelInfo().is_eager_input_streaming_used(filtered_tools)
+ and ANTHROPIC_FINE_GRAINED_TOOL_STREAMING_BETA_HEADER not in client_beta_list
+ else ()
+ )
+ anthropic_beta_list: Final = [*client_beta_list, *eager_beta]
+
# Only separate tools if computer use tools are actually present
if filtered_tools and self.is_computer_use_tool_used(filtered_tools, model):
# Separate computer use tools from regular function tools
@@ -1617,7 +1625,6 @@ class AmazonConverseConfig(BaseConfig):
# Opus 4.5 gates ``output_config.effort`` behind a beta header;
# Claude 4.6/4.7 accept it without one.
- base_model: Final = BedrockModelInfo.get_base_model(model)
if base_model.startswith("anthropic"):
output_config: Final = additional_request_params.get("output_config")
if (
@@ -1632,12 +1639,6 @@ class AmazonConverseConfig(BaseConfig):
if ANTHROPIC_EFFORT_BETA_HEADER not in anthropic_beta_list:
anthropic_beta_list.append(ANTHROPIC_EFFORT_BETA_HEADER)
- if (
- AnthropicModelInfo().is_eager_input_streaming_used(filtered_tools)
- and ANTHROPIC_FINE_GRAINED_TOOL_STREAMING_BETA_HEADER not in anthropic_beta_list
- ):
- anthropic_beta_list.append(ANTHROPIC_FINE_GRAINED_TOOL_STREAMING_BETA_HEADER)
-
# Bedrock Converse: compact_20260112 edits only (+ beta header).
AmazonConverseConfig._filter_context_management_for_bedrock_converse(
additional_request_params, anthropic_beta_list
diff --git a/litellm/proxy/_lazy_openapi_snapshot.json b/litellm/proxy/_lazy_openapi_snapshot.json
index 64daa695316..7a4c966a628 100644
--- a/litellm/proxy/_lazy_openapi_snapshot.json
+++ b/litellm/proxy/_lazy_openapi_snapshot.json
@@ -19370,7 +19370,7 @@
}
}
},
- "description": "\nUnified rate-limit error.\n\nEvery rate-limit condition surfaced by litellm \u2014 whether it originated from\nan upstream LLM provider, a vendor batch endpoint, or one of litellm's own\nproxy-side limiters (parallel-requests, dynamic-rate, batch-rate, budget,\nmax-iterations, etc.) \u2014 is raised as an instance of this class.\n\nThe :attr:`category` attribute lets callers distinguish the source. See\n:class:`RateLimitErrorCategory` for the available values.\n"
+ "description": "\n Unified rate-limit error.\n\n Every rate-limit condition surfaced by litellm \u2014 whether it originated from\n an upstream LLM provider, a vendor batch endpoint, or one of litellm's own\n proxy-side limiters (parallel-requests, dynamic-rate, batch-rate, budget,\n max-iterations, etc.) \u2014 is raised as an instance of this class.\n\n The :attr:`category` attribute lets callers distinguish the source. See\n :class:`RateLimitErrorCategory` for the available values.\n "
},
"500": {
"content": {