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]

Add support for forwarding client headers

Sameer Kankutecf286e688598
diff --git a/litellm/llms/bedrock/rerank/handler.py b/litellm/llms/bedrock/rerank/handler.py
index f5a532bec15..06f1e9e86c9 100644
--- a/litellm/llms/bedrock/rerank/handler.py
+++ b/litellm/llms/bedrock/rerank/handler.py
@@ -34,7 +34,7 @@ class BedrockRerankHandler(BaseAWSLLM):
if client is None:
client = get_async_httpx_client(llm_provider=litellm.LlmProviders.BEDROCK)
try:
- response = await client.post(url=prepared_request["endpoint_url"], headers=prepared_request["prepped"].headers, data=prepared_request["body"]) # type: ignore
+ response = await client.post(url=prepared_request["endpoint_url"], headers=dict(prepared_request["prepped"].headers), data=prepared_request["body"])
response.raise_for_status()
except httpx.HTTPStatusError as err:
error_code = err.response.status_code
@@ -84,7 +84,7 @@ class BedrockRerankHandler(BaseAWSLLM):
additional_args={
"complete_input_dict": data,
"api_base": prepared_request["endpoint_url"],
- "headers": prepared_request["prepped"].headers,
+ "headers": dict(prepared_request["prepped"].headers),
},
)
@@ -94,7 +94,7 @@ class BedrockRerankHandler(BaseAWSLLM):
if client is None or not isinstance(client, HTTPHandler):
client = _get_httpx_client()
try:
- response = client.post(url=prepared_request["endpoint_url"], headers=prepared_request["prepped"].headers, data=prepared_request["body"]) # type: ignore
+ response = client.post(url=prepared_request["endpoint_url"], headers=dict(prepared_request["prepped"].headers), data=prepared_request["body"])
response.raise_for_status()
except httpx.HTTPStatusError as err:
error_code = err.response.status_code
diff --git a/litellm/rerank_api/main.py b/litellm/rerank_api/main.py
index 3a2b75e58da..5eb65be6a2c 100644
--- a/litellm/rerank_api/main.py
+++ b/litellm/rerank_api/main.py
@@ -358,6 +358,7 @@ def rerank( # noqa: PLR0915
_is_async=_is_async,
optional_params=optional_params.model_dump(exclude_unset=True),
api_base=api_base,
+ extra_headers=headers or litellm.headers or {},
logging_obj=litellm_logging_obj,
client=client,
)