mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-18 09:45:23 +00:00
Merge 54d06e7d46 into e16d79d635
This commit is contained in:
commit
26acb9fe00
13 changed files with 475 additions and 1 deletions
|
|
@ -1059,6 +1059,7 @@ openai_compatible_endpoints: Final[list[str]] = [
|
|||
"https://api.cortecs.ai/v1",
|
||||
"https://api.scx.ai/v1",
|
||||
"https://api.prisminference.com/v1",
|
||||
"https://router.hostinger.com/v1",
|
||||
"https://api.reka.ai/v1",
|
||||
"https://gigachat.devices.sberbank.ru/api/v1",
|
||||
"https://api.openinfer.ai/v1",
|
||||
|
|
@ -1139,6 +1140,7 @@ openai_compatible_providers: Final[list[str]] = [
|
|||
"cortecs",
|
||||
"scx-ai",
|
||||
"prism",
|
||||
"hostinger_router",
|
||||
"sail",
|
||||
"reka",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ JSON-based provider configuration loader for OpenAI-compatible providers.
|
|||
"""
|
||||
|
||||
import json
|
||||
from collections.abc import Sequence
|
||||
from pathlib import Path
|
||||
from typing import Final
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ class SimpleProviderConfig:
|
|||
self.param_mappings = data.get("param_mappings", {})
|
||||
self.constraints = data.get("constraints", {})
|
||||
self.special_handling = data.get("special_handling", {})
|
||||
self.supported_endpoints = data.get("supported_endpoints", [])
|
||||
self.supported_endpoints: Sequence[str] = data.get("supported_endpoints", [])
|
||||
self.provider_info: ProviderSpecificModelInfo = (
|
||||
_PROVIDER_INFO_ADAPTER.validate_python(data["provider_info"]) if "provider_info" in data else {}
|
||||
)
|
||||
|
|
@ -86,6 +87,14 @@ class JSONProviderRegistry:
|
|||
return False
|
||||
return "/v1/responses" in provider.supported_endpoints
|
||||
|
||||
@classmethod
|
||||
def supports_embeddings(cls, slug: str) -> bool:
|
||||
"""Check if a JSON provider supports the Embeddings API"""
|
||||
provider: Final = cls._providers.get(slug)
|
||||
if provider is None:
|
||||
return False
|
||||
return "/v1/embeddings" in provider.supported_endpoints
|
||||
|
||||
@classmethod
|
||||
def list_providers(cls) -> list:
|
||||
"""List all registered provider slugs"""
|
||||
|
|
|
|||
|
|
@ -219,6 +219,12 @@
|
|||
"api_base_env": "PRISM_API_BASE",
|
||||
"supported_endpoints": ["/v1/chat/completions", "/v1/responses", "/v1/messages"]
|
||||
},
|
||||
"hostinger_router": {
|
||||
"base_url": "https://router.hostinger.com/v1",
|
||||
"api_key_env": "HOSTINGER_ROUTER_API_KEY",
|
||||
"api_base_env": "HOSTINGER_ROUTER_API_BASE",
|
||||
"supported_endpoints": ["/v1/chat/completions", "/v1/responses", "/v1/messages", "/v1/embeddings"]
|
||||
},
|
||||
"sail": {
|
||||
"base_url": "https://api.sailresearch.com/v1",
|
||||
"api_key_env": "SAIL_API_KEY",
|
||||
|
|
|
|||
|
|
@ -6961,6 +6961,7 @@ def embedding(
|
|||
custom_llm_provider == "openai_like"
|
||||
or custom_llm_provider == "llamafile"
|
||||
or custom_llm_provider == "lm_studio"
|
||||
or JSONProviderRegistry.supports_embeddings(custom_llm_provider) # JSON-configured providers
|
||||
):
|
||||
api_base = api_base or litellm.api_base or get_secret_str("OPENAI_LIKE_API_BASE")
|
||||
|
||||
|
|
|
|||
|
|
@ -38352,6 +38352,61 @@
|
|||
"/v1/images/generations"
|
||||
]
|
||||
},
|
||||
"hostinger_router/gpt-5.2": {
|
||||
"cache_read_input_token_cost": 0.00000021,
|
||||
"input_cost_per_token": 0.0000021,
|
||||
"litellm_provider": "hostinger_router",
|
||||
"max_input_tokens": 272000,
|
||||
"max_output_tokens": 128000,
|
||||
"max_tokens": 128000,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 0.0000168,
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_vision": true,
|
||||
"supported_endpoints": ["/v1/chat/completions", "/v1/responses"],
|
||||
"source": "https://router.hostinger.com/v1/models"
|
||||
},
|
||||
"hostinger_router/claude-sonnet-5": {
|
||||
"cache_creation_input_token_cost": 0.000003,
|
||||
"cache_creation_input_token_cost_above_1hr": 0.0000048,
|
||||
"cache_read_input_token_cost": 0.00000024,
|
||||
"input_cost_per_token": 0.0000024,
|
||||
"litellm_provider": "hostinger_router",
|
||||
"max_input_tokens": 1000000,
|
||||
"max_output_tokens": 128000,
|
||||
"max_tokens": 128000,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 0.000012,
|
||||
"supports_function_calling": true,
|
||||
"supports_prompt_caching": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true,
|
||||
"supports_response_schema": true,
|
||||
"supported_endpoints": ["/v1/chat/completions", "/v1/messages"],
|
||||
"source": "https://router.hostinger.com/v1/models"
|
||||
},
|
||||
"hostinger_router/text-embedding-3-large": {
|
||||
"input_cost_per_token": 0.000000156,
|
||||
"litellm_provider": "hostinger_router",
|
||||
"max_input_tokens": 8191,
|
||||
"max_tokens": 8191,
|
||||
"mode": "embedding",
|
||||
"output_cost_per_token": 0.0,
|
||||
"source": "https://router.hostinger.com/v1/models"
|
||||
},
|
||||
"hostinger_router/text-embedding-3-small": {
|
||||
"input_cost_per_token": 0.000000024,
|
||||
"litellm_provider": "hostinger_router",
|
||||
"max_input_tokens": 8191,
|
||||
"max_tokens": 8191,
|
||||
"mode": "embedding",
|
||||
"output_cost_per_token": 0.0,
|
||||
"source": "https://router.hostinger.com/v1/models"
|
||||
},
|
||||
"hyperbolic/NousResearch/Hermes-3-Llama-3.1-70B": {
|
||||
"input_cost_per_token": 1.2e-07,
|
||||
"litellm_provider": "hyperbolic",
|
||||
|
|
|
|||
|
|
@ -671,6 +671,24 @@
|
|||
"interactions": false
|
||||
}
|
||||
},
|
||||
"hostinger_router": {
|
||||
"display_name": "Hostinger Router (`hostinger_router`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/hostinger_router",
|
||||
"endpoints": {
|
||||
"chat_completions": true,
|
||||
"messages": true,
|
||||
"responses": true,
|
||||
"embeddings": true,
|
||||
"image_generations": false,
|
||||
"audio_transcriptions": false,
|
||||
"audio_speech": false,
|
||||
"moderations": false,
|
||||
"batches": false,
|
||||
"rerank": false,
|
||||
"a2a": false,
|
||||
"interactions": false
|
||||
}
|
||||
},
|
||||
"custom": {
|
||||
"display_name": "Custom (`custom`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/custom_llm_server",
|
||||
|
|
|
|||
|
|
@ -3203,6 +3203,34 @@
|
|||
],
|
||||
"default_model_placeholder": "prism/deepseek-v4.1-flash"
|
||||
},
|
||||
{
|
||||
"provider": "HOSTINGER_ROUTER",
|
||||
"provider_display_name": "Hostinger Router",
|
||||
"litellm_provider": "hostinger_router",
|
||||
"credential_fields": [
|
||||
{
|
||||
"key": "api_base",
|
||||
"label": "API Base",
|
||||
"placeholder": "https://router.hostinger.com/v1",
|
||||
"tooltip": null,
|
||||
"required": false,
|
||||
"field_type": "text",
|
||||
"options": null,
|
||||
"default_value": null
|
||||
},
|
||||
{
|
||||
"key": "api_key",
|
||||
"label": "API Key",
|
||||
"placeholder": null,
|
||||
"tooltip": null,
|
||||
"required": true,
|
||||
"field_type": "password",
|
||||
"options": null,
|
||||
"default_value": null
|
||||
}
|
||||
],
|
||||
"default_model_placeholder": "hostinger_router/claude-sonnet-5"
|
||||
},
|
||||
{
|
||||
"provider": "RECRAFT",
|
||||
"provider_display_name": "Recraft",
|
||||
|
|
|
|||
|
|
@ -4585,6 +4585,7 @@ class LlmProviders(str, Enum):
|
|||
PRISM = "prism"
|
||||
OPENINFER = "openinfer"
|
||||
INFERENCEAPIS = "inferenceapis"
|
||||
HOSTINGER_ROUTER = "hostinger_router"
|
||||
DARKBLOOM = "darkbloom"
|
||||
META = "meta"
|
||||
SAIL = "sail"
|
||||
|
|
|
|||
|
|
@ -38352,6 +38352,61 @@
|
|||
"/v1/images/generations"
|
||||
]
|
||||
},
|
||||
"hostinger_router/gpt-5.2": {
|
||||
"cache_read_input_token_cost": 0.00000021,
|
||||
"input_cost_per_token": 0.0000021,
|
||||
"litellm_provider": "hostinger_router",
|
||||
"max_input_tokens": 272000,
|
||||
"max_output_tokens": 128000,
|
||||
"max_tokens": 128000,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 0.0000168,
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_vision": true,
|
||||
"supported_endpoints": ["/v1/chat/completions", "/v1/responses"],
|
||||
"source": "https://router.hostinger.com/v1/models"
|
||||
},
|
||||
"hostinger_router/claude-sonnet-5": {
|
||||
"cache_creation_input_token_cost": 0.000003,
|
||||
"cache_creation_input_token_cost_above_1hr": 0.0000048,
|
||||
"cache_read_input_token_cost": 0.00000024,
|
||||
"input_cost_per_token": 0.0000024,
|
||||
"litellm_provider": "hostinger_router",
|
||||
"max_input_tokens": 1000000,
|
||||
"max_output_tokens": 128000,
|
||||
"max_tokens": 128000,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 0.000012,
|
||||
"supports_function_calling": true,
|
||||
"supports_prompt_caching": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true,
|
||||
"supports_response_schema": true,
|
||||
"supported_endpoints": ["/v1/chat/completions", "/v1/messages"],
|
||||
"source": "https://router.hostinger.com/v1/models"
|
||||
},
|
||||
"hostinger_router/text-embedding-3-large": {
|
||||
"input_cost_per_token": 0.000000156,
|
||||
"litellm_provider": "hostinger_router",
|
||||
"max_input_tokens": 8191,
|
||||
"max_tokens": 8191,
|
||||
"mode": "embedding",
|
||||
"output_cost_per_token": 0.0,
|
||||
"source": "https://router.hostinger.com/v1/models"
|
||||
},
|
||||
"hostinger_router/text-embedding-3-small": {
|
||||
"input_cost_per_token": 0.000000024,
|
||||
"litellm_provider": "hostinger_router",
|
||||
"max_input_tokens": 8191,
|
||||
"max_tokens": 8191,
|
||||
"mode": "embedding",
|
||||
"output_cost_per_token": 0.0,
|
||||
"source": "https://router.hostinger.com/v1/models"
|
||||
},
|
||||
"hyperbolic/NousResearch/Hermes-3-Llama-3.1-70B": {
|
||||
"input_cost_per_token": 1.2e-07,
|
||||
"litellm_provider": "hyperbolic",
|
||||
|
|
|
|||
|
|
@ -725,6 +725,24 @@
|
|||
"interactions": false
|
||||
}
|
||||
},
|
||||
"hostinger_router": {
|
||||
"display_name": "Hostinger Router (`hostinger_router`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/hostinger_router",
|
||||
"endpoints": {
|
||||
"chat_completions": true,
|
||||
"messages": true,
|
||||
"responses": true,
|
||||
"embeddings": true,
|
||||
"image_generations": false,
|
||||
"audio_transcriptions": false,
|
||||
"audio_speech": false,
|
||||
"moderations": false,
|
||||
"batches": false,
|
||||
"rerank": false,
|
||||
"a2a": false,
|
||||
"interactions": false
|
||||
}
|
||||
},
|
||||
"crusoe": {
|
||||
"display_name": "Crusoe (`crusoe`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/crusoe",
|
||||
|
|
|
|||
276
tests/unit/llms/openai_like/test_hostinger_router_provider.py
Normal file
276
tests/unit/llms/openai_like/test_hostinger_router_provider.py
Normal file
|
|
@ -0,0 +1,276 @@
|
|||
import json
|
||||
from pathlib import Path
|
||||
from typing import Final
|
||||
|
||||
import pytest
|
||||
import respx
|
||||
|
||||
import litellm
|
||||
from litellm.caching.llm_caching_handler import LLMClientCache
|
||||
|
||||
|
||||
def test_hostinger_router_provider_resolution(monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
monkeypatch.setenv("HOSTINGER_ROUTER_API_KEY", "hostinger-test-key")
|
||||
|
||||
model, provider, api_key, api_base = get_llm_provider(
|
||||
model="hostinger_router/claude-sonnet-5",
|
||||
custom_llm_provider=None,
|
||||
api_base=None,
|
||||
api_key=None,
|
||||
)
|
||||
|
||||
assert model == "claude-sonnet-5"
|
||||
assert provider == "hostinger_router"
|
||||
assert api_key == "hostinger-test-key"
|
||||
assert api_base == "https://router.hostinger.com/v1"
|
||||
|
||||
|
||||
def test_hostinger_router_provider_keeps_explicit_credentials(monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
monkeypatch.setenv("HOSTINGER_ROUTER_API_KEY", "hostinger-env-key")
|
||||
|
||||
_, provider, api_key, api_base = get_llm_provider(
|
||||
model="hostinger_router/claude-sonnet-5",
|
||||
custom_llm_provider=None,
|
||||
api_base="https://router.internal.example/v1",
|
||||
api_key="hostinger-explicit-key",
|
||||
)
|
||||
|
||||
assert provider == "hostinger_router"
|
||||
assert api_key == "hostinger-explicit-key"
|
||||
assert api_base == "https://router.internal.example/v1"
|
||||
|
||||
|
||||
HOSTINGER_ROUTER_MODELS = tuple(sorted(name for name in litellm.model_cost if name.startswith("hostinger_router/")))
|
||||
HOSTINGER_ROUTER_CHAT_MODELS = tuple(
|
||||
name for name in HOSTINGER_ROUTER_MODELS if litellm.get_model_info(name)["mode"] == "chat"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model", HOSTINGER_ROUTER_CHAT_MODELS)
|
||||
def test_hostinger_router_model_cost_and_capabilities(model: str):
|
||||
from litellm.cost_calculator import cost_per_token
|
||||
|
||||
prompt_cost, completion_cost = cost_per_token(
|
||||
model=model,
|
||||
prompt_tokens=1_000_000,
|
||||
completion_tokens=1_000_000,
|
||||
custom_llm_provider="hostinger_router",
|
||||
)
|
||||
model_info = litellm.get_model_info(model)
|
||||
|
||||
assert prompt_cost == pytest.approx(model_info["input_cost_per_token"] * 1_000_000)
|
||||
assert completion_cost == pytest.approx(model_info["output_cost_per_token"] * 1_000_000)
|
||||
assert model_info["output_cost_per_token"] > 0
|
||||
assert model_info["max_tokens"] == model_info["max_output_tokens"] <= model_info["max_input_tokens"]
|
||||
assert model_info["litellm_provider"] == "hostinger_router"
|
||||
assert model_info["mode"] == "chat"
|
||||
assert model_info["supports_function_calling"] is True
|
||||
assert model_info["supports_reasoning"] is True
|
||||
assert model_info["supports_response_schema"] is True
|
||||
if model_info.get("supports_prompt_caching"):
|
||||
assert 0 < model_info["cache_read_input_token_cost"] < model_info["input_cost_per_token"]
|
||||
if "supports_vision" in model_info:
|
||||
assert litellm.supports_vision(model) is model_info["supports_vision"]
|
||||
else:
|
||||
assert litellm.supports_vision(model) in (True, False, None)
|
||||
|
||||
|
||||
def test_hostinger_router_backup_registry_mirrors_cost_map():
|
||||
package_root = Path(litellm.__file__).parent
|
||||
cost_map = json.loads((package_root.parent / "model_prices_and_context_window.json").read_text())
|
||||
backup = json.loads((package_root / "model_prices_and_context_window_backup.json").read_text())
|
||||
hostinger_entries = {name: entry for name, entry in cost_map.items() if name.startswith("hostinger_router/")}
|
||||
|
||||
assert tuple(sorted(hostinger_entries)) == HOSTINGER_ROUTER_MODELS
|
||||
assert hostinger_entries
|
||||
assert hostinger_entries == {name: backup[name] for name in hostinger_entries}
|
||||
|
||||
|
||||
def test_hostinger_router_is_available_in_add_model_form():
|
||||
fields_path = Path(litellm.__file__).parent / "proxy" / "public_endpoints" / "provider_create_fields.json"
|
||||
providers = json.loads(fields_path.read_text())
|
||||
hostinger = next(provider for provider in providers if provider["litellm_provider"] == "hostinger_router")
|
||||
|
||||
assert hostinger["provider"] == "HOSTINGER_ROUTER"
|
||||
assert hostinger["provider_display_name"] == "Hostinger Router"
|
||||
assert hostinger["default_model_placeholder"] == "hostinger_router/claude-sonnet-5"
|
||||
assert {field["key"]: field["required"] for field in hostinger["credential_fields"]} == {
|
||||
"api_base": False,
|
||||
"api_key": True,
|
||||
}
|
||||
|
||||
|
||||
def test_hostinger_router_supported_endpoints():
|
||||
matrix_path = Path(litellm.__file__).parent / "provider_endpoints_support_backup.json"
|
||||
providers = json.loads(matrix_path.read_text())["providers"]
|
||||
|
||||
assert providers["hostinger_router"]["endpoints"]["chat_completions"] is True
|
||||
assert providers["hostinger_router"]["endpoints"]["messages"] is True
|
||||
assert providers["hostinger_router"]["endpoints"]["responses"] is True
|
||||
assert providers["hostinger_router"]["endpoints"]["embeddings"] is True
|
||||
assert providers["hostinger_router"]["endpoints"]["image_generations"] is False
|
||||
assert providers["hostinger_router"]["endpoints"]["audio_transcriptions"] is False
|
||||
assert providers["hostinger_router"]["endpoints"]["batches"] is False
|
||||
|
||||
|
||||
def test_hostinger_router_chat_completions_request():
|
||||
with respx.mock() as upstream:
|
||||
route: Final = upstream.post("https://router.hostinger.com/v1/chat/completions").respond(
|
||||
200,
|
||||
json={
|
||||
"id": "chatcmpl_hostinger",
|
||||
"object": "chat.completion",
|
||||
"created": 1_789_550_000,
|
||||
"model": "claude-sonnet-5",
|
||||
"choices": [
|
||||
{
|
||||
"index": 0,
|
||||
"message": {"role": "assistant", "content": "Hello from Hostinger Router"},
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
"usage": {"prompt_tokens": 4, "completion_tokens": 3, "total_tokens": 7},
|
||||
},
|
||||
)
|
||||
response: Final = litellm.completion(
|
||||
model="hostinger_router/claude-sonnet-5",
|
||||
messages=[{"role": "user", "content": "Say hello"}],
|
||||
api_key="hostinger-test-key",
|
||||
)
|
||||
|
||||
request: Final = route.calls.last.request
|
||||
body: Final = json.loads(request.content)
|
||||
assert route.call_count == 1
|
||||
assert request.headers["authorization"] == "Bearer hostinger-test-key"
|
||||
assert body["model"] == "claude-sonnet-5"
|
||||
assert response.choices[0].message.content == "Hello from Hostinger Router"
|
||||
|
||||
|
||||
def test_hostinger_router_chat_completions_streaming_request():
|
||||
chunks = [
|
||||
'data: {"id":"chatcmpl_hostinger","object":"chat.completion.chunk","created":1789550000,"model":"claude-sonnet-5","choices":[{"index":0,"delta":{"role":"assistant","content":"Hi"},"finish_reason":null}]}\n\n',
|
||||
'data: {"id":"chatcmpl_hostinger","object":"chat.completion.chunk","created":1789550000,"model":"claude-sonnet-5","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":4,"completion_tokens":1,"total_tokens":5}}\n\n',
|
||||
"data: [DONE]\n\n",
|
||||
]
|
||||
with respx.mock() as upstream:
|
||||
route: Final = upstream.post("https://router.hostinger.com/v1/chat/completions").respond(
|
||||
200,
|
||||
headers={"content-type": "text/event-stream"},
|
||||
content="".join(chunks).encode(),
|
||||
)
|
||||
response: Final = litellm.completion(
|
||||
model="hostinger_router/claude-sonnet-5",
|
||||
messages=[{"role": "user", "content": "Say hello"}],
|
||||
stream=True,
|
||||
api_key="hostinger-test-key",
|
||||
)
|
||||
collected = [chunk for chunk in response]
|
||||
|
||||
request: Final = route.calls.last.request
|
||||
body: Final = json.loads(request.content)
|
||||
assert route.call_count == 1
|
||||
assert body["stream"] is True
|
||||
assert any(chunk.choices and chunk.choices[0].delta.content == "Hi" for chunk in collected)
|
||||
|
||||
|
||||
def test_hostinger_router_responses_request():
|
||||
with respx.mock() as upstream:
|
||||
route: Final = upstream.post("https://router.hostinger.com/v1/responses").respond(
|
||||
200,
|
||||
json={
|
||||
"id": "resp_hostinger",
|
||||
"object": "response",
|
||||
"created_at": 1_789_550_000,
|
||||
"model": "gpt-5.2",
|
||||
"status": "completed",
|
||||
"output": [
|
||||
{
|
||||
"id": "msg_hostinger",
|
||||
"type": "message",
|
||||
"role": "assistant",
|
||||
"status": "completed",
|
||||
"content": [{"type": "output_text", "text": "Hello from Hostinger Router", "annotations": []}],
|
||||
}
|
||||
],
|
||||
"usage": {"input_tokens": 4, "output_tokens": 3, "total_tokens": 7},
|
||||
},
|
||||
)
|
||||
response: Final = litellm.responses(
|
||||
model="hostinger_router/gpt-5.2",
|
||||
input="Say hello",
|
||||
api_key="hostinger-test-key",
|
||||
)
|
||||
|
||||
request: Final = route.calls.last.request
|
||||
body: Final = json.loads(request.content)
|
||||
assert route.call_count == 1
|
||||
assert str(request.url) == "https://router.hostinger.com/v1/responses"
|
||||
assert request.headers["authorization"] == "Bearer hostinger-test-key"
|
||||
assert body["model"] == "gpt-5.2"
|
||||
assert body["input"] == "Say hello"
|
||||
assert response.output[0].content[0].text == "Hello from Hostinger Router"
|
||||
|
||||
|
||||
def test_hostinger_router_embeddings_request():
|
||||
with respx.mock() as upstream:
|
||||
route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(
|
||||
200,
|
||||
json={
|
||||
"object": "list",
|
||||
"data": [{"object": "embedding", "index": 0, "embedding": [0.1, 0.2, 0.3]}],
|
||||
"model": "text-embedding-3-small",
|
||||
"usage": {"prompt_tokens": 2, "total_tokens": 2},
|
||||
},
|
||||
)
|
||||
response: Final = litellm.embedding(
|
||||
model="hostinger_router/text-embedding-3-small",
|
||||
input=["Say hello"],
|
||||
api_key="hostinger-test-key",
|
||||
)
|
||||
|
||||
request: Final = route.calls.last.request
|
||||
body: Final = json.loads(request.content)
|
||||
assert route.call_count == 1
|
||||
assert request.headers["authorization"] == "Bearer hostinger-test-key"
|
||||
assert body["model"] == "text-embedding-3-small"
|
||||
assert response.data[0]["embedding"] == [0.1, 0.2, 0.3]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_hostinger_router_anthropic_messages_request(monkeypatch: pytest.MonkeyPatch):
|
||||
monkeypatch.setattr(litellm, "disable_aiohttp_transport", True)
|
||||
monkeypatch.setattr(litellm, "in_memory_llm_clients_cache", LLMClientCache())
|
||||
with respx.mock() as upstream:
|
||||
route: Final = upstream.post("https://router.hostinger.com/v1/messages").respond(
|
||||
200,
|
||||
json={
|
||||
"id": "msg_hostinger",
|
||||
"type": "message",
|
||||
"role": "assistant",
|
||||
"model": "claude-sonnet-5",
|
||||
"content": [{"type": "text", "text": "Hello from Hostinger Router"}],
|
||||
"stop_reason": "end_turn",
|
||||
"stop_sequence": None,
|
||||
"usage": {"input_tokens": 4, "output_tokens": 3},
|
||||
},
|
||||
)
|
||||
response: Final = await litellm.anthropic.messages.acreate(
|
||||
model="hostinger_router/claude-sonnet-5",
|
||||
messages=[{"role": "user", "content": "Say hello"}],
|
||||
max_tokens=32,
|
||||
api_key="hostinger-test-key",
|
||||
)
|
||||
|
||||
request: Final = route.calls.last.request
|
||||
body: Final = json.loads(request.content)
|
||||
assert route.call_count == 1
|
||||
assert str(request.url) == "https://router.hostinger.com/v1/messages"
|
||||
assert request.headers["authorization"] == "Bearer hostinger-test-key"
|
||||
assert request.headers["anthropic-version"] == "2023-06-01"
|
||||
assert body["model"] == "claude-sonnet-5"
|
||||
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
|
||||
assert response["content"][0]["text"] == "Hello from Hostinger Router"
|
||||
BIN
ui/litellm-dashboard/public/assets/logos/hostinger.png
Normal file
BIN
ui/litellm-dashboard/public/assets/logos/hostinger.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
|
|
@ -28,6 +28,7 @@ import googleLogo from "../../public/assets/logos/google.svg";
|
|||
import groqLogo from "../../public/assets/logos/groq.svg";
|
||||
import huggingfaceLogo from "../../public/assets/logos/huggingface.svg";
|
||||
import hyperbolicLogo from "../../public/assets/logos/hyperbolic.svg";
|
||||
import hostingerLogo from "../../public/assets/logos/hostinger.png";
|
||||
import infinityLogo from "../../public/assets/logos/infinity.png";
|
||||
import jinaLogo from "../../public/assets/logos/jina.png";
|
||||
import lambdaLogo from "../../public/assets/logos/lambda.svg";
|
||||
|
|
@ -128,6 +129,7 @@ export enum Providers {
|
|||
Hosted_Vllm = "Hosted vLLM",
|
||||
HUGGINGFACE = "Huggingface",
|
||||
HYPERBOLIC = "Hyperbolic",
|
||||
HOSTINGER_ROUTER = "Hostinger Router",
|
||||
Infinity = "Infinity",
|
||||
JinaAI = "Jina AI",
|
||||
OPENCODE_GO = "OpenCode Go",
|
||||
|
|
@ -255,6 +257,7 @@ export const provider_map: Record<string, string> = {
|
|||
Hosted_Vllm: "hosted_vllm",
|
||||
HUGGINGFACE: "huggingface",
|
||||
HYPERBOLIC: "hyperbolic",
|
||||
HOSTINGER_ROUTER: "hostinger_router",
|
||||
Infinity: "infinity",
|
||||
JinaAI: "jina_ai",
|
||||
OPENCODE_GO: "opencode_go",
|
||||
|
|
@ -375,6 +378,7 @@ export const providerLogoMap: Partial<Record<Providers, string>> = {
|
|||
[Providers.Hosted_Vllm]: vllmLogo.src,
|
||||
[Providers.HUGGINGFACE]: huggingfaceLogo.src,
|
||||
[Providers.HYPERBOLIC]: hyperbolicLogo.src,
|
||||
[Providers.HOSTINGER_ROUTER]: hostingerLogo.src,
|
||||
[Providers.Infinity]: infinityLogo.src,
|
||||
[Providers.JinaAI]: jinaLogo.src,
|
||||
[Providers.OPENCODE_GO]: opencodeLogo.src,
|
||||
|
|
@ -477,6 +481,7 @@ const providerPlaceholderMap: Partial<Record<Providers, string>> = {
|
|||
[Providers.EDENAI]: "edenai/openai/gpt-mini-latest",
|
||||
[Providers.FalAI]: "fal_ai/fal-ai/flux-pro/v1.1-ultra",
|
||||
[Providers.Google_AI_Studio]: "gemini-pro",
|
||||
[Providers.HOSTINGER_ROUTER]: "hostinger_router/claude-sonnet-5",
|
||||
[Providers.JinaAI]: "jina_ai/",
|
||||
[Providers.MICROSOFT_365_COPILOT]: "microsoft_365_copilot/chat",
|
||||
[Providers.NVIDIA_RIVA]: "nvidia_riva/nvidia/parakeet-ctc-1_1b-asr",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue