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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(bedrock): route all cohere.embed models to BedrockCohereEmbeddingConfig
Devin AI7f3ff3b47f35
diff --git a/litellm/utils.py b/litellm/utils.pyindex 520c40f67c0..0cceda85a09 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -3536,7 +3536,7 @@ def get_optional_params_embeddings(object = litellm.AmazonTitanMultimodalEmbeddingG1Config()elif "amazon.titan-embed-text-v2:0" in model:object = litellm.AmazonTitanV2Config()- elif "cohere.embed-multilingual-v3" in model or "cohere.embed-v4" in model:+ elif "cohere.embed" in model:object = litellm.BedrockCohereEmbeddingConfig()elif "twelvelabs" in model or "marengo" in model:object = litellm.TwelveLabsMarengoEmbeddingConfig()diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.pyindex 92033251b13..6381e1a1274 100644--- a/tests/test_litellm/test_utils.py+++ b/tests/test_litellm/test_utils.py@@ -4412,6 +4412,37 @@ class TestVertexEmbeddingEncodingFormat:assert optional_params.get("outputDimensionality") == 256+class TestBedrockCohereEmbeddingDispatch:+ """All bedrock cohere.embed models must route to BedrockCohereEmbeddingConfig,+ not just multilingual-v3/v4: english-v3 was falling into the unmapped+ else-branch and rejecting encoding_format. Issue #38659."""++ @pytest.mark.parametrize(+ "model",+ [+ "cohere.embed-english-v3",+ "cohere.embed-multilingual-v3",+ "cohere.embed-v4:0",+ ],+ )+ def test_cohere_embed_models_accept_encoding_format(self, model):+ optional_params = litellm.utils.get_optional_params_embeddings(+ model=model,+ encoding_format="float",+ custom_llm_provider="bedrock",+ )+ assert optional_params.get("embedding_types") == ["float"]++ def test_cohere_embed_english_v3_maps_dimensions(self):+ optional_params = litellm.utils.get_optional_params_embeddings(+ model="cohere.embed-english-v3",+ encoding_format="float",+ dimensions=512,+ custom_llm_provider="bedrock",+ )+ assert optional_params.get("output_dimension") == 512++@pytest.mark.parametrize("model",[