diff --git a/litellm/constants.py b/litellm/constants.py index dc1caef4ee5..90073de7b0b 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -768,6 +768,7 @@ openai_compatible_endpoints: List = [ "api.featherless.ai/v1", "inference.api.nscale.com/v1", "api.siliconflow.com/v1", + "api.siliconflow.cn/v1", "api.studio.nebius.ai/v1", "https://dashscope-intl.aliyuncs.com/compatible-mode/v1", "https://api.moonshot.ai/v1", diff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.py index 635a8cbcbad..feb0c33d4f1 100644 --- a/litellm/litellm_core_utils/get_llm_provider_logic.py +++ b/litellm/litellm_core_utils/get_llm_provider_logic.py @@ -314,6 +314,9 @@ def get_llm_provider( # noqa: PLR0915 elif endpoint == "api.siliconflow.com/v1": custom_llm_provider = "siliconflow" dynamic_api_key = litellm.SiliconFlowConfig.get_api_key() + elif endpoint == "api.siliconflow.cn/v1": + custom_llm_provider = "siliconflow" + dynamic_api_key = litellm.SiliconFlowConfig.get_api_key() elif endpoint == "dashscope-intl.aliyuncs.com/compatible-mode/v1": custom_llm_provider = "dashscope" dynamic_api_key = get_secret_str("DASHSCOPE_API_KEY") diff --git a/litellm/llms/siliconflow/chat/transformation.py b/litellm/llms/siliconflow/chat/transformation.py index 7708ebbe353..b7e0ecfab79 100644 --- a/litellm/llms/siliconflow/chat/transformation.py +++ b/litellm/llms/siliconflow/chat/transformation.py @@ -43,10 +43,13 @@ class SiliconFlowConfig(OpenAIGPTConfig): def get_supported_openai_params(self, model: str) -> list: return [ "max_tokens", + "max_completion_tokens", "n", "temperature", "top_p", + "seed", "stream", + "stream_options", "logprobs", "top_logprobs", "frequency_penalty", @@ -56,4 +59,6 @@ class SiliconFlowConfig(OpenAIGPTConfig): "logit_bias", "tools", "tool_choice", + "parallel_tool_calls", + "user", ] diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index 388752b032e..e7825465bca 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -32,6 +32,24 @@ } }, "providers": { + "siliconflow": { + "display_name": "SiliconFlow (`siliconflow`)", + "url": "https://docs.litellm.ai/docs/providers/siliconflow", + "endpoints": { + "chat_completions": true, + "messages": true, + "responses": true, + "embeddings": false, + "image_generations": false, + "audio_transcriptions": false, + "audio_speech": false, + "moderations": false, + "batches": false, + "rerank": false, + "a2a": true, + "interactions": true + } + }, "a2a": { "display_name": "A2A (Agent-to-Agent) (`a2a`)", "url": "https://docs.litellm.ai/docs/providers/a2a", diff --git a/tests/test_litellm/llms/siliconflow/chat/test_siliconflow_chat_transformation.py b/tests/test_litellm/llms/siliconflow/chat/test_siliconflow_chat_transformation.py index a32670c66d3..d7e9f170522 100644 --- a/tests/test_litellm/llms/siliconflow/chat/test_siliconflow_chat_transformation.py +++ b/tests/test_litellm/llms/siliconflow/chat/test_siliconflow_chat_transformation.py @@ -51,7 +51,13 @@ class TestSiliconFlowConfig: assert SiliconFlowConfig.API_BASE_URL == "https://api.siliconflow.com/v1" def test_get_openai_compatible_provider_info(self): - with patch.dict(os.environ, {"SILICONFLOW_API_KEY": "sk-secret"}, clear=False): + def fake_secret(name, *args, **kwargs): + return "sk-secret" if name == "SILICONFLOW_API_KEY" else None + + with patch( + "litellm.llms.siliconflow.chat.transformation.get_secret_str", + side_effect=fake_secret, + ): api_base, api_key = self.config._get_openai_compatible_provider_info( api_base=None, api_key=None )