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
This commit is contained in:
Raullen Chai 2026-04-09 00:59:52 -07:00 • committed by Raullen
parent 3e1479c052
commit b175a04d26
5 changed files with 81 additions and 6 deletions

View file

@ -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"
}
}

View file

@ -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

View file

@ -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,

View file

@ -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"