Skip to content

fix(bedrock): handle cohere v4 embed response dictionary format - #17220

Merged
1 commit merged into
BerriAI:mainfrom
AndyForest:fix/bedrock-cohere-v4
Nov 28, 2025
Merged

1 commit merged into
BerriAI:mainfrom
AndyForest:fix/bedrock-cohere-v4

Conversation

@AndyForest

Copy link
Copy Markdown
Contributor

Title

Fix parsing of bedrock cohere embed v4 responses

Relevant issues

This PR fixes an issue where bedrock/cohere.embed-v4 models return a dictionary of embeddings (keyed by type, e.g., float, int8) instead of a flat list, causing LiteLLM to incorrectly parse the response.

Previously, LiteLLM would iterate over the dictionary keys (returning ["float", "int8"]) instead of the actual embedding vectors. This change explicitly checks if the embeddings field in the response is a dictionary and handles it as embeddings_by_type.

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
litellm-tests-screenshot-bedrock-cohere-v4-fix

I have also verified this in a live integration environment using bedrock/cohere.embed-v4:0 as well as confirming other embedding models are not affected such as bedrock/cohere.embed-multilingual-v3 and bedrock/amazon.titan-embed-text-v2:0.

Type

🐛 Bug Fix
✅ Test

Changes

litellm/llms/cohere/embed/v1_transformation.py
Added new code here to check the returned data.

tests/test_litellm/llms/bedrock/embed/test_bedrock_cohere_v4.py
I have added a new unit test that mocks the Cohere v4 response structure.

@vercel

vercel Bot commented Nov 27, 2025

Copy link
Copy Markdown

@AndyForest is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

@ghost
ghost merged commit 8aa4f3d into BerriAI:main Nov 28, 2025
4 of 6 checks passed
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant