fix(gemini-embeddings): convert task_type to camelCase taskType for Gemini API#24191
Merged
RheagalFire merged 1 commit intoBerriAI:litellm_oss_staging_03_19_2026from Mar 20, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR fixes a long-standing silent bug where LiteLLM was sending Changes:
Notes:
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_transformation.py | Adds task_type → taskType key conversion in both transformation functions, correctly following the existing dimensions → outputDimensionality pattern. Change is minimal, correct, and complete. |
| tests/litellm/llms/vertex_ai/test_gemini_batch_embeddings.py | Adds three new mock-based unit tests that verify snake_case→camelCase conversion for both API paths and camelCase passthrough. All tests are properly mocked (no real network calls). Minor: camelCase passthrough is only tested for the embed_content path, not the batch path. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User calls litellm.embedding with task_type param] --> B{Which path?}
B -->|text-only, non-multimodal| C[transform_openai_input_gemini_content\nbatchEmbedContents path]
B -->|multimodal / gemini-embedding-2-preview| D[transform_openai_input_gemini_embed_content\nembedContent path]
C --> E{task_type in gemini_params?}
E -->|Yes - BEFORE fix| F1["❌ Sends task_type\n(silently ignored by API)"]
E -->|Yes - AFTER fix| G1["✅ Renames to taskType\n(accepted by API)"]
E -->|No| H1[Pass through unchanged]
D --> I{task_type in gemini_params?}
I -->|Yes - BEFORE fix| F2["❌ Sends task_type\n(silently ignored by API)"]
I -->|Yes - AFTER fix| G2["✅ Renames to taskType\n(accepted by API)"]
I -->|No| H2[Pass through unchanged]
G1 --> J1[EmbedContentRequest with taskType field]
H1 --> J1
G2 --> J2[embedContent request body with taskType field]
H2 --> J2
Last reviewed commit: "fix(gemini-embedding..."
Contributor
…emini API The Gemini REST API documents the embedding task type parameter as camelCase `taskType`. The existing transformation functions convert `dimensions` to `outputDimensionality` but miss the parallel `task_type` to `taskType` conversion. This adds that conversion to both `transform_openai_input_gemini_content` (batchEmbedContents path) and `transform_openai_input_gemini_embed_content` (embedContent path). Fixes BerriAI#24190
bf63136 to
ed764f7
Compare
RheagalFire
approved these changes
Mar 20, 2026
589c6cd
into
BerriAI:litellm_oss_staging_03_19_2026
39 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #24190
What
taskType(ref)task_typeGeminiEmbedContentRequestBody) define it as camelCasetaskTypeThe existing code converts
dimensions→outputDimensionalitybut misses the paralleltask_type→taskTypeconversion.Fix
Adds
task_type→taskTypeconversion to both transformation functions inbatch_embed_content_transformation.py, following the existingdimensionspattern:Tests added
test_task_type_mapped_to_camel_case_batch— snake_case conversion for batchEmbedContents pathtest_task_type_mapped_to_camel_case_embed_content— snake_case conversion for embedContent pathtest_task_type_camel_case_passthrough— camelCasetaskTypepassed directly is preservedAll 23 tests in
test_gemini_batch_embeddings.pypass.