Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions litellm/litellm_core_utils/get_provider_specific_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ def get_provider_specific_headers(
custom_llm_provider: Optional[str],
) -> Dict:
"""
Get the provider specific headers for the given custom llm provider
Get the provider specific headers for the given custom llm provider.

Supports comma-separated provider lists for headers that work across multiple providers.

Returns:
Optional[Dict]: The provider specific headers for the given custom llm provider
Dict: The provider specific headers for the given custom llm provider
"""
if (
provider_specific_header is not None
and provider_specific_header.get("custom_llm_provider") == custom_llm_provider
):
if provider_specific_header is None or custom_llm_provider is None:
return {}

stored_providers = provider_specific_header.get("custom_llm_provider", "")
provider_list = [p.strip() for p in stored_providers.split(",")]

if custom_llm_provider in provider_list:
return provider_specific_header.get("extra_headers", {})
return {}

return {}
4 changes: 3 additions & 1 deletion litellm/proxy/litellm_pre_call_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,8 +1252,10 @@ def add_provider_specific_headers_to_request(
added_header = True

if added_header is True:
# Anthropic headers work across multiple providers
# Store as comma-separated list so retrieval can match any of them
data["provider_specific_header"] = ProviderSpecificHeader(
custom_llm_provider="anthropic",
custom_llm_provider="anthropic,bedrock,bedrock_converse,vertex_ai",
extra_headers=anthropic_headers,
)

Expand Down
Loading
Loading