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