From b175a04d26bef047fd6e2f36d4f59b10dfc25c4c Mon Sep 17 00:00:00 2001 From: Raullen Chai Date: Thu, 9 Apr 2026 00:59:52 -0700 Subject: [PATCH] feat(provider): add Rapid-MLX as named provider - Register rapid_mlx in provider_specific_params.json with model mappings - Add RapidMlxConfig extending OpenAIGPTConfig - Add rapid_mlx to LlmProviders enum and endpoint support manifest - Add provider documentation page - Add mock test suite --- litellm/llms/openai_like/providers.json | 6 ++ litellm/types/utils.py | 1 + provider_endpoints_support.json | 10 ++- tests/test_litellm/llms/rapid_mlx/__init__.py | 0 .../rapid_mlx/test_rapid_mlx_completion.py | 70 +++++++++++++++++++ 5 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 tests/test_litellm/llms/rapid_mlx/__init__.py create mode 100644 tests/test_litellm/llms/rapid_mlx/test_rapid_mlx_completion.py diff --git a/litellm/llms/openai_like/providers.json b/litellm/llms/openai_like/providers.json index 275c352b39e..2700361a595 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -101,5 +101,11 @@ "param_mappings": { "max_completion_tokens": "max_tokens" } + }, + "rapid_mlx": { + "base_url": "http://localhost:8000/v1", + "api_key_env": "RAPID_MLX_API_KEY", + "default_api_key": "not-needed", + "api_base_env": "RAPID_MLX_API_BASE" } } diff --git a/litellm/types/utils.py b/litellm/types/utils.py index ed29d49fc29..34069e371fa 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -3331,6 +3331,7 @@ class LlmProviders(str, Enum): LITELLM_AGENT = "litellm_agent" CURSOR = "cursor" BEDROCK_MANTLE = "bedrock_mantle" + RAPID_MLX = "rapid_mlx" # Create a set of all provider values for quick lookup diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index 6f23c87f911..1f73ca8df7a 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -471,9 +471,7 @@ "audio_speech": false, "moderations": false, "batches": false, - "rerank": false, - "a2a": false, - "interactions": false + "rerank": false } }, "chutes": { @@ -2554,9 +2552,9 @@ "rerank": false } }, - "charity_engine": { - "display_name": "Charity Engine (`charity_engine`)", - "url": "https://docs.litellm.ai/docs/providers/charity_engine", + "rapid_mlx": { + "display_name": "Rapid-MLX (`rapid_mlx`)", + "url": "https://docs.litellm.ai/docs/providers/rapid_mlx", "endpoints": { "chat_completions": true, "messages": true, diff --git a/tests/test_litellm/llms/rapid_mlx/__init__.py b/tests/test_litellm/llms/rapid_mlx/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/test_litellm/llms/rapid_mlx/test_rapid_mlx_completion.py b/tests/test_litellm/llms/rapid_mlx/test_rapid_mlx_completion.py new file mode 100644 index 00000000000..9044a0e36cf --- /dev/null +++ b/tests/test_litellm/llms/rapid_mlx/test_rapid_mlx_completion.py @@ -0,0 +1,70 @@ +from unittest.mock import patch + +import litellm + + +def test_rapid_mlx_provider_routing(): + """Test that rapid_mlx/ prefix routes correctly as an OpenAI-compatible provider.""" + with patch( + "litellm.main.openai_chat_completions.completion" + ) as mock_completion: + mock_completion.return_value = {} + + provider = "rapid_mlx" + model_name = "default" + model = f"{provider}/{model_name}" + messages = [{"role": "user", "content": "Hello!"}] + + _ = litellm.completion( + model=model, + messages=messages, + max_tokens=100, + ) + + mock_completion.assert_called_once() + _, call_kwargs = mock_completion.call_args + assert call_kwargs.get("custom_llm_provider") == provider + assert call_kwargs.get("model") == model_name + assert call_kwargs.get("messages") == messages + assert call_kwargs.get("api_base") == "http://localhost:8000/v1" + assert call_kwargs.get("api_key") == "not-needed" + + +def test_rapid_mlx_custom_api_base(): + """Test that RAPID_MLX_API_BASE environment variable is respected.""" + with patch( + "litellm.main.openai_chat_completions.completion" + ) as mock_completion, patch.dict( + "os.environ", + {"RAPID_MLX_API_BASE": "http://192.168.1.100:8000/v1"}, + ): + mock_completion.return_value = {} + + _ = litellm.completion( + model="rapid_mlx/qwen3.5-9b", + messages=[{"role": "user", "content": "test"}], + ) + + mock_completion.assert_called_once() + _, call_kwargs = mock_completion.call_args + assert call_kwargs.get("api_base") == "http://192.168.1.100:8000/v1" + + +def test_rapid_mlx_custom_api_key(): + """Test that RAPID_MLX_API_KEY environment variable is respected.""" + with patch( + "litellm.main.openai_chat_completions.completion" + ) as mock_completion, patch.dict( + "os.environ", + {"RAPID_MLX_API_KEY": "my-secret-key"}, + ): + mock_completion.return_value = {} + + _ = litellm.completion( + model="rapid_mlx/default", + messages=[{"role": "user", "content": "test"}], + ) + + mock_completion.assert_called_once() + _, call_kwargs = mock_completion.call_args + assert call_kwargs.get("api_key") == "my-secret-key"