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]

fix bedrock embeddings - validate env

Ishaan Jafferd9794f081197
diff --git a/litellm/llms/cohere/embed/handler.py b/litellm/llms/cohere/embed/handler.py
index 41b81279723..3ab8baf7ba8 100644
--- a/litellm/llms/cohere/embed/handler.py
+++ b/litellm/llms/cohere/embed/handler.py
@@ -21,14 +21,18 @@ from .v1_transformation import CohereEmbeddingConfig
def validate_environment(api_key, headers: dict):
- headers.update(
- {
- "Request-Source": "unspecified:litellm",
- "accept": "application/json",
- "content-type": "application/json",
- }
- )
- if api_key:
+ # Create a lowercase key lookup to avoid duplicate headers with different cases
+ # This is important when headers come from AWS signed requests (which use Title-Case)
+ existing_keys_lower = {k.lower(): k for k in headers.keys()}
+
+ # Only add headers if they don't already exist (case-insensitive check)
+ if "request-source" not in existing_keys_lower:
+ headers["Request-Source"] = "unspecified:litellm"
+ if "accept" not in existing_keys_lower:
+ headers["accept"] = "application/json"
+ if "content-type" not in existing_keys_lower:
+ headers["content-type"] = "application/json"
+ if api_key and "authorization" not in existing_keys_lower:
headers["Authorization"] = f"Bearer {api_key}"
return headers