diff --git a/litellm/llms/anthropic/chat/handler.py b/litellm/llms/anthropic/chat/handler.py index e85c0d0d01..f51adf9610 100644 --- a/litellm/llms/anthropic/chat/handler.py +++ b/litellm/llms/anthropic/chat/handler.py @@ -58,6 +58,9 @@ from litellm.types.utils import ( from ...base import BaseLLM from ..common_utils import AnthropicError, process_anthropic_headers +from litellm.anthropic_beta_headers_manager import ( + update_headers_with_filtered_beta, +) from .transformation import AnthropicConfig if TYPE_CHECKING: @@ -333,6 +336,10 @@ class AnthropicChatCompletion(BaseLLM): litellm_params=litellm_params, ) + headers = update_headers_with_filtered_beta( + headers=headers, provider=custom_llm_provider + ) + config = ProviderConfigManager.get_provider_chat_config( model=model, provider=LlmProviders(custom_llm_provider), diff --git a/litellm/llms/bedrock/chat/converse_handler.py b/litellm/llms/bedrock/chat/converse_handler.py index d5bd054118..25af852e09 100644 --- a/litellm/llms/bedrock/chat/converse_handler.py +++ b/litellm/llms/bedrock/chat/converse_handler.py @@ -13,7 +13,9 @@ from litellm.llms.custom_httpx.http_handler import ( ) from litellm.types.utils import ModelResponse from litellm.utils import CustomStreamWrapper - +from litellm.anthropic_beta_headers_manager import ( + update_headers_with_filtered_beta, + ) from ..base_aws_llm import BaseAWSLLM, Credentials from ..common_utils import BedrockError from .invoke_handler import AWSEventStreamDecoder, MockResponseIterator, make_call @@ -337,7 +339,11 @@ class BedrockConverseLLM(BaseAWSLLM): headers = {"Content-Type": "application/json"} if extra_headers is not None: headers = {"Content-Type": "application/json", **extra_headers} - + + # Filter beta headers in HTTP headers before making the request + headers = update_headers_with_filtered_beta( + headers=headers, provider="bedrock_converse" + ) ### ROUTING (ASYNC, STREAMING, SYNC) if acompletion: if isinstance(client, HTTPHandler): diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.py index 95db8ec64b..30927ec7bf 100644 --- a/litellm/llms/custom_httpx/llm_http_handler.py +++ b/litellm/llms/custom_httpx/llm_http_handler.py @@ -81,6 +81,9 @@ from litellm.types.llms.anthropic_skills import ( ListSkillsResponse, Skill, ) +from litellm.anthropic_beta_headers_manager import ( + update_headers_with_filtered_beta, + ) from litellm.types.llms.openai import ( CreateBatchRequest, CreateFileRequest, @@ -1858,6 +1861,13 @@ class BaseLLMHTTPHandler: api_key=api_key, api_base=api_base, ) + + print( "đŸ”¥headers before filtering", headers ) + print( "đŸ”¥custom_llm_provider", custom_llm_provider ) + headers = update_headers_with_filtered_beta( + headers=headers, provider=custom_llm_provider + ) + print( "đŸ”¥headers after filtering", headers ) logging_obj.update_environment_variables( model=model,