litellm - ✅(Solved) Fix [Bug]: `multimodalembedding` silently drops `dimensions` parameter — `outputDimensionality` never placed in request body [2 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#24392Fetched 2026-04-08 01:18:04
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2labeled ×2closed ×1referenced ×1

Root Cause

The parameter mapping chain works correctly up to a point, but the final step fails:

  1. map_openai_params in VertexAIMultimodalEmbeddingConfig (line 39-41) correctly maps dimensionsoutputDimensionality in optional_params
  2. transform_embedding_request (line 176-204) receives optional_params containing outputDimensionality, but never places it in the request body

The Vertex AI multimodal embedding API expects:

{
  "instances": [...],
  "parameters": {
    "outputDimensionality": 128
  }
}

But transform_embedding_request only builds {"instances": [...]} — the parameters field is never added. The VertexMultimodalEmbeddingRequest TypedDict also lacks a parameters field.

Affected file: litellm/llms/vertex_ai/multimodal_embeddings/transformation.py

Fix Action

Fixed

PR fix notes

PR #24415: fix(vertex_ai): forward dimensions parameter in multimodalembedding requests

Description (problem / solution / changelog)

Relevant issues

Fixes https://github.com/BerriAI/litellm/issues/24392

Pre-Submission checklist

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • 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
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Type

🐛 Bug Fix

Changes

The dimensions parameter was correctly mapped to outputDimensionality in map_openai_params, but transform_embedding_request never placed it in the request body. The Vertex AI multimodal embedding predict endpoint expects it as dimension under a parameters field (docs):

{
  "instances": [...],
  "parameters": {"dimension": 128}
}

Without this fix, the request always omits parameters, so the API returns the default 1408-dim embedding regardless of the dimensions value.

Note: The Vertex AI multimodal embedding API uses dimension (not outputDimensionality which is the Gemini embedContent API param). Verified empirically with curl against the live API.

Changes

  • litellm/types/llms/vertex_ai.py: Added optional parameters field to VertexMultimodalEmbeddingRequest
  • litellm/llms/vertex_ai/multimodal_embeddings/transformation.py: Extract outputDimensionality from optional_params and map it to dimension in the request body

Tests added

  • test_dimensions_parameter_forwarded_as_output_dimensionality — verifies dimensions=128 produces parameters.dimension=128 in the request
  • test_no_parameters_field_when_dimensions_not_set — verifies no parameters field when dimensions is not specified

Changed files

  • litellm/llms/vertex_ai/multimodal_embeddings/transformation.py (modified, +5/-0)
  • litellm/types/llms/vertex_ai.py (modified, +3/-2)
  • tests/test_litellm/llms/vertex_ai/multimodal_embeddings/test_vertex_ai_multimodal_embedding_transformation.py (modified, +32/-0)

PR #24428: Litellm staging 03 23 2026

Description (problem / solution / changelog)

Relevant issues

<!-- e.g. "Fixes #000" -->

Pre-Submission checklist

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

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • 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
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

<!-- Select the type of Pull Request --> <!-- Keep only the necessary ones -->

🆕 New Feature 🐛 Bug Fix 🧹 Refactoring 📖 Documentation 🚄 Infrastructure ✅ Test

Changes

Changed files

  • docs/my-website/docs/integrations/observability_index.md (modified, +28/-1)
  • litellm/completion_extras/litellm_responses_transformation/transformation.py (modified, +9/-91)
  • litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py (modified, +12/-0)
  • litellm/llms/vertex_ai/multimodal_embeddings/transformation.py (modified, +5/-0)
  • litellm/model_prices_and_context_window_backup.json (modified, +83/-96)
  • litellm/responses/format_mapping.py (added, +342/-0)
  • litellm/responses/litellm_completion_transformation/transformation.py (modified, +14/-203)
  • litellm/responses/utils.py (modified, +3/-73)
  • litellm/types/llms/vertex_ai.py (modified, +3/-2)
  • model_prices_and_context_window.json (modified, +268/-182)
  • tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py (modified, +82/-0)
  • tests/test_litellm/llms/vertex_ai/multimodal_embeddings/test_vertex_ai_multimodal_embedding_transformation.py (modified, +32/-0)
  • tests/test_litellm/responses/test_format_mapping.py (added, +304/-0)
  • tests/test_litellm/test_claude_opus_4_6_config.py (modified, +38/-21)
  • tests/test_litellm/test_claude_sonnet_4_6_config.py (added, +161/-0)

Code Example

{
  "instances": [...],
  "parameters": {
    "outputDimensionality": 128
  }
}

---

import litellm

# dimensions parameter is silently ignored
response = litellm.embedding(
    model="vertex_ai/multimodalembedding",
    input="Hello world",
    dimensions=128,  # expected 128-dim output
    vertex_project="your-project",
    vertex_location="us-central1",
)

print(len(response.data[0]["embedding"]))  # Always 1408, never 128

---

curl -X POST http://localhost:4000/v1/embeddings \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{"model": "multimodalembedding", "input": "test", "dimensions": 128}'
# Response embedding dim is always 1408

---

def transform_embedding_request(self, model, input, optional_params, headers):
    optional_params = optional_params or {}
    request_data = VertexMultimodalEmbeddingRequest(instances=[])
    
    # ... existing instance building logic ...
    
    # Add parameters field if outputDimensionality is set
    if "outputDimensionality" in optional_params:
        request_data["parameters"] = {
            "outputDimensionality": optional_params["outputDimensionality"]
        }
    
    return cast(dict, request_data)

---

class VertexMultimodalEmbeddingRequest(TypedDict, total=False):
    instances: Required[List[Instance]]
    parameters: dict  # Add this
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

When using vertex_ai/multimodalembedding with the dimensions parameter, the parameter is silently dropped. The returned embedding always has the default dimension (1408), regardless of what dimensions value is set.

Root Cause

The parameter mapping chain works correctly up to a point, but the final step fails:

  1. map_openai_params in VertexAIMultimodalEmbeddingConfig (line 39-41) correctly maps dimensionsoutputDimensionality in optional_params
  2. transform_embedding_request (line 176-204) receives optional_params containing outputDimensionality, but never places it in the request body

The Vertex AI multimodal embedding API expects:

{
  "instances": [...],
  "parameters": {
    "outputDimensionality": 128
  }
}

But transform_embedding_request only builds {"instances": [...]} — the parameters field is never added. The VertexMultimodalEmbeddingRequest TypedDict also lacks a parameters field.

Affected file: litellm/llms/vertex_ai/multimodal_embeddings/transformation.py

Steps to Reproduce

import litellm

# dimensions parameter is silently ignored
response = litellm.embedding(
    model="vertex_ai/multimodalembedding",
    input="Hello world",
    dimensions=128,  # expected 128-dim output
    vertex_project="your-project",
    vertex_location="us-central1",
)

print(len(response.data[0]["embedding"]))  # Always 1408, never 128

Via proxy (curl):

curl -X POST http://localhost:4000/v1/embeddings \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{"model": "multimodalembedding", "input": "test", "dimensions": 128}'
# Response embedding dim is always 1408

All of these also fail (tested against a live LiteLLM proxy):

  • dimensions=128/256/512/1024 via OpenAI format
  • outputDimensionality=128 as raw param
  • extra_body={"parameters": {"outputDimensionality": 128}}

Suggested Fix

In transformation.py, transform_embedding_request should extract outputDimensionality from optional_params and add it to the request body:

def transform_embedding_request(self, model, input, optional_params, headers):
    optional_params = optional_params or {}
    request_data = VertexMultimodalEmbeddingRequest(instances=[])
    
    # ... existing instance building logic ...
    
    # Add parameters field if outputDimensionality is set
    if "outputDimensionality" in optional_params:
        request_data["parameters"] = {
            "outputDimensionality": optional_params["outputDimensionality"]
        }
    
    return cast(dict, request_data)

And VertexMultimodalEmbeddingRequest in litellm/types/llms/vertex_ai.py needs a parameters field:

class VertexMultimodalEmbeddingRequest(TypedDict, total=False):
    instances: Required[List[Instance]]
    parameters: dict  # Add this

What part of LiteLLM is this about?

SDK (litellm Python package)

What LiteLLM version are you on ?

main branch (also affects all released versions)

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

To fix the issue, we need to modify two parts of the code:

  • Update the transform_embedding_request function in transformation.py to include the parameters field in the request body.
  • Add a parameters field to the VertexMultimodalEmbeddingRequest TypedDict in litellm/types/llms/vertex_ai.py.

Here are the concrete steps:

  • Modify transform_embedding_request as follows:
def transform_embedding_request(self, model, input, optional_params, headers):
    optional_params = optional_params or {}
    request_data = VertexMultimodalEmbeddingRequest(instances=[])
    
    # ... existing instance building logic ...
    
    # Add parameters field if outputDimensionality is set
    if "outputDimensionality" in optional_params:
        request_data["parameters"] = {
            "outputDimensionality": optional_params["outputDimensionality"]
        }
    
    return cast(dict, request_data)
  • Update VertexMultimodalEmbeddingRequest to include the parameters field:
class VertexMultimodalEmbeddingRequest(TypedDict, total=False):
    instances: Required[List[Instance]]
    parameters: dict  # Add this

Verification

To verify that the fix worked, you can use the following code:

import litellm

response = litellm.embedding(
    model="vertex_ai/multimodalembedding",
    input="Hello world",
    dimensions=128,  
    vertex_project="your-project",
    vertex_location="us-central1",
)

print(len(response.data[0]["embedding"]))  # Should print 128

This should output the correct embedding dimension (128 in this case).

Extra Tips

Make sure to update the litellm package to the latest version after applying these changes. Additionally, you can test the fix using the curl command provided in the issue body to ensure that the API request is correctly formatted.

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 [Bug]: `multimodalembedding` silently drops `dimensions` parameter — `outputDimensionality` never placed in request body [2 pull requests, 1 participants]