fix(embeddings): allow dimensions param passthrough via allowed_openai_params for non-text-embedding-3 OpenAI models - #22144
Conversation
…i_params for non-text-embedding-3 OpenAI models When calling non-text-embedding-3 models routed through the openai provider (e.g. nvidia/llama-3.2-nv-embedqa-1b-v2), passing `dimensions` previously raised an UnsupportedParamsError unconditionally. This fix threads `allowed_openai_params` through the embedding call stack so that providers can opt-in to passing `dimensions` by including it in the list. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds an
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| litellm/main.py | Extracts allowed_openai_params from kwargs and passes it through to get_optional_params_embeddings. Clean, minimal change. |
| litellm/utils.py | Adds allowed_openai_params parameter to get_optional_params_embeddings and uses it to bypass the dimensions check for non-text-embedding-3 OpenAI models. Contains a debug log that should be removed and a pre-existing misleading error message. |
| tests/local_testing/test_get_optional_params_embeddings.py | Adds two unit tests: one verifying dimensions passes through with allowed_openai_params, one verifying it still raises without. Tests are well-structured but placed in tests/local_testing/ rather than the required tests/litellm/ directory. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["embedding() in main.py"] --> B["Extract allowed_openai_params from kwargs"]
B --> C["Call get_optional_params_embeddings()"]
C --> D{"custom_llm_provider == 'openai'?"}
D -- No --> E["Other provider handling"]
D -- Yes --> F{"model contains 'text-embedding-3'?"}
F -- Yes --> G["Pass all non_default_params through"]
F -- No --> H{"'dimensions' in non_default_params?"}
H -- No --> G
H -- Yes --> I{"'dimensions' in allowed_openai_params?"}
I -- Yes --> G
I -- No --> J["Raise UnsupportedParamsError"]
Last reviewed commit: 3634b5f
| elif custom_llm_provider == "openai": | ||
| # 'dimensions` is only supported in `text-embedding-3` and later models | ||
|
|
||
| if ( |
There was a problem hiding this comment.
Debug log should be removed
This verbose_logger.debug call logs the allowed_openai_params value on every OpenAI embedding call. While not harmful, it appears to be a leftover debugging statement. Consider removing it before merging.
| if ( |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Additional Comments (1)
The error message says "Setting dimensions is not supported for OpenAI |
…params_embeddings fix(embeddings): allow dimensions param passthrough via allowed_openai_params for non-text-embedding-3 OpenAI models
When calling non-text-embedding-3 models routed through the openai provider (e.g. nvidia/llama-3.2-nv-embedqa-1b-v2), passing
dimensionspreviously raised an UnsupportedParamsError unconditionally. This fix threadsallowed_openai_paramsthrough the embedding call stack so that providers can opt-in to passingdimensionsby including it in the list.Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test
Changes