Skip to content

fix: only pass dimensions to OpenAI embeddings API when explicitly configured#4181

Closed
Br1an67 wants to merge 1 commit intomem0ai:mainfrom
Br1an67:fix/issue-4153-openai-dimensions
Closed

fix: only pass dimensions to OpenAI embeddings API when explicitly configured#4181
Br1an67 wants to merge 1 commit intomem0ai:mainfrom
Br1an67:fix/issue-4153-openai-dimensions

Conversation

@Br1an67
Copy link
Copy Markdown
Contributor

@Br1an67 Br1an67 commented Mar 1, 2026

Description

OpenAIEmbedding.embed() always passes dimensions=self.config.embedding_dims to the OpenAI API. For non-matryoshka models served by OpenAI-compatible backends (e.g. vLLM, Ollama), this causes a 400 error because those models don't support the dimensions parameter.

The fix tracks whether embedding_dims was explicitly provided in the config. If not, dimensions is omitted from the API call entirely. When explicitly set, it continues to be passed as before.

Fixes #4153

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit Test

  • Updated 4 existing tests to reflect that dimensions is no longer passed by default

  • Added test_embed_no_dimensions_when_not_configured: verifies dimensions is NOT sent when embedding_dims is not explicitly set

  • Added test_embed_dimensions_when_explicitly_configured: verifies dimensions IS sent when embedding_dims is explicitly set (e.g., 512)

All 7 tests pass.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

…nfigured

Non-matryoshka embedding models (e.g. on vLLM, Ollama) reject the
dimensions parameter with a 400 error. Track whether embedding_dims
was explicitly set and only include it in the API call when it was.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 1, 2026

CLA assistant check
All committers have signed the CLA.

@Br1an67
Copy link
Copy Markdown
Contributor Author

Br1an67 commented Mar 8, 2026

Hi — just a gentle bump on this. Happy to make any changes if needed!

@utkarsh240799
Copy link
Copy Markdown
Contributor

Hi @Br1an67 ,

Thanks for taking the time to come up with the PR. We appreciate it!
The issue has been fixed by PR #4481 . Therefore, closing this PR.

Thanks

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.

OpenAIEmbedding always passes dimensions, breaks non-matryoshka OpenAI-compatible embedding backends

4 participants