fix(embeddings): add allowed_openai_params for OpenAI-compatible embedding dimensions#1320
Merged
nicoloboschi merged 1 commit intovectorize-io:mainfrom Apr 29, 2026
Conversation
…dding dimensions When using litellm-sdk with OpenAI-compatible custom models (model name starts with "openai/"), the "dimensions" parameter is rejected by litellm unless it is explicitly allow-listed via allowed_openai_params. This fix adds the allow-listing so that HINDSIGHT_API_EMBEDDINGS_LITELLM_SDK_OUTPUT_DIMENSIONS works correctly with OpenAI-compatible embedding endpoints. Fixes: custom embedding models with OpenAI-compatible APIs reject the dimensions parameter unless allowed_openai_params includes "dimensions".
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.
What
Fix the
allowed_openai_paramsissue inLiteLLMSDKEmbeddingswhen using OpenAI-compatible custom embedding models.Problem
When using
litellm-sdkas the embeddings provider with an OpenAI-compatible custom model (e.g.,openai/Qwen3-Embedding-4B-4bit-DWQ), thedimensionsparameter is silently rejected by litellm unless it is explicitly allow-listed viaallowed_openai_params.This means
HINDSIGHT_API_EMBEDDINGS_LITELLM_SDK_OUTPUT_DIMENSIONShas no effect — the embedding returns the model's default dimension instead of the configured one.Solution
Add
allowed_openai_params = ["dimensions"]to the litellm kwargs when the model name starts withopenai/andoutput_dimensionsis set.This affects both the async (
aembedding) and sync (embedding) code paths inLiteLLMSDKEmbeddings.Changes
hindsight-api-slim/hindsight_api/engine/embeddings.py: Addallowed_openai_paramsin 2 places (async and sync paths)hindsight-api-slim/tests/test_litellm_sdk_embeddings.py: Add testtest_openai_output_dimensions_allows_litellm_dimensions_paramand update existing tests to verifyallowed_openai_paramsbehaviorTesting
test_litellm_sdk_embeddings.py)litellm-sdk+ OpenAI-compatible custom embedding endpoint +OUTPUT_DIMENSIONS=2000