Skip to content

fix(embeddings): allow dimensions param passthrough via allowed_openai_params for non-text-embedding-3 OpenAI models - #22144

Merged
Sameerlite merged 2 commits into
mainfrom
litellm_allowed_openai_params_embeddings
Feb 26, 2026
Merged

fix(embeddings): allow dimensions param passthrough via allowed_openai_params for non-text-embedding-3 OpenAI models#22144
Sameerlite merged 2 commits into
mainfrom
litellm_allowed_openai_params_embeddings

Conversation

@Sameerlite

Copy link
Copy Markdown
Contributor

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.

Relevant issues

Pre-Submission checklist

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

  • I have Added testing in the tests/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

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

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

Changes

…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>
@vercel

vercel Bot commented Feb 26, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 26, 2026 4:34am

Request Review

@greptile-apps

greptile-apps Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds an allowed_openai_params passthrough mechanism to the embedding call stack, allowing non-text-embedding-3 OpenAI models (e.g., nvidia/llama-3.2-nv-embedqa-1b-v2) to accept the dimensions parameter without raising UnsupportedParamsError. The change is minimal and well-scoped.

  • litellm/main.py: Extracts allowed_openai_params from kwargs and passes it to get_optional_params_embeddings
  • litellm/utils.py: Adds allowed_openai_params parameter to skip the dimensions restriction when the param is explicitly allowed
  • Tests added in tests/local_testing/ covering both the allow and reject paths
  • Note: The PR adds tests only in tests/local_testing/, not in tests/litellm/ as required by the contribution checklist
  • The pre-existing error message on line 3202 is misleading (says "not supported for text-embedding-3" when it should say "only supported for text-embedding-3")

Confidence Score: 4/5

  • This PR is safe to merge — it adds a non-breaking opt-in bypass for a parameter restriction with proper guard conditions.
  • The change is minimal and backwards-compatible. The existing behavior is preserved when allowed_openai_params is not passed. Tests cover both the happy path and the error path. Minor issues: a leftover debug log and a pre-existing misleading error message.
  • litellm/utils.py has a debug log that should be removed before merge

Important Files Changed

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"]
Loading

Last reviewed commit: 3634b5f

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment thread litellm/utils.py
elif custom_llm_provider == "openai":
# 'dimensions` is only supported in `text-embedding-3` and later models

if (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Suggested change
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!

@greptile-apps

greptile-apps Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor
Additional Comments (1)

litellm/utils.py
Pre-existing: misleading error message

The error message says "Setting dimensions is not supported for OpenAI text-embedding-3 and later models" — but the condition triggers for models that are not text-embedding-3. The message should say something like "Setting dimensions is only supported for OpenAI text-embedding-3 and later models" (note: "only supported for" instead of "not supported for"). This bug predates this PR but is worth fixing here since you're already modifying this block.

            raise UnsupportedParamsError(
                status_code=500,
                message="Setting dimensions is only supported for OpenAI `text-embedding-3` and later models. To drop it from the call, set `litellm.drop_params = True`.",
            )

@Sameerlite
Sameerlite merged commit dc1e97d into main Feb 26, 2026
65 of 90 checks passed
@ishaan-berri
ishaan-berri deleted the litellm_allowed_openai_params_embeddings branch March 26, 2026 22:29
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…params_embeddings

fix(embeddings): allow dimensions param passthrough via allowed_openai_params for non-text-embedding-3 OpenAI models
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.

1 participant