diff --git a/litellm/constants.py b/litellm/constants.py index 1c1939bd350..de4e263a1a9 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -596,6 +596,9 @@ LITELLM_CHAT_PROVIDERS: Final = [ "gdc", "xai", "custom_openai", + "byteplus", + "digitalocean", + "siliconflow", "text-completion-openai", "cohere", "cohere_chat", @@ -930,6 +933,9 @@ openai_compatible_providers: Final[list] = [ "cometapi", "clarifai", "docker_model_runner", + "byteplus", + "digitalocean", + "siliconflow", "ragflow", "pinstripes", # Pinstripes - JSON-configured provider "darkbloom", @@ -961,6 +967,9 @@ openai_text_completion_compatible_providers: Final[list] = [ # providers that s "lambda_ai", "hyperbolic", "wandb", + "byteplus", + "digitalocean", + "siliconflow", ] _openai_like_providers: Final[list] = [ "predibase", diff --git a/litellm/main.py b/litellm/main.py index 01c106adc7c..036959837b6 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -6272,6 +6272,12 @@ def embedding( or custom_llm_provider == "together_ai" or custom_llm_provider == "nvidia_nim" or custom_llm_provider == "litellm_proxy" + or custom_llm_provider == "byteplus" + or custom_llm_provider == "digitalocean" + or custom_llm_provider == "siliconflow" + or custom_llm_provider == "deepinfra" + or custom_llm_provider == "nscale" + or custom_llm_provider == "novita" or (model in litellm.open_ai_embedding_models and custom_llm_provider is None) ): api_base = ( diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 5783a39b30c..ada27a60824 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -3768,6 +3768,9 @@ class LlmProviders(str, Enum): ANTHROPIC = "anthropic" ANTHROPIC_TEXT = "anthropic_text" BYTEZ = "bytez" + BYTEPLUS = "byteplus" + DIGITALOCEAN = "digitalocean" + SILICONFLOW = "siliconflow" REPLICATE = "replicate" REDUCTO = "reducto" RUNWAYML = "runwayml" diff --git a/tests/test_litellm/test_openai_compatible_embedding_providers.py b/tests/test_litellm/test_openai_compatible_embedding_providers.py new file mode 100644 index 00000000000..3f7fb7c9275 --- /dev/null +++ b/tests/test_litellm/test_openai_compatible_embedding_providers.py @@ -0,0 +1,37 @@ +from unittest.mock import MagicMock, patch + +import pytest + +import litellm + + +@pytest.mark.parametrize( + "provider", + ["byteplus", "digitalocean", "siliconflow", "deepinfra", "nscale", "novita"], +) +def test_openai_compatible_provider_embedding_dispatch(provider): + mock_response = MagicMock() + mock_response.parse.return_value = MagicMock( + model_dump=lambda: { + "data": [{"embedding": [0.1, 0.2, 0.3], "index": 0}], + "model": "test-embedding", + "object": "list", + "usage": {"prompt_tokens": 1, "total_tokens": 1}, + } + ) + mock_response.headers = {} + + with patch("litellm.llms.openai.openai.OpenAIChatCompletion._get_openai_client") as mock_get_client: + mock_client = MagicMock() + mock_get_client.return_value = mock_client + mock_client.embeddings.with_raw_response.create.return_value = mock_response + + response = litellm.embedding( + model=f"{provider}/test-embedding", + input="Hello world", + api_key="test-key", + api_base="http://test.example/v1", + ) + + assert response.data[0]["embedding"] == [0.1, 0.2, 0.3] + assert mock_client.embeddings.with_raw_response.create.called