mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
feat(providers): add SCX.ai as OpenAI-compatible provider
This commit is contained in:
parent
24123269cc
commit
b5c59b6787
5 changed files with 148 additions and 0 deletions
|
|
@ -728,6 +728,7 @@ openai_compatible_endpoints: List = [
|
|||
"https://api.libertai.io/v1",
|
||||
"https://pinstripes.io/v1",
|
||||
"https://api.meta.ai/v1",
|
||||
"https://api.scx.ai/v1",
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -795,6 +796,7 @@ openai_compatible_providers: List = [
|
|||
"pinstripes", # Pinstripes - JSON-configured provider
|
||||
"darkbloom",
|
||||
"meta", # Meta Model API (Muse Spark) - JSON-configured provider
|
||||
"scx-ai",
|
||||
]
|
||||
openai_text_completion_compatible_providers: List = [ # providers that support `/v1/completions`
|
||||
"together_ai",
|
||||
|
|
|
|||
|
|
@ -349,6 +349,9 @@ def get_llm_provider(
|
|||
elif endpoint == "https://api.meta.ai/v1":
|
||||
custom_llm_provider = "meta"
|
||||
dynamic_api_key = get_secret_str("META_API_KEY")
|
||||
elif endpoint == "https://api.scx.ai/v1":
|
||||
custom_llm_provider = "scx-ai"
|
||||
dynamic_api_key = get_secret_str("SCX_API_KEY")
|
||||
|
||||
if api_base is not None and not isinstance(api_base, str):
|
||||
raise Exception("api base needs to be a string. api_base={}".format(api_base))
|
||||
|
|
|
|||
|
|
@ -183,5 +183,17 @@
|
|||
"max_completion_tokens": "max_tokens"
|
||||
},
|
||||
"supported_endpoints": ["/v1/chat/completions", "/v1/responses", "/v1/embeddings"]
|
||||
},
|
||||
"scx-ai": {
|
||||
"base_url": "https://api.scx.ai/v1",
|
||||
"api_key_env": "SCX_API_KEY",
|
||||
"api_base_env": "SCX_API_BASE",
|
||||
"param_mappings": {
|
||||
"max_completion_tokens": "max_tokens"
|
||||
},
|
||||
"constraints": {
|
||||
"temperature_max": 1.0
|
||||
},
|
||||
"supported_endpoints": ["/v1/chat/completions"]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3508,6 +3508,7 @@ class LlmProviders(str, Enum):
|
|||
TENSORMESH = "tensormesh"
|
||||
LIBERTAI = "libertai"
|
||||
PINSTRIPES = "pinstripes"
|
||||
SCX_AI = "scx-ai"
|
||||
DARKBLOOM = "darkbloom"
|
||||
META = "meta"
|
||||
LITELLM_AGENT = "litellm_agent"
|
||||
|
|
|
|||
130
tests/test_litellm/llms/openai_like/test_scx_ai_provider.py
Normal file
130
tests/test_litellm/llms/openai_like/test_scx_ai_provider.py
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
"""
|
||||
Tests for SCX.ai provider configuration and integration.
|
||||
"""
|
||||
|
||||
import litellm
|
||||
|
||||
|
||||
class TestSCXAIProviderConfig:
|
||||
def test_scx_ai_in_provider_list(self):
|
||||
from litellm import LlmProviders
|
||||
|
||||
assert hasattr(LlmProviders, "SCX_AI")
|
||||
assert LlmProviders.SCX_AI.value == "scx-ai"
|
||||
assert "scx-ai" in litellm.provider_list
|
||||
|
||||
def test_scx_ai_json_config_exists(self):
|
||||
from litellm.llms.openai_like.json_loader import JSONProviderRegistry
|
||||
|
||||
assert JSONProviderRegistry.exists("scx-ai")
|
||||
|
||||
scx = JSONProviderRegistry.get("scx-ai")
|
||||
assert scx is not None
|
||||
assert scx.base_url == "https://api.scx.ai/v1"
|
||||
assert scx.api_key_env == "SCX_API_KEY"
|
||||
assert scx.param_mappings.get("max_completion_tokens") == "max_tokens"
|
||||
assert scx.constraints.get("temperature_max") == 1.0
|
||||
|
||||
def test_scx_ai_in_openai_compatible_providers(self):
|
||||
from litellm.constants import openai_compatible_providers
|
||||
|
||||
assert "scx-ai" in openai_compatible_providers
|
||||
|
||||
def test_scx_ai_provider_resolution(self):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
model, provider, api_key, api_base = get_llm_provider(
|
||||
model="scx-ai/gpt-oss-120b",
|
||||
custom_llm_provider=None,
|
||||
api_base=None,
|
||||
api_key=None,
|
||||
)
|
||||
|
||||
assert model == "gpt-oss-120b"
|
||||
assert provider == "scx-ai"
|
||||
assert api_base == "https://api.scx.ai/v1"
|
||||
|
||||
def test_scx_ai_api_base_override(self):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
model, provider, api_key, api_base = get_llm_provider(
|
||||
model="scx-ai/gpt-oss-120b",
|
||||
custom_llm_provider=None,
|
||||
api_base="https://custom.scx.ai/v1",
|
||||
api_key="sk-test",
|
||||
)
|
||||
|
||||
assert provider == "scx-ai"
|
||||
assert api_base == "https://custom.scx.ai/v1"
|
||||
assert api_key == "sk-test"
|
||||
|
||||
def test_scx_ai_url_autodetection(self):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
model, provider, api_key, api_base = get_llm_provider(
|
||||
model="gpt-oss-120b",
|
||||
custom_llm_provider=None,
|
||||
api_base="https://api.scx.ai/v1",
|
||||
api_key=None,
|
||||
)
|
||||
assert provider == "scx-ai"
|
||||
assert api_base == "https://api.scx.ai/v1"
|
||||
|
||||
def test_scx_ai_temperature_clamped_to_max(self):
|
||||
from litellm.llms.openai_like.dynamic_config import create_config_class
|
||||
from litellm.llms.openai_like.json_loader import JSONProviderRegistry
|
||||
|
||||
provider = JSONProviderRegistry.get("scx-ai")
|
||||
assert provider is not None
|
||||
config = create_config_class(provider)()
|
||||
|
||||
optional_params = config.map_openai_params(
|
||||
non_default_params={"temperature": 1.7},
|
||||
optional_params={},
|
||||
model="gpt-oss-120b",
|
||||
drop_params=False,
|
||||
)
|
||||
assert optional_params["temperature"] == 1.0
|
||||
|
||||
optional_params = config.map_openai_params(
|
||||
non_default_params={"temperature": 0.4},
|
||||
optional_params={},
|
||||
model="gpt-oss-120b",
|
||||
drop_params=False,
|
||||
)
|
||||
assert optional_params["temperature"] == 0.4
|
||||
|
||||
def test_scx_ai_max_completion_tokens_mapped(self):
|
||||
from litellm.llms.openai_like.dynamic_config import create_config_class
|
||||
from litellm.llms.openai_like.json_loader import JSONProviderRegistry
|
||||
|
||||
provider = JSONProviderRegistry.get("scx-ai")
|
||||
assert provider is not None
|
||||
config = create_config_class(provider)()
|
||||
|
||||
optional_params = config.map_openai_params(
|
||||
non_default_params={"max_completion_tokens": 256},
|
||||
optional_params={},
|
||||
model="gpt-oss-120b",
|
||||
drop_params=False,
|
||||
)
|
||||
assert optional_params["max_tokens"] == 256
|
||||
assert "max_completion_tokens" not in optional_params
|
||||
|
||||
def test_scx_ai_router_config(self):
|
||||
from litellm import Router
|
||||
|
||||
router = Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "scx-chat",
|
||||
"litellm_params": {
|
||||
"model": "scx-ai/gpt-oss-120b",
|
||||
"api_key": "test-key",
|
||||
},
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
assert len(router.model_list) == 1
|
||||
assert router.model_list[0]["model_name"] == "scx-chat"
|
||||
Loading…
Add table
Reference in a new issue