Skip to content

feat: Support dimensions param for Cohere embed v4#20235

Merged
Sameerlite merged 1 commit intoBerriAI:mainfrom
amirzaushnizer:litellm-support-cohere-embed-v4
Feb 2, 2026
Merged

feat: Support dimensions param for Cohere embed v4#20235
Sameerlite merged 1 commit intoBerriAI:mainfrom
amirzaushnizer:litellm-support-cohere-embed-v4

Conversation

@amirzaushnizer
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Feb 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 1, 2026 4:10pm

Request Review

@CLAassistant
Copy link

CLAassistant commented Feb 1, 2026

CLA assistant check
All committers have signed the CLA.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 1, 2026

Greptile Overview

Greptile Summary

Added support for the dimensions parameter for Cohere embed v4 models on Bedrock. The implementation maps the OpenAI-compatible dimensions parameter to Cohere's output_dimension parameter, consistent with the existing Cohere embedding transformation logic. The change extends model detection in utils.py to recognize cohere.embed-v4 models alongside existing v3 models.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are minimal, well-structured, and follow existing patterns in the codebase. The implementation correctly maps OpenAI parameters to Cohere API parameters, consistent with the standard Cohere embedding transformation. No performance concerns or custom rule violations detected.
  • No files require special attention

Important Files Changed

Filename Overview
litellm/llms/bedrock/embed/cohere_transformation.py Added dimensions parameter support, mapping it to output_dimension for Cohere v4
litellm/types/llms/bedrock.py Added output_dimension field to CohereEmbeddingRequest TypedDict
litellm/utils.py Extended model detection to include cohere.embed-v4 alongside cohere.embed-multilingual-v3

Sequence Diagram

sequenceDiagram
    participant User
    participant LiteLLM
    participant Utils
    participant BedrockCohereConfig
    participant BedrockAPI

    User->>LiteLLM: embedding(model="bedrock/cohere.embed-v4:0", input=text, dimensions=512)
    LiteLLM->>Utils: get_optional_params_embeddings()
    Utils->>Utils: Check model contains "cohere.embed-v4"
    Utils->>BedrockCohereConfig: Instantiate BedrockCohereEmbeddingConfig()
    Utils->>BedrockCohereConfig: get_supported_openai_params()
    BedrockCohereConfig-->>Utils: ["encoding_format", "dimensions"]
    Utils->>BedrockCohereConfig: map_openai_params({"dimensions": 512})
    BedrockCohereConfig->>BedrockCohereConfig: Map "dimensions" to "output_dimension"
    BedrockCohereConfig-->>Utils: {"output_dimension": 512}
    Utils-->>LiteLLM: optional_params
    LiteLLM->>BedrockAPI: Invoke with output_dimension=512
    BedrockAPI-->>LiteLLM: Embedding response
    LiteLLM-->>User: EmbeddingResponse
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Collaborator

@Sameerlite Sameerlite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Sameerlite Sameerlite changed the base branch from main to litellm_oss_staging_01_31_2026 February 2, 2026 07:21
@Sameerlite Sameerlite changed the base branch from litellm_oss_staging_01_31_2026 to main February 2, 2026 07:22
@Sameerlite Sameerlite merged commit c13cb4c into BerriAI:main Feb 2, 2026
5 of 8 checks passed
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.

3 participants