From e6771feace5e33377cf1896206f082268331a19e Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Tue, 14 Apr 2026 20:36:28 +0530 Subject: [PATCH] Revert "fix(embedding): omit null encoding_format for openai requests (#25395)" This reverts commit e3d160f158ac33348699f4196e09d19401bbcc41. --- litellm/main.py | 3 ++ .../test_openai_embeddings_encoding_format.py | 34 ------------------- 2 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 tests/test_litellm/llms/openai/embeddings/test_openai_embeddings_encoding_format.py diff --git a/litellm/main.py b/litellm/main.py index cf360855d1..ddd37b4753 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -4913,6 +4913,9 @@ def embedding( # noqa: PLR0915 if encoding_format is not None: optional_params["encoding_format"] = encoding_format + else: + # Omiting causes openai sdk to add default value of "float" + optional_params["encoding_format"] = None api_version = None diff --git a/tests/test_litellm/llms/openai/embeddings/test_openai_embeddings_encoding_format.py b/tests/test_litellm/llms/openai/embeddings/test_openai_embeddings_encoding_format.py deleted file mode 100644 index 617037865c..0000000000 --- a/tests/test_litellm/llms/openai/embeddings/test_openai_embeddings_encoding_format.py +++ /dev/null @@ -1,34 +0,0 @@ -from unittest.mock import patch - -import litellm - - -@patch("litellm.main.openai_chat_completions.embedding", return_value={"ok": True}) -def test_openai_embedding_does_not_send_encoding_format_when_unset(mock_embedding): - """Regression test: do not send encoding_format=null to OpenAI-compatible APIs.""" - litellm.embedding( - model="text-embedding-3-small", - input=["hello"], - api_base="https://example.com/v1", - api_key="test-key", - custom_llm_provider="openai", - ) - - optional_params = mock_embedding.call_args.kwargs["optional_params"] - assert "encoding_format" not in optional_params - - -@patch("litellm.main.openai_chat_completions.embedding", return_value={"ok": True}) -def test_openai_embedding_preserves_explicit_encoding_format(mock_embedding): - """Explicit encoding_format should still be forwarded.""" - litellm.embedding( - model="text-embedding-3-small", - input=["hello"], - api_base="https://example.com/v1", - api_key="test-key", - custom_llm_provider="openai", - encoding_format="float", - ) - - optional_params = mock_embedding.call_args.kwargs["optional_params"] - assert optional_params["encoding_format"] == "float"