litellm - ✅(Solved) Fix Cohere embed-v4 on Bedrock: embedding_types sent as string instead of array → 400 Malformed request [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#25925Fetched 2026-04-17 08:28:09
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1referenced ×1

Calling cohere-embed-v4 (model: bedrock/eu.cohere.embed-v4:0) via the OpenAI-compatible /v1/embeddings endpoint with encoding_format: "float" (or any string value) results in a 400 Bad Request from Bedrock:

litellm.BadRequestError: BedrockException - {"message":"Malformed request. Please check your parameter/values and try again."}. Received Model Group=cohere-embed-v4

Error Message

litellm.BadRequestError: BedrockException - {"message":"Malformed request. Please check your parameter/values and try again."}. Received Model Group=cohere-embed-v4

Root Cause

LiteLLM maps the OpenAI param encoding_format: "float" (string) to Cohere's embedding_types field, but writes it as a string. Cohere's Bedrock embedding API requires embedding_types to be an array of strings (["float"]).

In litellm/llms/cohere/embed/transformation.py, around line 113:

for k, v in inference_params.items():
    transformed_request[k] = v  # type: ignore

The inference_params dict already contains embedding_types: "float" as a string at this point (from the upstream OpenAI-to-Cohere param mapping), and it's written through unchanged.

Fix Action

Fixed

PR fix notes

PR #25927: fix(bedrock/cohere): wrap embedding_types as list when encoding_format is string

Description (problem / solution / changelog)

Problem

Calling cohere-embed-v4 via Bedrock (e.g. bedrock/eu.cohere.embed-v4:0) with encoding_format: "float" causes a 400 Bad Request:

BedrockException - {"message":"Malformed request. Please check your parameter/values and try again."}

The Bedrock Cohere embedding API requires embedding_types to be an array of strings (["float"]), but BedrockCohereEmbeddingConfig.map_openai_params was passing it as a raw string ("float").

Root cause

In litellm/llms/bedrock/embed/cohere_transformation.py:

# Before (bug):
if k == "encoding_format":
    optional_params["embedding_types"] = v  # v is "float" (string)

The parent class CohereEmbeddingConfig already has the correct behaviour (wrapping v in a list), but the Bedrock subclass did not.

Fix

# After:
if k == "encoding_format":
    optional_params["embedding_types"] = v if isinstance(v, list) else [v]

Closes #25925

Changed files

  • litellm/llms/bedrock/embed/cohere_transformation.py (modified, +2/-1)

Code Example

litellm.BadRequestError: BedrockException - {"message":"Malformed request. Please check your parameter/values and try again."}. Received Model Group=cohere-embed-v4

---

for k, v in inference_params.items():
    transformed_request[k] = v  # type: ignore

---

model_list:
  - model_name: cohere-embed-v4
    litellm_params:
      model: bedrock/eu.cohere.embed-v4:0
      aws_region_name: eu-central-1
    model_info:
      mode: embedding

---

curl -X POST http://localhost:4000/v1/embeddings \
  -H "Authorization: Bearer <key>" -H "Content-Type: application/json" \
  -d '{"model":"cohere-embed-v4","input":"test","encoding_format":"float"}'

---

{"input_type": "search_document", "texts": ["test"], "embedding_types": "float"}

---

{"input_type": "search_document", "texts": ["test"], "embedding_types": ["float"]}

---

for k, v in inference_params.items():
    if k == "embedding_types" and isinstance(v, str):
        v = [v]
    transformed_request[k] = v  # type: ignore
RAW_BUFFERClick to expand / collapse

Summary

Calling cohere-embed-v4 (model: bedrock/eu.cohere.embed-v4:0) via the OpenAI-compatible /v1/embeddings endpoint with encoding_format: "float" (or any string value) results in a 400 Bad Request from Bedrock:

litellm.BadRequestError: BedrockException - {"message":"Malformed request. Please check your parameter/values and try again."}. Received Model Group=cohere-embed-v4

Root cause

LiteLLM maps the OpenAI param encoding_format: "float" (string) to Cohere's embedding_types field, but writes it as a string. Cohere's Bedrock embedding API requires embedding_types to be an array of strings (["float"]).

In litellm/llms/cohere/embed/transformation.py, around line 113:

for k, v in inference_params.items():
    transformed_request[k] = v  # type: ignore

The inference_params dict already contains embedding_types: "float" as a string at this point (from the upstream OpenAI-to-Cohere param mapping), and it's written through unchanged.

Reproduction

LiteLLM model config:

model_list:
  - model_name: cohere-embed-v4
    litellm_params:
      model: bedrock/eu.cohere.embed-v4:0
      aws_region_name: eu-central-1
    model_info:
      mode: embedding

Trigger:

curl -X POST http://localhost:4000/v1/embeddings \
  -H "Authorization: Bearer <key>" -H "Content-Type: application/json" \
  -d '{"model":"cohere-embed-v4","input":"test","encoding_format":"float"}'

Result: HTTP 400 with BedrockException - Malformed request.

Same request without encoding_format returns 200 OK, confirming the bug is specifically in this param translation.

The captured payload sent to Bedrock (verified via tracing):

{"input_type": "search_document", "texts": ["test"], "embedding_types": "float"}

Should be:

{"input_type": "search_document", "texts": ["test"], "embedding_types": ["float"]}

Real-world impact

This breaks all OpenAI SDK clients that pass encoding_format (default for many libraries — e.g., the mem0ai package hardcodes encoding_format: "float" in its OSS embedder). Any agent memory layer using Cohere embed-v4 via Bedrock through LiteLLM is broken.

Proposed fix

In litellm/llms/cohere/embed/transformation.py _transform_request:

for k, v in inference_params.items():
    if k == "embedding_types" and isinstance(v, str):
        v = [v]
    transformed_request[k] = v  # type: ignore

Alternatively (cleaner) — wrap during the OpenAI→Cohere param mapping wherever encoding_format becomes embedding_types.

Verified the one-line fix above resolves the issue locally — Cohere embed-v4 on Bedrock now returns 200 OK with the same client request.

Versions

  • LiteLLM: latest in ghcr.io/berriai/litellm:main-stable (pulled 2026-04-17)
  • Bedrock model: eu.cohere.embed-v4:0 (EU cross-region inference profile)
  • Region: eu-central-1

Could someone please open a PR? The fix is small and isolated.

extent analysis

TL;DR

The most likely fix is to modify the litellm/llms/cohere/embed/transformation.py file to correctly handle the encoding_format parameter by converting it to an array of strings when mapping to Cohere's embedding_types field.

Guidance

  • Verify that the issue is indeed caused by the incorrect mapping of encoding_format to embedding_types by checking the request payload sent to Bedrock.
  • Apply the proposed fix in litellm/llms/cohere/embed/transformation.py to convert the embedding_types value to an array of strings when it is a string.
  • Test the fix by sending a request with the encoding_format parameter and verifying that the response is 200 OK.
  • Consider wrapping the encoding_format to embedding_types mapping during the OpenAI-to-Cohere param mapping for a cleaner solution.

Example

for k, v in inference_params.items():
    if k == "embedding_types" and isinstance(v, str):
        v = [v]
    transformed_request[k] = v  # type: ignore

Notes

The fix assumes that the encoding_format parameter will always be a string. If this parameter can have other types, additional handling may be necessary.

Recommendation

Apply the workaround by modifying the litellm/llms/cohere/embed/transformation.py file to correctly handle the encoding_format parameter, as this is a small and isolated fix that resolves the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - ✅(Solved) Fix Cohere embed-v4 on Bedrock: embedding_types sent as string instead of array → 400 Malformed request [1 pull requests, 1 participants]