diff --git a/litellm/utils.py b/litellm/utils.py index dfacefe6971..53ab2d8eb6b 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -3453,7 +3453,28 @@ def get_optional_params_embeddings( # noqa: PLR0915 else: optional_params = non_default_params else: - optional_params = non_default_params + # openai_compatible_providers (e.g. hosted_vllm, openrouter, etc.) + # Pass all params through, but honour drop_params for `dimensions` + # because many vLLM / compatible endpoints don't support it and return + # 422 when it is present. Only text-embedding-3-* models support it. + optional_params = non_default_params.copy() + if ( + "dimensions" in optional_params + and model is not None + and "text-embedding-3" not in model + ): + if litellm.drop_params is True or drop_params is True: + optional_params.pop("dimensions") + else: + raise UnsupportedParamsError( + status_code=500, + message=( + f"Setting 'dimensions' is not supported for model '{model}' " + f"with provider '{custom_llm_provider}'. Only text-embedding-3-* " + "models support this parameter. To drop it from the call, set " + "`litellm.drop_params = True`." + ), + ) final_params = add_provider_specific_params_to_optional_params( optional_params=optional_params,