Litellm dev 01 22 2025 p4 (#7932)

* feat(main.py): add new 'provider_specific_header' param

allows passing extra header for specific provider

* fix(litellm_pre_call_utils.py): add unit test for pre call utils

* test(test_bedrock_completion.py): skip test now that bedrock supports this
This commit is contained in:
Krish Dholakia 2025-01-22 21:52:07 -08:00 committed by GitHub
parent 4911cd80a1
commit 27560bd5ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 119 additions and 5 deletions

View file

@ -20,6 +20,7 @@ from litellm.proxy._types import (
from litellm.types.llms.anthropic import ANTHROPIC_API_HEADERS
from litellm.types.services import ServiceTypes
from litellm.types.utils import (
ProviderSpecificHeader,
StandardLoggingUserAPIKeyMetadata,
SupportedCacheControls,
)
@ -729,19 +730,20 @@ def add_provider_specific_headers_to_request(
data: dict,
headers: dict,
):
extra_headers = data.get("extra_headers", {}) or {}
anthropic_headers = {}
# boolean to indicate if a header was added
added_header = False
for header in ANTHROPIC_API_HEADERS:
if header in headers:
header_value = headers[header]
extra_headers.update({header: header_value})
anthropic_headers[header] = header_value
added_header = True
if added_header is True:
data["extra_headers"] = extra_headers
data["provider_specific_header"] = ProviderSpecificHeader(
custom_llm_provider="anthropic",
extra_headers=anthropic_headers,
)
return