From 54d06e7d4652b92359e00b8252f65cd23b2b4709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Algirdas=20=C4=8C=2E?= Date: Wed, 7 Oct 2026 08:12:53 +0300 Subject: [PATCH 01/14] feat: add Hostinger Router as an OpenAI-compatible provider Adds hostinger_router (https://router.hostinger.com/v1) to the JSON-configured openai_like providers with chat completions, responses, messages, and embeddings endpoints, cost-map entries for claude-sonnet-5, gpt-5.2 and the two text-embedding-3 models (credits converted at 1 credit = $0.01, sourced from the public https://router.hostinger.com/v1/models catalog), the endpoint-support matrix, Admin UI add-model form fields and logo, and respx-mocked unit tests covering all declared endpoints. Also routes /v1/embeddings for JSON-configured providers that declare it in providers.json; previously embedding calls for these providers fell through to LiteLLMUnknownProvider. --- litellm/constants.py | 2 + litellm/llms/openai_like/json_loader.py | 11 +- litellm/llms/openai_like/providers.json | 6 + litellm/main.py | 1 + ...odel_prices_and_context_window_backup.json | 55 ++++ .../provider_endpoints_support_backup.json | 18 ++ .../provider_create_fields.json | 28 ++ litellm/types/utils.py | 1 + model_prices_and_context_window.json | 55 ++++ provider_endpoints_support.json | 18 ++ .../test_hostinger_router_provider.py | 276 ++++++++++++++++++ .../public/assets/logos/hostinger.png | Bin 0 -> 16604 bytes .../src/components/provider_info_helpers.tsx | 5 + 13 files changed, 475 insertions(+), 1 deletion(-) create mode 100644 tests/unit/llms/openai_like/test_hostinger_router_provider.py create mode 100644 ui/litellm-dashboard/public/assets/logos/hostinger.png diff --git a/litellm/constants.py b/litellm/constants.py index c0fe0491775..4c1ae308dda 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -1057,6 +1057,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", @@ -1136,6 +1137,7 @@ openai_compatible_providers: Final[list[str]] = [ "cortecs", "scx-ai", "prism", + "hostinger_router", "sail", "reka", ] diff --git a/litellm/llms/openai_like/json_loader.py b/litellm/llms/openai_like/json_loader.py index 23b63177137..c2208d49133 100644 --- a/litellm/llms/openai_like/json_loader.py +++ b/litellm/llms/openai_like/json_loader.py @@ -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""" diff --git a/litellm/llms/openai_like/providers.json b/litellm/llms/openai_like/providers.json index 36337fddbdc..4d78acf422c 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -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", diff --git a/litellm/main.py b/litellm/main.py index 27700cf9def..c1c227012bd 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -6911,6 +6911,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") diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index cb9bfa6ffe4..54e82a6dcc8 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -39422,6 +39422,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", diff --git a/litellm/provider_endpoints_support_backup.json b/litellm/provider_endpoints_support_backup.json index f95b553c2b4..0f537ef425a 100644 --- a/litellm/provider_endpoints_support_backup.json +++ b/litellm/provider_endpoints_support_backup.json @@ -654,6 +654,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", diff --git a/litellm/proxy/public_endpoints/provider_create_fields.json b/litellm/proxy/public_endpoints/provider_create_fields.json index 4bec42a7868..9168dfdd7e8 100644 --- a/litellm/proxy/public_endpoints/provider_create_fields.json +++ b/litellm/proxy/public_endpoints/provider_create_fields.json @@ -3157,6 +3157,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", diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 5939a350970..63813d010dc 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -4549,6 +4549,7 @@ class LlmProviders(str, Enum): PRISM = "prism" OPENINFER = "openinfer" INFERENCEAPIS = "inferenceapis" + HOSTINGER_ROUTER = "hostinger_router" DARKBLOOM = "darkbloom" META = "meta" SAIL = "sail" diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index cb9bfa6ffe4..54e82a6dcc8 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -39422,6 +39422,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", diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index d65da3f41fd..5dd89bd6606 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -708,6 +708,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", diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py new file mode 100644 index 00000000000..324bfa2eda5 --- /dev/null +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -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" diff --git a/ui/litellm-dashboard/public/assets/logos/hostinger.png b/ui/litellm-dashboard/public/assets/logos/hostinger.png new file mode 100644 index 0000000000000000000000000000000000000000..9ae3f4bcca1b0a3d2fa65a23064017950f4926eb GIT binary patch literal 16604 zcmb`u1yoe++b%woC}9B7rKprN3eqSe(jWrTBGTO*q5^_|(hUyMDJ_i%NXXC)LwDEE z{GUC(?>Xmx*0;`D-#NcoYnHQQ$FuK!$8}%#^?X!TlqM#iCV;_U#4^vMp2J|+;3qch z@+I)ko@@Ux3?`8#BPIF5b##5gAGl3k3%8ous#{DH(7RH2 zUau73DMZ~?Jv8nxfeZxq{O^2xISr1NhBnr|XvNl`>lK;bahtW|;N#tC)mDpov_DQjc-WN;ss2;`33bD0^S!WlF59*y@JSNoi zJ%~5TXe!b$YS%I05mvl7ER&()mZ|d8K=P(7TW!CtGn$ZAhIYFI-9B#B)&-sI_Bgy0 z8@d#i**jyh4@yJN8RKvy@>uEYetsbrU_PVJND^8I86|yM^BXrm4FL}}bB$H@ zgW19&D()igF1-+rj!Ja+X(+Eh4kO(@cLTquI!o^`nRCK~ zZj8%b7oq5G*^U|*ZuUgVwc;n>#(c+*G$~4@|oDCUIaWRwGR_>UP2B2p*-mc zKC4n#|5`?puXaKix<|~oz|-)MIP9kL3hfOU+60GY_7cLFJg&~#4bwvAxGQ%r!@dV% z(f6%}Wu?+MnkUhl&31{p_50~Ehq%rUZm=H7c(mGHG8BZ--N2RaAn#$D>VI#^?lh%> zbFtIB=65&c>Z)7Ut0zSFA{k+{hYbCOaT!C-+WF<4Rdij z5w-+TtE~#%3(3ru@PoOB3)`Ff{GWxu4V&JL@~PTs&dFa2f} zb)=&nCkYE|6BpW!%~&o=G7YA2rWwc5?6Vd#T=O7~2oUkK(|UZta1-weHcZGp>S)`E zuf==sHGOU;uv0OMspj;v+O$%pGW2)@tj}%Lr^9We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<8aK#JeWS!Ral|3i+u1?6mn

BhjkFB91D_ z+WXcauH(_uaNMvE_V;0VbQ-eN^{sy#g?zZH>TWf>-~J#v?#(EeK(G%@6YIl-tRIhn z{B4Im%_j_EX1HixKr!6-)L&=<@{h!)R$HgH`@mGX$5RRH87At3KIfm2T}6QClgkcl z0{ghbVkFj_~RI0p8Z@4-4kcOBr6Dk zJtA$N=<%^SYFZ_f3tj(ifX*Fq!#r#*kIqRW9RNBjaHD^LPAgvGXcV;JX7qirlkQSl z83pPB031H{l^C(L5hQNeh=+&ksiTV#@`RAdg5<4x%j1J}z4) z49ZBXaqJs^@~$g+0OJxp!J-G3-U27sVqRSksmj`$+Y72vT0E+uD*pqFlbOdG@C`(k z(QYvFCrv%?&1_le)lwE7O1IM(D(t=ohVR(jv%++x?txvt~yOH;OPaps+9u>&1DLLUO?kAsMuX0ZT~yhvs-Zj$VvbR^Zz7Z z*0@c{Nj8#JH|ad)fx$XJ;>R1dYyz?lDRZPvB-eehgVMV+g&da!2h#sJq2N|!^O0kd zO|on48!au(iB^}Rnq{DK0^5jELELI=xFX(o_q_iJ2#jRffiGH^P~N7rhR9x&r%0P}Lap_s}KyPdiL{j-+U5OzCdV&RX9%bCE zvCzbT9&!jzaep0O^DI8!X@y{>dfj4L_1L{g-4Y;?g%j2fRu=;FJ~q#Wph)ayMa}|c>20vuqs~&2qa+IB4ZsH2A@EG|GgLhX1 z8xHEGEefGsTy9U#@sT<{d4sJ)UTZww!AE7cn=@1<~-?VcRp!M3j4PI7eF>|t=-^Cavy`b%iSFd!i4FzS7ydUs cRiPI+wI&}sUR&O5fKHQvD@qkSe&zT70bxfGz5oCK literal 0 HcmV?d00001 diff --git a/ui/litellm-dashboard/src/components/provider_info_helpers.tsx b/ui/litellm-dashboard/src/components/provider_info_helpers.tsx index 5a163bce3b6..78f8bf1ae92 100644 --- a/ui/litellm-dashboard/src/components/provider_info_helpers.tsx +++ b/ui/litellm-dashboard/src/components/provider_info_helpers.tsx @@ -27,6 +27,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"; @@ -127,6 +128,7 @@ export enum Providers { Hosted_Vllm = "Hosted vLLM", HUGGINGFACE = "Huggingface", HYPERBOLIC = "Hyperbolic", + HOSTINGER_ROUTER = "Hostinger Router", Infinity = "Infinity", JinaAI = "Jina AI", LAMBDA_AI = "Lambda Ai", @@ -253,6 +255,7 @@ export const provider_map: Record = { Hosted_Vllm: "hosted_vllm", HUGGINGFACE: "huggingface", HYPERBOLIC: "hyperbolic", + HOSTINGER_ROUTER: "hostinger_router", Infinity: "infinity", JinaAI: "jina_ai", LAMBDA_AI: "lambda_ai", @@ -372,6 +375,7 @@ export const providerLogoMap: Partial> = { [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.LAMBDA_AI]: lambdaLogo.src, @@ -473,6 +477,7 @@ const providerPlaceholderMap: Partial> = { [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", From ec74f0dc4f4584719c9afcf2cabb43c4a3205971 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Wed, 28 Oct 2026 06:31:52 -0700 Subject: [PATCH 02/14] fix(hostinger_router): match prices to the live catalog, drop retired max_tokens, regenerate the endpoint matrix --- ...odel_prices_and_context_window_backup.json | 18 +++----- .../provider_endpoints_support_backup.json | 44 +++++++++++-------- model_prices_and_context_window.json | 18 +++----- provider_endpoints_support.json | 18 +++++--- 4 files changed, 53 insertions(+), 45 deletions(-) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 74bc3a9c7df..e4cb8ca47cd 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -38355,7 +38355,6 @@ "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, @@ -38367,16 +38366,15 @@ "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, + "cache_creation_input_token_cost": 3.3e-06, + "cache_creation_input_token_cost_above_1hr": 5.28e-06, + "cache_read_input_token_cost": 2.64e-07, + "input_cost_per_token": 2.64e-06, "litellm_provider": "hostinger_router", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", - "output_cost_per_token": 0.000012, + "output_cost_per_token": 1.32e-05, "supports_function_calling": true, "supports_prompt_caching": true, "supports_reasoning": true, @@ -38387,19 +38385,17 @@ "source": "https://router.hostinger.com/v1/models" }, "hostinger_router/text-embedding-3-large": { - "input_cost_per_token": 0.000000156, + "input_cost_per_token": 1.716e-07, "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, + "input_cost_per_token": 3e-08, "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" diff --git a/litellm/provider_endpoints_support_backup.json b/litellm/provider_endpoints_support_backup.json index 88ad89dc237..ac3caf3a89b 100644 --- a/litellm/provider_endpoints_support_backup.json +++ b/litellm/provider_endpoints_support_backup.json @@ -1061,6 +1061,32 @@ "generateContent": false } }, + "hostinger_router": { + "display_name": "Hostinger Router (`hostinger_router`)", + "url": "https://docs.litellm.ai/docs/providers/hostinger_router", + "endpoints": { + "chat_completions": true, + "responses": true, + "text_completion": true, + "embeddings": true, + "image_generations": false, + "image_edits": false, + "audio_transcriptions": false, + "audio_speech": false, + "rerank": false, + "ocr": false, + "search": false, + "moderations": false, + "realtime": false, + "video_generations": false, + "batches": false, + "messages": true, + "interactions": true, + "systemone": false, + "a2a": true, + "generateContent": true + } + }, "crusoe": { "display_name": "Crusoe (`crusoe`)", "url": "https://docs.litellm.ai/docs/providers/crusoe", @@ -1087,24 +1113,6 @@ "generateContent": true } }, - "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", diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 74bc3a9c7df..e4cb8ca47cd 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -38355,7 +38355,6 @@ "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, @@ -38367,16 +38366,15 @@ "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, + "cache_creation_input_token_cost": 3.3e-06, + "cache_creation_input_token_cost_above_1hr": 5.28e-06, + "cache_read_input_token_cost": 2.64e-07, + "input_cost_per_token": 2.64e-06, "litellm_provider": "hostinger_router", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", - "output_cost_per_token": 0.000012, + "output_cost_per_token": 1.32e-05, "supports_function_calling": true, "supports_prompt_caching": true, "supports_reasoning": true, @@ -38387,19 +38385,17 @@ "source": "https://router.hostinger.com/v1/models" }, "hostinger_router/text-embedding-3-large": { - "input_cost_per_token": 0.000000156, + "input_cost_per_token": 1.716e-07, "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, + "input_cost_per_token": 3e-08, "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" diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index c317a8b616d..ac3caf3a89b 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -1066,17 +1066,25 @@ "url": "https://docs.litellm.ai/docs/providers/hostinger_router", "endpoints": { "chat_completions": true, - "messages": true, "responses": true, + "text_completion": true, "embeddings": true, "image_generations": false, + "image_edits": false, "audio_transcriptions": false, "audio_speech": false, - "moderations": false, - "batches": false, "rerank": false, - "a2a": false, - "interactions": false + "ocr": false, + "search": false, + "moderations": false, + "realtime": false, + "video_generations": false, + "batches": false, + "messages": true, + "interactions": true, + "systemone": false, + "a2a": true, + "generateContent": true } }, "crusoe": { From 6ea48ceae05197e28f5d66fa82da6fa83f894613 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Wed, 28 Oct 2026 22:54:55 -0700 Subject: [PATCH 03/14] fix(hostinger_router): keep api_base detection off, send embeddings headers as HTTP headers, drop generic key fallback Unprefixed models called with Hostinger's api_base keep their own provider, JSON provider embeddings no longer borrow OPENAI_LIKE_API_KEY or litellm.api_key, and the openai_like embedding handler sends extra_headers as request headers instead of in the JSON body --- litellm/constants.py | 1 - litellm/llms/openai_like/embedding/handler.py | 12 +- litellm/llms/openai_like/json_loader.py | 1 - litellm/main.py | 6 +- .../test_hostinger_router_provider.py | 119 +++++++++++------- 5 files changed, 82 insertions(+), 57 deletions(-) diff --git a/litellm/constants.py b/litellm/constants.py index 94f0eb68c2c..650cde85fe5 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -1062,7 +1062,6 @@ 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", diff --git a/litellm/llms/openai_like/embedding/handler.py b/litellm/llms/openai_like/embedding/handler.py index 77b6b673707..3f13a970a82 100644 --- a/litellm/llms/openai_like/embedding/handler.py +++ b/litellm/llms/openai_like/embedding/handler.py @@ -103,8 +103,12 @@ class OpenAILikeEmbeddingHandler(OpenAILikeBase): custom_endpoint=custom_endpoint, ) model = model - filtered_optional_params: Final = {k: v for k, v in optional_params.items() if v not in (None, "")} - data: Final = {"model": model, "input": input, **filtered_optional_params} + data: Final = { + "model": model, + "input": input, + **{k: v for k, v in optional_params.items() if k != "extra_headers" and v not in (None, "")}, + } + request_headers: Final = {**(optional_params.get("extra_headers") or {}), **headers} ## LOGGING logging_obj.pre_call( @@ -123,7 +127,7 @@ class OpenAILikeEmbeddingHandler(OpenAILikeBase): api_key=api_key, timeout=timeout, client=client, - headers=headers, + headers=request_headers, ) if client is None or isinstance(client, AsyncHTTPHandler): self.client = HTTPHandler(timeout=timeout) @@ -134,7 +138,7 @@ class OpenAILikeEmbeddingHandler(OpenAILikeBase): try: response: Final = self.client.post( api_base, - headers=headers, + headers=request_headers, data=json.dumps(data), ) diff --git a/litellm/llms/openai_like/json_loader.py b/litellm/llms/openai_like/json_loader.py index c2208d49133..a5bdf2c94ab 100644 --- a/litellm/llms/openai_like/json_loader.py +++ b/litellm/llms/openai_like/json_loader.py @@ -89,7 +89,6 @@ class JSONProviderRegistry: @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 diff --git a/litellm/main.py b/litellm/main.py index 0828a7e94be..79ae81df218 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -6984,13 +6984,13 @@ 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 + or JSONProviderRegistry.supports_embeddings(custom_llm_provider) ): api_base = api_base or litellm.api_base or get_secret_str("OPENAI_LIKE_API_BASE") # set API KEY - if api_key is None: - api_key = api_key or litellm.api_key or litellm.openai_like_key or get_secret_str("OPENAI_LIKE_API_KEY") + if api_key is None and not JSONProviderRegistry.supports_embeddings(custom_llm_provider): + api_key = litellm.api_key or litellm.openai_like_key or get_secret_str("OPENAI_LIKE_API_KEY") if headers is not None and headers != {}: optional_params["extra_headers"] = headers diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py index 324bfa2eda5..0788a86674a 100644 --- a/tests/unit/llms/openai_like/test_hostinger_router_provider.py +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -1,5 +1,4 @@ import json -from pathlib import Path from typing import Final import pytest @@ -44,6 +43,20 @@ def test_hostinger_router_provider_keeps_explicit_credentials(monkeypatch: pytes assert api_base == "https://router.internal.example/v1" +@pytest.mark.parametrize("model", ["gpt-5-nano", "claude-sonnet-5"]) +def test_hostinger_router_api_base_keeps_unprefixed_model_provider(model: str): + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + _, provider_without_api_base, _, _ = get_llm_provider(model=model) + _, provider_with_hostinger_api_base, _, _ = get_llm_provider( + model=model, + api_base="https://router.hostinger.com/v1", + api_key="hostinger-test-key", + ) + + assert provider_with_hostinger_api_base == provider_without_api_base + + 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" @@ -79,44 +92,6 @@ def test_hostinger_router_model_cost_and_capabilities(model: str): 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( @@ -215,17 +190,17 @@ def test_hostinger_router_responses_request(): assert response.output[0].content[0].text == "Hello from Hostinger Router" +EMBEDDING_RESPONSE: Final = { + "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}, +} + + 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}, - }, - ) + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) response: Final = litellm.embedding( model="hostinger_router/text-embedding-3-small", input=["Say hello"], @@ -240,6 +215,54 @@ def test_hostinger_router_embeddings_request(): assert response.data[0]["embedding"] == [0.1, 0.2, 0.3] +def test_hostinger_router_embeddings_send_extra_headers_as_http_headers(): + with respx.mock() as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + extra_headers={"X-Trace-Id": "trace-123"}, + ) + + request: Final = route.calls.last.request + body: Final = json.loads(request.content) + assert request.headers["x-trace-id"] == "trace-123" + assert request.headers["authorization"] == "Bearer hostinger-test-key" + assert request.headers["content-type"] == "application/json" + assert set(body) == {"model", "input"} + + +def test_hostinger_router_embeddings_never_borrow_another_providers_key(monkeypatch: pytest.MonkeyPatch): + monkeypatch.delenv("HOSTINGER_ROUTER_API_KEY", raising=False) + monkeypatch.setenv("OPENAI_LIKE_API_KEY", "other-provider-key") + monkeypatch.setenv("OPENAI_API_KEY", "other-provider-key") + + with respx.mock(assert_all_called=False) as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + with pytest.raises(litellm.BadRequestError, match="Missing API Key"): + litellm.embedding(model="hostinger_router/text-embedding-3-small", input=["Say hello"]) + + assert route.call_count == 0 + + +def test_json_provider_without_embeddings_endpoint_refuses_embeddings(): + from litellm.llms.openai_like.json_loader import JSONProviderRegistry + + slug: Final = next( + slug + for slug in JSONProviderRegistry.list_providers() + if not JSONProviderRegistry.supports_embeddings(slug) and slug not in litellm.provider_list + ) + + with respx.mock(assert_all_called=False) as upstream: + route: Final = upstream.route().respond(200, json=EMBEDDING_RESPONSE) + with pytest.raises(litellm.BadRequestError): + litellm.embedding(model=f"{slug}/text-embedding-3-small", input=["Say hello"], api_key="test-key") + + assert route.call_count == 0 + + @pytest.mark.asyncio async def test_hostinger_router_anthropic_messages_request(monkeypatch: pytest.MonkeyPatch): monkeypatch.setattr(litellm, "disable_aiohttp_transport", True) From a9942ead60317c0cbd02b0d4d90e24a4b5665b09 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 29 Oct 2026 03:41:06 -0700 Subject: [PATCH 04/14] fix(openai_like): route Hostinger messages and responses per model, keep the configured key header Native /v1/messages and /v1/responses calls for a JSON provider now also follow the model's cost-map supported_endpoints, so Hostinger models without the route go through chat completions instead of a 403. Embedding key headers replace extra_headers case-insensitively, and pinstripes stops declaring /v1/embeddings. --- litellm/llms/openai_like/embedding/handler.py | 12 ++- litellm/llms/openai_like/json_loader.py | 20 +++++ litellm/llms/openai_like/providers.json | 4 +- litellm/utils.py | 4 +- .../test_hostinger_router_provider.py | 79 +++++++++++++++++++ 5 files changed, 114 insertions(+), 5 deletions(-) diff --git a/litellm/llms/openai_like/embedding/handler.py b/litellm/llms/openai_like/embedding/handler.py index 3f13a970a82..119bdb20526 100644 --- a/litellm/llms/openai_like/embedding/handler.py +++ b/litellm/llms/openai_like/embedding/handler.py @@ -3,9 +3,11 @@ ## Allows jina ai embedding calls - which don't allow 'encoding_format' in payload. import json +from collections.abc import Mapping from typing import Final import httpx +from pydantic import TypeAdapter import litellm from litellm.llms.custom_httpx.http_handler import ( @@ -17,6 +19,8 @@ from litellm.types.utils import EmbeddingResponse from ..common_utils import OpenAILikeBase, OpenAILikeError +_HEADERS_ADAPTER: Final = TypeAdapter(Mapping[str, str]) + class OpenAILikeEmbeddingHandler(OpenAILikeBase): def __init__(self, **kwargs): @@ -108,7 +112,13 @@ class OpenAILikeEmbeddingHandler(OpenAILikeBase): "input": input, **{k: v for k, v in optional_params.items() if k != "extra_headers" and v not in (None, "")}, } - request_headers: Final = {**(optional_params.get("extra_headers") or {}), **headers} + extra_headers: Final = _HEADERS_ADAPTER.validate_python(optional_params.get("extra_headers") or {}) + key_headers: Final = _HEADERS_ADAPTER.validate_python(headers) + key_header_names: Final = frozenset(name.lower() for name in key_headers) + request_headers: Final = { + **{name: value for name, value in extra_headers.items() if name.lower() not in key_header_names}, + **key_headers, + } ## LOGGING logging_obj.pre_call( diff --git a/litellm/llms/openai_like/json_loader.py b/litellm/llms/openai_like/json_loader.py index bbb1532ed34..3076bc5bc76 100644 --- a/litellm/llms/openai_like/json_loader.py +++ b/litellm/llms/openai_like/json_loader.py @@ -14,6 +14,8 @@ from litellm.types.utils import ProviderSpecificModelInfo _PROVIDER_INFO_ADAPTER: Final = TypeAdapter(ProviderSpecificModelInfo) _SPECIAL_HANDLING_ADAPTER: Final = TypeAdapter(Mapping[str, bool]) +_MODEL_ROW_ADAPTER: Final = TypeAdapter(Mapping[str, object]) +_ENDPOINTS_ADAPTER: Final = TypeAdapter(tuple[str, ...]) class SimpleProviderConfig: @@ -97,11 +99,29 @@ class JSONProviderRegistry: return False return "/v1/embeddings" in provider.supported_endpoints + @classmethod + def serves_endpoint(cls, slug: str, model: str | None, endpoint: str) -> bool: + provider: Final = cls._providers.get(slug) + if provider is None: + return False + return endpoint in provider.supported_endpoints or endpoint in _model_supported_endpoints(slug, model) + @classmethod def list_providers(cls) -> list: """List all registered provider slugs""" return list(cls._providers.keys()) +def _model_supported_endpoints(slug: str, model: str | None) -> tuple[str, ...]: + import litellm + + if not model: + return () + row: Final = _MODEL_ROW_ADAPTER.validate_python( + litellm.model_cost.get(f"{slug}/{model.removeprefix(f'{slug}/')}", {}) + ) + return _ENDPOINTS_ADAPTER.validate_python(row.get("supported_endpoints") or ()) + + # Load on import JSONProviderRegistry.load() diff --git a/litellm/llms/openai_like/providers.json b/litellm/llms/openai_like/providers.json index ab65ef33574..b33ac999e0a 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -211,7 +211,7 @@ "param_mappings": { "max_completion_tokens": "max_tokens" }, - "supported_endpoints": ["/v1/chat/completions", "/v1/responses", "/v1/embeddings"] + "supported_endpoints": ["/v1/chat/completions", "/v1/responses"] }, "scx-ai": { "base_url": "https://api.scx.ai/v1", @@ -235,7 +235,7 @@ "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"] + "supported_endpoints": ["/v1/chat/completions", "/v1/embeddings"] }, "sail": { "base_url": "https://api.sailresearch.com/v1", diff --git a/litellm/utils.py b/litellm/utils.py index 72c37c3760e..cca3278a6a9 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -9771,7 +9771,7 @@ class ProviderConfigManager: from litellm.llms.openai_like.json_loader import JSONProviderRegistry json_provider: Final = JSONProviderRegistry.get(provider.value) - if json_provider is not None and "/v1/messages" in json_provider.supported_endpoints: + if json_provider is not None and JSONProviderRegistry.serves_endpoint(provider.value, model, "/v1/messages"): from litellm.llms.openai_like.messages.transformation import ( JSONProviderAnthropicMessagesConfig, ) @@ -9910,7 +9910,7 @@ class ProviderConfigManager: return result # Fall back to JSON providers (generic OpenAI-compatible) - if JSONProviderRegistry.exists(provider_str) and JSONProviderRegistry.supports_responses_api(provider_str): + if JSONProviderRegistry.serves_endpoint(provider_str, model, "/v1/responses"): provider_config: Final = JSONProviderRegistry.get(provider_str) if provider_config is not None: return create_responses_config_class(provider_config)() diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py index 0788a86674a..dcbeefa1b0e 100644 --- a/tests/unit/llms/openai_like/test_hostinger_router_provider.py +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -233,6 +233,21 @@ def test_hostinger_router_embeddings_send_extra_headers_as_http_headers(): assert set(body) == {"model", "input"} +def test_hostinger_router_embeddings_key_headers_replace_extra_headers_of_any_case(): + with respx.mock() as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + extra_headers={"authorization": "Bearer caller-key", "content-type": "text/plain"}, + ) + + request: Final = route.calls.last.request + assert request.headers.get_list("authorization") == ["Bearer hostinger-test-key"] + assert request.headers.get_list("content-type") == ["application/json"] + + def test_hostinger_router_embeddings_never_borrow_another_providers_key(monkeypatch: pytest.MonkeyPatch): monkeypatch.delenv("HOSTINGER_ROUTER_API_KEY", raising=False) monkeypatch.setenv("OPENAI_LIKE_API_KEY", "other-provider-key") @@ -297,3 +312,67 @@ async def test_hostinger_router_anthropic_messages_request(monkeypatch: pytest.M assert body["model"] == "claude-sonnet-5" assert body["messages"] == [{"role": "user", "content": "Say hello"}] assert response["content"][0]["text"] == "Hello from Hostinger Router" + + +CHAT_COMPLETION_RESPONSE: Final = { + "id": "chatcmpl_hostinger", + "object": "chat.completion", + "created": 1_789_550_000, + "model": "gpt-5.2", + "choices": [ + { + "index": 0, + "message": {"role": "assistant", "content": "Hello from Hostinger Router"}, + "finish_reason": "stop", + } + ], + "usage": {"prompt_tokens": 4, "completion_tokens": 3, "total_tokens": 7}, +} +UNSUPPORTED_ENDPOINT: Final = {"error": {"message": "Model does not support this endpoint."}} + + +@pytest.mark.asyncio +@pytest.mark.parametrize("model", ["gpt-5.2", "gpt-5-nano"]) +async def test_hostinger_router_messages_bridge_models_without_native_messages( + model: str, monkeypatch: pytest.MonkeyPatch +): + monkeypatch.setattr(litellm, "disable_aiohttp_transport", True) + monkeypatch.setattr(litellm, "in_memory_llm_clients_cache", LLMClientCache()) + with respx.mock(assert_all_called=False) as upstream: + native: Final = upstream.post("https://router.hostinger.com/v1/messages").respond( + 403, json=UNSUPPORTED_ENDPOINT + ) + chat: Final = upstream.post("https://router.hostinger.com/v1/chat/completions").respond( + 200, json=CHAT_COMPLETION_RESPONSE + ) + response: Final = await litellm.anthropic.messages.acreate( + model=f"hostinger_router/{model}", + messages=[{"role": "user", "content": "Say hello"}], + max_tokens=32, + api_key="hostinger-test-key", + ) + + assert native.call_count == 0 + assert chat.call_count == 1 + assert json.loads(chat.calls.last.request.content)["model"] == model + assert response["content"][0]["text"] == "Hello from Hostinger Router" + + +def test_hostinger_router_responses_bridge_models_without_native_responses(): + with respx.mock(assert_all_called=False) as upstream: + native: Final = upstream.post("https://router.hostinger.com/v1/responses").respond( + 403, json=UNSUPPORTED_ENDPOINT + ) + chat: Final = upstream.post("https://router.hostinger.com/v1/chat/completions").respond( + 200, json=CHAT_COMPLETION_RESPONSE + ) + response: Final = litellm.responses( + model="hostinger_router/claude-sonnet-5", + input="Say hello", + api_key="hostinger-test-key", + ) + + assert native.call_count == 0 + assert chat.call_count == 1 + assert json.loads(chat.calls.last.request.content)["model"] == "claude-sonnet-5" + assert response.output[0].content[0].text == "Hello from Hostinger Router" From d98f05db6d2cb0903ae4bdf856d8e0ad18bac28e Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 29 Oct 2026 05:04:47 -0700 Subject: [PATCH 05/14] fix(openai_like): let embeddings extra_headers override the key's headers as chat does Embeddings now match chat through the OpenAI SDK, so an extra_headers entry replaces the key's header of the same name in any letter case. The Hostinger capability test checks that the supports_* lookups agree with each cost-map row instead of pinning vendor flags --- litellm/llms/openai_like/embedding/handler.py | 6 ++--- .../test_hostinger_router_provider.py | 23 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/litellm/llms/openai_like/embedding/handler.py b/litellm/llms/openai_like/embedding/handler.py index 119bdb20526..e00477b3876 100644 --- a/litellm/llms/openai_like/embedding/handler.py +++ b/litellm/llms/openai_like/embedding/handler.py @@ -114,10 +114,10 @@ class OpenAILikeEmbeddingHandler(OpenAILikeBase): } extra_headers: Final = _HEADERS_ADAPTER.validate_python(optional_params.get("extra_headers") or {}) key_headers: Final = _HEADERS_ADAPTER.validate_python(headers) - key_header_names: Final = frozenset(name.lower() for name in key_headers) + extra_header_names: Final = frozenset(name.lower() for name in extra_headers) request_headers: Final = { - **{name: value for name, value in extra_headers.items() if name.lower() not in key_header_names}, - **key_headers, + **{name: value for name, value in key_headers.items() if name.lower() not in extra_header_names}, + **extra_headers, } ## LOGGING diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py index dcbeefa1b0e..4d44cb9839d 100644 --- a/tests/unit/llms/openai_like/test_hostinger_router_provider.py +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -81,15 +81,17 @@ def test_hostinger_router_model_cost_and_capabilities(model: str): 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) + capability_checks: Final = ( + ("supports_function_calling", litellm.supports_function_calling), + ("supports_reasoning", litellm.supports_reasoning), + ("supports_response_schema", litellm.supports_response_schema), + ("supports_vision", litellm.supports_vision), + ) + assert {name: check(model) for name, check in capability_checks} == { + name: model_info.get(name) is True for name, _ in capability_checks + } def test_hostinger_router_chat_completions_request(): @@ -233,19 +235,20 @@ def test_hostinger_router_embeddings_send_extra_headers_as_http_headers(): assert set(body) == {"model", "input"} -def test_hostinger_router_embeddings_key_headers_replace_extra_headers_of_any_case(): +def test_hostinger_router_embeddings_extra_headers_replace_key_headers_of_any_case(): with respx.mock() as upstream: route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) litellm.embedding( model="hostinger_router/text-embedding-3-small", input=["Say hello"], api_key="hostinger-test-key", - extra_headers={"authorization": "Bearer caller-key", "content-type": "text/plain"}, + extra_headers={"authorization": "Bearer caller-key", "x-trace-id": "trace-1"}, ) request: Final = route.calls.last.request - assert request.headers.get_list("authorization") == ["Bearer hostinger-test-key"] + assert request.headers.get_list("authorization") == ["Bearer caller-key"] assert request.headers.get_list("content-type") == ["application/json"] + assert request.headers.get_list("x-trace-id") == ["trace-1"] def test_hostinger_router_embeddings_never_borrow_another_providers_key(monkeypatch: pytest.MonkeyPatch): From 4bf0faf702211f603419314dc81e0cec43818647 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 29 Oct 2026 08:00:07 -0700 Subject: [PATCH 06/14] fix(openai_like): send numeric embeddings extra_headers as text and keep Hostinger's 1h cache TTL A config.yaml header like X-Org-Id: 12345 loads as an int, which the embeddings header check rejected with a 500. Int and float values now go out as their decimal text. Hostinger Router accepts and bills a 1h cache_control TTL on /v1/messages, so its provider entry opts into keeping it. --- litellm/llms/openai_like/embedding/handler.py | 15 ++++-- litellm/llms/openai_like/providers.json | 3 ++ .../test_hostinger_router_provider.py | 50 +++++++++++++++++++ 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/litellm/llms/openai_like/embedding/handler.py b/litellm/llms/openai_like/embedding/handler.py index e00477b3876..891f7876052 100644 --- a/litellm/llms/openai_like/embedding/handler.py +++ b/litellm/llms/openai_like/embedding/handler.py @@ -4,10 +4,11 @@ import json from collections.abc import Mapping +from types import MappingProxyType from typing import Final import httpx -from pydantic import TypeAdapter +from pydantic import StrictFloat, StrictInt, StrictStr, TypeAdapter import litellm from litellm.llms.custom_httpx.http_handler import ( @@ -19,7 +20,11 @@ from litellm.types.utils import EmbeddingResponse from ..common_utils import OpenAILikeBase, OpenAILikeError -_HEADERS_ADAPTER: Final = TypeAdapter(Mapping[str, str]) +_HEADERS_ADAPTER: Final = TypeAdapter(Mapping[str, StrictStr | StrictInt | StrictFloat]) + + +def _as_header_text(headers: Mapping[str, str | int | float]) -> Mapping[str, str]: + return MappingProxyType({name: str(value) for name, value in headers.items()}) class OpenAILikeEmbeddingHandler(OpenAILikeBase): @@ -112,8 +117,10 @@ class OpenAILikeEmbeddingHandler(OpenAILikeBase): "input": input, **{k: v for k, v in optional_params.items() if k != "extra_headers" and v not in (None, "")}, } - extra_headers: Final = _HEADERS_ADAPTER.validate_python(optional_params.get("extra_headers") or {}) - key_headers: Final = _HEADERS_ADAPTER.validate_python(headers) + extra_headers: Final = _as_header_text( + _HEADERS_ADAPTER.validate_python(optional_params.get("extra_headers") or {}) + ) + key_headers: Final = _as_header_text(_HEADERS_ADAPTER.validate_python(headers)) extra_header_names: Final = frozenset(name.lower() for name in extra_headers) request_headers: Final = { **{name: value for name, value in key_headers.items() if name.lower() not in extra_header_names}, diff --git a/litellm/llms/openai_like/providers.json b/litellm/llms/openai_like/providers.json index b33ac999e0a..60629b26871 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -235,6 +235,9 @@ "base_url": "https://router.hostinger.com/v1", "api_key_env": "HOSTINGER_ROUTER_API_KEY", "api_base_env": "HOSTINGER_ROUTER_API_BASE", + "constraints": { + "cache_control_ttl": true + }, "supported_endpoints": ["/v1/chat/completions", "/v1/embeddings"] }, "sail": { diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py index 4d44cb9839d..f164bad03e6 100644 --- a/tests/unit/llms/openai_like/test_hostinger_router_provider.py +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -251,6 +251,20 @@ def test_hostinger_router_embeddings_extra_headers_replace_key_headers_of_any_ca assert request.headers.get_list("x-trace-id") == ["trace-1"] +@pytest.mark.parametrize(("configured", "sent"), [(12345, "12345"), (1.5, "1.5")]) +def test_hostinger_router_embeddings_send_numeric_extra_headers_as_text(configured: int | float, sent: str): + with respx.mock() as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + extra_headers={"X-Org-Id": configured}, + ) + + assert route.calls.last.request.headers.get_list("x-org-id") == [sent] + + def test_hostinger_router_embeddings_never_borrow_another_providers_key(monkeypatch: pytest.MonkeyPatch): monkeypatch.delenv("HOSTINGER_ROUTER_API_KEY", raising=False) monkeypatch.setenv("OPENAI_LIKE_API_KEY", "other-provider-key") @@ -317,6 +331,42 @@ async def test_hostinger_router_anthropic_messages_request(monkeypatch: pytest.M assert response["content"][0]["text"] == "Hello from Hostinger Router" +@pytest.mark.asyncio +async def test_hostinger_router_anthropic_messages_keep_one_hour_cache_ttl(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setattr(litellm, "disable_aiohttp_transport", True) + monkeypatch.setattr(litellm, "in_memory_llm_clients_cache", LLMClientCache()) + cached_block: Final = { + "type": "text", + "text": "Long shared context", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + 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"}], + "stop_reason": "end_turn", + "stop_sequence": None, + "usage": {"input_tokens": 4, "output_tokens": 1}, + }, + ) + await litellm.anthropic.messages.acreate( + model="hostinger_router/claude-sonnet-5", + system=[cached_block], + messages=[{"role": "user", "content": [cached_block]}], + max_tokens=32, + api_key="hostinger-test-key", + ) + + body: Final = json.loads(route.calls.last.request.content) + assert body["system"] == [cached_block] + assert body["messages"] == [{"role": "user", "content": [cached_block]}] + + CHAT_COMPLETION_RESPONSE: Final = { "id": "chatcmpl_hostinger", "object": "chat.completion", From c1d0b8f16c90fa131d9a04366ee3e0b9c5290d65 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 29 Oct 2026 10:38:59 -0700 Subject: [PATCH 07/14] fix(openai_like): send Hostinger's 1h cache TTL as the 5-minute default so cache writes bill at its charge --- litellm/llms/openai_like/providers.json | 3 -- .../test_hostinger_router_provider.py | 36 ------------------- 2 files changed, 39 deletions(-) diff --git a/litellm/llms/openai_like/providers.json b/litellm/llms/openai_like/providers.json index 3d046f2d279..c4f0456cebd 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -235,9 +235,6 @@ "base_url": "https://router.hostinger.com/v1", "api_key_env": "HOSTINGER_ROUTER_API_KEY", "api_base_env": "HOSTINGER_ROUTER_API_BASE", - "constraints": { - "cache_control_ttl": true - }, "supported_endpoints": ["/v1/chat/completions", "/v1/embeddings"] }, "sail": { diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py index f164bad03e6..47cf6d96ce0 100644 --- a/tests/unit/llms/openai_like/test_hostinger_router_provider.py +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -331,42 +331,6 @@ async def test_hostinger_router_anthropic_messages_request(monkeypatch: pytest.M assert response["content"][0]["text"] == "Hello from Hostinger Router" -@pytest.mark.asyncio -async def test_hostinger_router_anthropic_messages_keep_one_hour_cache_ttl(monkeypatch: pytest.MonkeyPatch): - monkeypatch.setattr(litellm, "disable_aiohttp_transport", True) - monkeypatch.setattr(litellm, "in_memory_llm_clients_cache", LLMClientCache()) - cached_block: Final = { - "type": "text", - "text": "Long shared context", - "cache_control": {"type": "ephemeral", "ttl": "1h"}, - } - 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"}], - "stop_reason": "end_turn", - "stop_sequence": None, - "usage": {"input_tokens": 4, "output_tokens": 1}, - }, - ) - await litellm.anthropic.messages.acreate( - model="hostinger_router/claude-sonnet-5", - system=[cached_block], - messages=[{"role": "user", "content": [cached_block]}], - max_tokens=32, - api_key="hostinger-test-key", - ) - - body: Final = json.loads(route.calls.last.request.content) - assert body["system"] == [cached_block] - assert body["messages"] == [{"role": "user", "content": [cached_block]}] - - CHAT_COMPLETION_RESPONSE: Final = { "id": "chatcmpl_hostinger", "object": "chat.completion", From e8ab6a0d1fefdf0ec2cd6e173c168a88fde3f89e Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 29 Oct 2026 14:12:52 -0700 Subject: [PATCH 08/14] fix(openai_like): route Hostinger natives per model from providers.json, refuse non-text embeddings headers unless drop_params --- litellm/llms/databricks/embed/handler.py | 2 + litellm/llms/openai_like/README.md | 14 ++ litellm/llms/openai_like/embedding/handler.py | 30 ++++- litellm/llms/openai_like/json_loader.py | 22 ++- litellm/llms/openai_like/providers.json | 6 +- litellm/main.py | 1 + .../test_hostinger_router_provider.py | 127 ++++++++++++++++++ 7 files changed, 180 insertions(+), 22 deletions(-) diff --git a/litellm/llms/databricks/embed/handler.py b/litellm/llms/databricks/embed/handler.py index 8b2fa768968..05807a118c3 100644 --- a/litellm/llms/databricks/embed/handler.py +++ b/litellm/llms/databricks/embed/handler.py @@ -26,6 +26,7 @@ class DatabricksEmbeddingHandler(OpenAILikeEmbeddingHandler, DatabricksBase): aembedding=None, custom_endpoint: bool | None = None, headers: dict | None = None, + drop_params: bool = False, ) -> EmbeddingResponse: # Check for custom user agent in optional_params or environment # This allows partners building on LiteLLM to set their own telemetry @@ -58,4 +59,5 @@ class DatabricksEmbeddingHandler(OpenAILikeEmbeddingHandler, DatabricksBase): aembedding=aembedding, custom_endpoint=True, headers=headers, + drop_params=drop_params, ) diff --git a/litellm/llms/openai_like/README.md b/litellm/llms/openai_like/README.md index c56f58b24c9..fb00b07c986 100644 --- a/litellm/llms/openai_like/README.md +++ b/litellm/llms/openai_like/README.md @@ -125,6 +125,20 @@ The provider inherits all request/response handling from OpenAI's Responses API If `supported_endpoints` is omitted, it defaults to `[]` (only chat completions, which is always enabled for JSON providers). +When only some models serve an endpoint natively, list them under `model_supported_endpoints`. Every other model reaches `/v1/responses` and `/v1/messages` through chat completions: + +```json +{ + "your_provider": { + "supported_endpoints": ["/v1/chat/completions"], + "model_supported_endpoints": { + "model-a": ["/v1/messages"], + "model-b": ["/v1/responses"] + } + } +} +``` + ### How It Works 1. `json_loader.py` checks `supported_endpoints` for `/v1/responses` diff --git a/litellm/llms/openai_like/embedding/handler.py b/litellm/llms/openai_like/embedding/handler.py index 891f7876052..e6189d5e97e 100644 --- a/litellm/llms/openai_like/embedding/handler.py +++ b/litellm/llms/openai_like/embedding/handler.py @@ -8,7 +8,7 @@ from types import MappingProxyType from typing import Final import httpx -from pydantic import StrictFloat, StrictInt, StrictStr, TypeAdapter +from pydantic import TypeAdapter import litellm from litellm.llms.custom_httpx.http_handler import ( @@ -20,11 +20,26 @@ from litellm.types.utils import EmbeddingResponse from ..common_utils import OpenAILikeBase, OpenAILikeError -_HEADERS_ADAPTER: Final = TypeAdapter(Mapping[str, StrictStr | StrictInt | StrictFloat]) +_KEY_HEADERS_ADAPTER: Final = TypeAdapter(Mapping[str, str]) +_EXTRA_HEADERS_ADAPTER: Final = TypeAdapter(Mapping[str, object]) -def _as_header_text(headers: Mapping[str, str | int | float]) -> Mapping[str, str]: - return MappingProxyType({name: str(value) for name, value in headers.items()}) +def _header_text(value: object) -> str | None: + if isinstance(value, bool) or not isinstance(value, str | int | float): + return None + return str(value) + + +def _extra_headers_as_text(extra_headers: Mapping[str, object], model: str, drop_params: bool) -> Mapping[str, str]: + texts: Final = MappingProxyType({name: _header_text(value) for name, value in extra_headers.items()}) + malformed: Final = sorted(name for name, text in texts.items() if text is None) + if malformed and not drop_params: + raise litellm.UnsupportedParamsError( + message=f"extra_headers {', '.join(malformed)} must be text or a number. " + "To drop them from the call, set `litellm.drop_params = True`.", + model=model, + ) + return MappingProxyType({name: text for name, text in texts.items() if text is not None}) class OpenAILikeEmbeddingHandler(OpenAILikeBase): @@ -103,6 +118,7 @@ class OpenAILikeEmbeddingHandler(OpenAILikeBase): aembedding=None, custom_endpoint: bool | None = None, headers: dict | None = None, + drop_params: bool = False, ) -> EmbeddingResponse: api_base, headers = self._validate_environment( api_base=api_base, @@ -117,10 +133,10 @@ class OpenAILikeEmbeddingHandler(OpenAILikeBase): "input": input, **{k: v for k, v in optional_params.items() if k != "extra_headers" and v not in (None, "")}, } - extra_headers: Final = _as_header_text( - _HEADERS_ADAPTER.validate_python(optional_params.get("extra_headers") or {}) + extra_headers: Final = _extra_headers_as_text( + _EXTRA_HEADERS_ADAPTER.validate_python(optional_params.get("extra_headers") or {}), model, drop_params ) - key_headers: Final = _as_header_text(_HEADERS_ADAPTER.validate_python(headers)) + key_headers: Final = _KEY_HEADERS_ADAPTER.validate_python(headers) extra_header_names: Final = frozenset(name.lower() for name in extra_headers) request_headers: Final = { **{name: value for name, value in key_headers.items() if name.lower() not in extra_header_names}, diff --git a/litellm/llms/openai_like/json_loader.py b/litellm/llms/openai_like/json_loader.py index 3076bc5bc76..658e4176f22 100644 --- a/litellm/llms/openai_like/json_loader.py +++ b/litellm/llms/openai_like/json_loader.py @@ -14,8 +14,7 @@ from litellm.types.utils import ProviderSpecificModelInfo _PROVIDER_INFO_ADAPTER: Final = TypeAdapter(ProviderSpecificModelInfo) _SPECIAL_HANDLING_ADAPTER: Final = TypeAdapter(Mapping[str, bool]) -_MODEL_ROW_ADAPTER: Final = TypeAdapter(Mapping[str, object]) -_ENDPOINTS_ADAPTER: Final = TypeAdapter(tuple[str, ...]) +_MODEL_ENDPOINTS_ADAPTER: Final = TypeAdapter(Mapping[str, tuple[str, ...]]) class SimpleProviderConfig: @@ -33,6 +32,9 @@ class SimpleProviderConfig: data.get("special_handling", {}) ) self.supported_endpoints: Sequence[str] = data.get("supported_endpoints", []) + self.model_supported_endpoints: Mapping[str, tuple[str, ...]] = _MODEL_ENDPOINTS_ADAPTER.validate_python( + data.get("model_supported_endpoints", {}) + ) self.provider_info: ProviderSpecificModelInfo = ( _PROVIDER_INFO_ADAPTER.validate_python(data["provider_info"]) if "provider_info" in data else {} ) @@ -104,7 +106,10 @@ class JSONProviderRegistry: provider: Final = cls._providers.get(slug) if provider is None: return False - return endpoint in provider.supported_endpoints or endpoint in _model_supported_endpoints(slug, model) + model_endpoints: Final = ( + provider.model_supported_endpoints.get(model.removeprefix(f"{slug}/"), ()) if model else () + ) + return endpoint in provider.supported_endpoints or endpoint in model_endpoints @classmethod def list_providers(cls) -> list: @@ -112,16 +117,5 @@ class JSONProviderRegistry: return list(cls._providers.keys()) -def _model_supported_endpoints(slug: str, model: str | None) -> tuple[str, ...]: - import litellm - - if not model: - return () - row: Final = _MODEL_ROW_ADAPTER.validate_python( - litellm.model_cost.get(f"{slug}/{model.removeprefix(f'{slug}/')}", {}) - ) - return _ENDPOINTS_ADAPTER.validate_python(row.get("supported_endpoints") or ()) - - # Load on import JSONProviderRegistry.load() diff --git a/litellm/llms/openai_like/providers.json b/litellm/llms/openai_like/providers.json index c4f0456cebd..a71a9c3bb9b 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -235,7 +235,11 @@ "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/embeddings"] + "supported_endpoints": ["/v1/chat/completions", "/v1/embeddings"], + "model_supported_endpoints": { + "claude-sonnet-5": ["/v1/messages"], + "gpt-5.2": ["/v1/responses"] + } }, "sail": { "base_url": "https://api.sailresearch.com/v1", diff --git a/litellm/main.py b/litellm/main.py index f0ae4111580..fa84de8b7d1 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -7173,6 +7173,7 @@ def embedding( optional_params=optional_params, client=client, aembedding=aembedding, + drop_params=drop_unsupported_params, ) elif custom_llm_provider == "oci": if headers is None: diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py index 47cf6d96ce0..8d9b2e05c51 100644 --- a/tests/unit/llms/openai_like/test_hostinger_router_provider.py +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -1,3 +1,4 @@ +import copy import json from typing import Final @@ -265,6 +266,40 @@ def test_hostinger_router_embeddings_send_numeric_extra_headers_as_text(configur assert route.calls.last.request.headers.get_list("x-org-id") == [sent] +@pytest.mark.parametrize("configured", [True, None, ["a", "b"]]) +def test_hostinger_router_embeddings_refuse_non_text_extra_headers(configured: object): + with respx.mock(assert_all_called=False) as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + with pytest.raises(litellm.UnsupportedParamsError, match="X-Debug") as refused: + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + extra_headers={"X-Debug": configured}, + ) + + assert refused.value.status_code == 400 + assert route.call_count == 0 + + +@pytest.mark.parametrize("configured", [True, None, ["a", "b"]]) +def test_hostinger_router_embeddings_drop_non_text_extra_headers_under_drop_params(configured: object): + with respx.mock() as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + extra_headers={"X-Debug": configured, "X-Trace-Id": "trace-1"}, + drop_params=True, + ) + + request: Final = route.calls.last.request + assert "x-debug" not in request.headers + assert request.headers.get_list("x-trace-id") == ["trace-1"] + assert set(json.loads(request.content)) == {"model", "input"} + + def test_hostinger_router_embeddings_never_borrow_another_providers_key(monkeypatch: pytest.MonkeyPatch): monkeypatch.delenv("HOSTINGER_ROUTER_API_KEY", raising=False) monkeypatch.setenv("OPENAI_LIKE_API_KEY", "other-provider-key") @@ -393,3 +428,95 @@ def test_hostinger_router_responses_bridge_models_without_native_responses(): assert chat.call_count == 1 assert json.loads(chat.calls.last.request.content)["model"] == "claude-sonnet-5" assert response.output[0].content[0].text == "Hello from Hostinger Router" + + +ANTHROPIC_MESSAGE_RESPONSE: Final = { + "id": "msg_hostinger", + "type": "message", + "role": "assistant", + "model": "claude-haiku-4-5", + "content": [{"type": "text", "text": "Hello from Hostinger Router"}], + "stop_reason": "end_turn", + "stop_sequence": None, + "usage": {"input_tokens": 4, "output_tokens": 3}, +} + + +@pytest.mark.asyncio +@pytest.mark.parametrize( + "sibling_model_info", + [ + {"supported_endpoints": ["/v1/chat/completions", "/v1/messages", "/v1/responses"]}, + {"supported_endpoints": "/v1/messages"}, + ], +) +async def test_hostinger_router_endpoint_opt_in_stays_with_its_own_deployment( + sibling_model_info: dict[str, object], monkeypatch: pytest.MonkeyPatch +): + monkeypatch.setattr(litellm, "model_cost", copy.deepcopy(litellm.model_cost)) + monkeypatch.setattr(litellm, "disable_aiohttp_transport", True) + monkeypatch.setattr(litellm, "in_memory_llm_clients_cache", LLMClientCache()) + deployment_params: Final = {"model": "hostinger_router/gpt-5-nano", "api_key": "hostinger-test-key"} + router: Final = litellm.Router( + model_list=[ + {"model_name": "opted-in", "litellm_params": deployment_params, "model_info": sibling_model_info}, + {"model_name": "plain", "litellm_params": deployment_params}, + ] + ) + + with respx.mock(assert_all_called=False) as upstream: + native_messages: Final = upstream.post("https://router.hostinger.com/v1/messages").respond( + 403, json=UNSUPPORTED_ENDPOINT + ) + native_responses: Final = upstream.post("https://router.hostinger.com/v1/responses").respond( + 403, json=UNSUPPORTED_ENDPOINT + ) + chat: Final = upstream.post("https://router.hostinger.com/v1/chat/completions").respond( + 200, json=CHAT_COMPLETION_RESPONSE + ) + messages_response: Final = await router.aanthropic_messages( + model="plain", messages=[{"role": "user", "content": "Say hello"}], max_tokens=32 + ) + responses_response: Final = await router.aresponses(model="plain", input="Say hello") + + assert native_messages.call_count == 0 + assert native_responses.call_count == 0 + assert chat.call_count == 2 + assert messages_response["content"][0]["text"] == "Hello from Hostinger Router" + assert responses_response.output[0].content[0].text == "Hello from Hostinger Router" + + +@pytest.mark.asyncio +async def test_hostinger_router_deployment_cache_ttl_opt_in_keeps_one_hour_ttl(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setattr(litellm, "model_cost", copy.deepcopy(litellm.model_cost)) + monkeypatch.setattr(litellm, "disable_aiohttp_transport", True) + monkeypatch.setattr(litellm, "in_memory_llm_clients_cache", LLMClientCache()) + router: Final = litellm.Router( + model_list=[ + { + "model_name": "opted-in", + "litellm_params": { + "model": "hostinger_router/claude-haiku-4-5", + "api_base": "https://router.hostinger.com/v1", + "api_key": "hostinger-test-key", + }, + "model_info": {"supported_endpoints": ["/v1/messages"], "cache_control_ttl": True}, + } + ] + ) + one_hour_cache: Final = {"type": "ephemeral", "ttl": "1h"} + + with respx.mock() as upstream: + native: Final = upstream.post("https://router.hostinger.com/v1/messages").respond( + 200, json=ANTHROPIC_MESSAGE_RESPONSE + ) + await router.aanthropic_messages( + model="opted-in", + messages=[ + {"role": "user", "content": [{"type": "text", "text": "Say hello", "cache_control": one_hour_cache}]} + ], + max_tokens=32, + ) + + body: Final = json.loads(native.calls.last.request.content) + assert body["messages"][0]["content"][0]["cache_control"] == one_hour_cache From a16dadd3b5ab47775193b650467ce40b7d526d5a Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 29 Oct 2026 21:00:58 -0700 Subject: [PATCH 09/14] fix(openai_like): refuse Host, Content-Length and Transfer-Encoding in embeddings extra_headers unless drop_params --- litellm/llms/openai_like/embedding/handler.py | 14 ++++--- .../test_hostinger_router_provider.py | 38 +++++++++++++++++++ 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/litellm/llms/openai_like/embedding/handler.py b/litellm/llms/openai_like/embedding/handler.py index e6189d5e97e..baafcd5d94f 100644 --- a/litellm/llms/openai_like/embedding/handler.py +++ b/litellm/llms/openai_like/embedding/handler.py @@ -22,20 +22,24 @@ from ..common_utils import OpenAILikeBase, OpenAILikeError _KEY_HEADERS_ADAPTER: Final = TypeAdapter(Mapping[str, str]) _EXTRA_HEADERS_ADAPTER: Final = TypeAdapter(Mapping[str, object]) +_TRANSPORT_HEADER_NAMES: Final = frozenset({"host", "content-length", "transfer-encoding"}) -def _header_text(value: object) -> str | None: +def _header_text(name: str, value: object) -> str | None: + if name.lower() in _TRANSPORT_HEADER_NAMES: + return None if isinstance(value, bool) or not isinstance(value, str | int | float): return None return str(value) def _extra_headers_as_text(extra_headers: Mapping[str, object], model: str, drop_params: bool) -> Mapping[str, str]: - texts: Final = MappingProxyType({name: _header_text(value) for name, value in extra_headers.items()}) - malformed: Final = sorted(name for name, text in texts.items() if text is None) - if malformed and not drop_params: + texts: Final = MappingProxyType({name: _header_text(name, value) for name, value in extra_headers.items()}) + refused: Final = sorted(name for name, text in texts.items() if text is None) + if refused and not drop_params: raise litellm.UnsupportedParamsError( - message=f"extra_headers {', '.join(malformed)} must be text or a number. " + message=f"extra_headers {', '.join(refused)} cannot be sent. Values must be text or a number, " + "and Host, Content-Length and Transfer-Encoding come from the request. " "To drop them from the call, set `litellm.drop_params = True`.", model=model, ) diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py index 8d9b2e05c51..aded92c362d 100644 --- a/tests/unit/llms/openai_like/test_hostinger_router_provider.py +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -300,6 +300,44 @@ def test_hostinger_router_embeddings_drop_non_text_extra_headers_under_drop_para assert set(json.loads(request.content)) == {"model", "input"} +TRANSPORT_EXTRA_HEADERS: Final = [("Host", "other.example"), ("content-length", "1"), ("Transfer-Encoding", "chunked")] + + +@pytest.mark.parametrize(("name", "configured"), TRANSPORT_EXTRA_HEADERS) +def test_hostinger_router_embeddings_refuse_transport_extra_headers(name: str, configured: str): + with respx.mock(assert_all_called=False) as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + with pytest.raises(litellm.UnsupportedParamsError, match=name) as refused: + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + extra_headers={name: configured}, + ) + + assert refused.value.status_code == 400 + assert route.call_count == 0 + + +@pytest.mark.parametrize(("name", "configured"), TRANSPORT_EXTRA_HEADERS) +def test_hostinger_router_embeddings_drop_transport_extra_headers_under_drop_params(name: str, configured: str): + with respx.mock() as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + extra_headers={name: configured, "X-Trace-Id": "trace-1"}, + drop_params=True, + ) + + request: Final = route.calls.last.request + assert request.headers.get_list("host") == ["router.hostinger.com"] + assert request.headers.get_list("content-length") == [str(len(request.content))] + assert "transfer-encoding" not in request.headers + assert request.headers.get_list("x-trace-id") == ["trace-1"] + + def test_hostinger_router_embeddings_never_borrow_another_providers_key(monkeypatch: pytest.MonkeyPatch): monkeypatch.delenv("HOSTINGER_ROUTER_API_KEY", raising=False) monkeypatch.setenv("OPENAI_LIKE_API_KEY", "other-provider-key") From 2efdee446295a57d9228b0c79c29c9a6f73cbaab Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 30 Oct 2026 03:58:09 -0700 Subject: [PATCH 10/14] fix(openai_like): refuse malformed embeddings extra_headers and ignore transport headers Header names must be HTTP tokens and values printable ASCII on one line, so a colon in a name or a line break in a value answers 400 unless drop_params drops it. Host, Content-Length and Transfer-Encoding are ignored, since a 400 for them sends the call to the deployment's fallback with the same headers. --- litellm/llms/openai_like/embedding/handler.py | 19 ++++++--- .../test_hostinger_router_provider.py | 39 ++++++++++++++++--- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/litellm/llms/openai_like/embedding/handler.py b/litellm/llms/openai_like/embedding/handler.py index baafcd5d94f..d46d49f39de 100644 --- a/litellm/llms/openai_like/embedding/handler.py +++ b/litellm/llms/openai_like/embedding/handler.py @@ -3,6 +3,7 @@ ## Allows jina ai embedding calls - which don't allow 'encoding_format' in payload. import json +import re from collections.abc import Mapping from types import MappingProxyType from typing import Final @@ -23,23 +24,29 @@ from ..common_utils import OpenAILikeBase, OpenAILikeError _KEY_HEADERS_ADAPTER: Final = TypeAdapter(Mapping[str, str]) _EXTRA_HEADERS_ADAPTER: Final = TypeAdapter(Mapping[str, object]) _TRANSPORT_HEADER_NAMES: Final = frozenset({"host", "content-length", "transfer-encoding"}) +_HEADER_NAME: Final = re.compile(r"[!#$%&'*+\-.^_`|~0-9A-Za-z]+") +_HEADER_VALUE: Final = re.compile(r"[\t\x20-\x7e]*") def _header_text(name: str, value: object) -> str | None: - if name.lower() in _TRANSPORT_HEADER_NAMES: - return None if isinstance(value, bool) or not isinstance(value, str | int | float): return None - return str(value) + text: Final = str(value) + if _HEADER_NAME.fullmatch(name) is None or _HEADER_VALUE.fullmatch(text) is None: + return None + return text def _extra_headers_as_text(extra_headers: Mapping[str, object], model: str, drop_params: bool) -> Mapping[str, str]: - texts: Final = MappingProxyType({name: _header_text(name, value) for name, value in extra_headers.items()}) + caller_set: Final = { + name: value for name, value in extra_headers.items() if name.lower() not in _TRANSPORT_HEADER_NAMES + } + texts: Final = MappingProxyType({name: _header_text(name, value) for name, value in caller_set.items()}) refused: Final = sorted(name for name, text in texts.items() if text is None) if refused and not drop_params: raise litellm.UnsupportedParamsError( - message=f"extra_headers {', '.join(refused)} cannot be sent. Values must be text or a number, " - "and Host, Content-Length and Transfer-Encoding come from the request. " + message=f"extra_headers {', '.join(map(repr, refused))} cannot be sent. A header needs a name made of " + "letters, digits or !#$%&'*+-.^_`|~ and a text or number value of printable ASCII on one line. " "To drop them from the call, set `litellm.drop_params = True`.", model=model, ) diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py index aded92c362d..75d3bf25cee 100644 --- a/tests/unit/llms/openai_like/test_hostinger_router_provider.py +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -304,10 +304,37 @@ TRANSPORT_EXTRA_HEADERS: Final = [("Host", "other.example"), ("content-length", @pytest.mark.parametrize(("name", "configured"), TRANSPORT_EXTRA_HEADERS) -def test_hostinger_router_embeddings_refuse_transport_extra_headers(name: str, configured: str): +def test_hostinger_router_embeddings_ignore_transport_extra_headers(name: str, configured: str): + with respx.mock() as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + extra_headers={name: configured, "X-Trace-Id": "trace-1"}, + ) + + request: Final = route.calls.last.request + assert request.headers.get_list("host") == ["router.hostinger.com"] + assert request.headers.get_list("content-length") == [str(len(request.content))] + assert "transfer-encoding" not in request.headers + assert request.headers.get_list("x-trace-id") == ["trace-1"] + + +MALFORMED_EXTRA_HEADERS: Final = [ + ("Host:evil.example", "x"), + ("X Note", "x"), + ("X-Note", "a\r\nHost: evil.example"), + ("X-Note", "line\nbreak"), + ("X-Note", "caf\u00e9"), +] + + +@pytest.mark.parametrize(("name", "configured"), MALFORMED_EXTRA_HEADERS) +def test_hostinger_router_embeddings_refuse_malformed_extra_headers(name: str, configured: str): with respx.mock(assert_all_called=False) as upstream: route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) - with pytest.raises(litellm.UnsupportedParamsError, match=name) as refused: + with pytest.raises(litellm.UnsupportedParamsError) as refused: litellm.embedding( model="hostinger_router/text-embedding-3-small", input=["Say hello"], @@ -316,11 +343,12 @@ def test_hostinger_router_embeddings_refuse_transport_extra_headers(name: str, c ) assert refused.value.status_code == 400 + assert repr(name) in refused.value.message assert route.call_count == 0 -@pytest.mark.parametrize(("name", "configured"), TRANSPORT_EXTRA_HEADERS) -def test_hostinger_router_embeddings_drop_transport_extra_headers_under_drop_params(name: str, configured: str): +@pytest.mark.parametrize(("name", "configured"), MALFORMED_EXTRA_HEADERS) +def test_hostinger_router_embeddings_drop_malformed_extra_headers_under_drop_params(name: str, configured: str): with respx.mock() as upstream: route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) litellm.embedding( @@ -333,9 +361,8 @@ def test_hostinger_router_embeddings_drop_transport_extra_headers_under_drop_par request: Final = route.calls.last.request assert request.headers.get_list("host") == ["router.hostinger.com"] - assert request.headers.get_list("content-length") == [str(len(request.content))] - assert "transfer-encoding" not in request.headers assert request.headers.get_list("x-trace-id") == ["trace-1"] + assert name not in request.headers def test_hostinger_router_embeddings_never_borrow_another_providers_key(monkeypatch: pytest.MonkeyPatch): From c66275528da6f8167a9a12eb1d456dacde0ea9c3 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 30 Oct 2026 05:05:11 -0700 Subject: [PATCH 11/14] fix(openai_like): trim embeddings extra_headers values and drop values HTTP cannot carry HTTP ignores spaces and tabs around a header value, so values are trimmed before they are sent. A value that is not printable ASCII on one line after trimming is dropped with a warning instead of failing the call, since the proxy adds headers itself from key aliases and forwarded client headers that the caller cannot fix. A malformed header name or a non-text value still answers 400 unless drop_params drops it. --- litellm/llms/openai_like/embedding/handler.py | 16 ++++-- .../test_hostinger_router_provider.py | 53 ++++++++++++++----- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/litellm/llms/openai_like/embedding/handler.py b/litellm/llms/openai_like/embedding/handler.py index d46d49f39de..8212a7415aa 100644 --- a/litellm/llms/openai_like/embedding/handler.py +++ b/litellm/llms/openai_like/embedding/handler.py @@ -12,6 +12,7 @@ import httpx from pydantic import TypeAdapter import litellm +from litellm._logging import verbose_logger from litellm.llms.custom_httpx.http_handler import ( AsyncHTTPHandler, HTTPHandler, @@ -31,10 +32,9 @@ _HEADER_VALUE: Final = re.compile(r"[\t\x20-\x7e]*") def _header_text(name: str, value: object) -> str | None: if isinstance(value, bool) or not isinstance(value, str | int | float): return None - text: Final = str(value) - if _HEADER_NAME.fullmatch(name) is None or _HEADER_VALUE.fullmatch(text) is None: + if _HEADER_NAME.fullmatch(name) is None: return None - return text + return str(value).strip(" \t") def _extra_headers_as_text(extra_headers: Mapping[str, object], model: str, drop_params: bool) -> Mapping[str, str]: @@ -46,11 +46,17 @@ def _extra_headers_as_text(extra_headers: Mapping[str, object], model: str, drop if refused and not drop_params: raise litellm.UnsupportedParamsError( message=f"extra_headers {', '.join(map(repr, refused))} cannot be sent. A header needs a name made of " - "letters, digits or !#$%&'*+-.^_`|~ and a text or number value of printable ASCII on one line. " + "letters, digits or !#$%&'*+-.^_`|~ and a text or number value. " "To drop them from the call, set `litellm.drop_params = True`.", model=model, ) - return MappingProxyType({name: text for name, text in texts.items() if text is not None}) + named: Final = MappingProxyType({name: text for name, text in texts.items() if text is not None}) + unsendable: Final = sorted(name for name, text in named.items() if _HEADER_VALUE.fullmatch(text) is None) + if unsendable: + verbose_logger.warning( + "extra_headers %s dropped, since a header value must be printable ASCII on one line", unsendable + ) + return MappingProxyType({name: text for name, text in named.items() if name not in unsendable}) class OpenAILikeEmbeddingHandler(OpenAILikeBase): diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py index 75d3bf25cee..13597d6dd92 100644 --- a/tests/unit/llms/openai_like/test_hostinger_router_provider.py +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -321,17 +321,11 @@ def test_hostinger_router_embeddings_ignore_transport_extra_headers(name: str, c assert request.headers.get_list("x-trace-id") == ["trace-1"] -MALFORMED_EXTRA_HEADERS: Final = [ - ("Host:evil.example", "x"), - ("X Note", "x"), - ("X-Note", "a\r\nHost: evil.example"), - ("X-Note", "line\nbreak"), - ("X-Note", "caf\u00e9"), -] +MALFORMED_HEADER_NAMES: Final = ["Host:evil.example", "X Note", "X-Caf\u00e9"] -@pytest.mark.parametrize(("name", "configured"), MALFORMED_EXTRA_HEADERS) -def test_hostinger_router_embeddings_refuse_malformed_extra_headers(name: str, configured: str): +@pytest.mark.parametrize("name", MALFORMED_HEADER_NAMES) +def test_hostinger_router_embeddings_refuse_malformed_extra_header_names(name: str): with respx.mock(assert_all_called=False) as upstream: route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) with pytest.raises(litellm.UnsupportedParamsError) as refused: @@ -339,7 +333,7 @@ def test_hostinger_router_embeddings_refuse_malformed_extra_headers(name: str, c model="hostinger_router/text-embedding-3-small", input=["Say hello"], api_key="hostinger-test-key", - extra_headers={name: configured}, + extra_headers={name: "x"}, ) assert refused.value.status_code == 400 @@ -347,22 +341,53 @@ def test_hostinger_router_embeddings_refuse_malformed_extra_headers(name: str, c assert route.call_count == 0 -@pytest.mark.parametrize(("name", "configured"), MALFORMED_EXTRA_HEADERS) -def test_hostinger_router_embeddings_drop_malformed_extra_headers_under_drop_params(name: str, configured: str): +@pytest.mark.parametrize("name", MALFORMED_HEADER_NAMES) +def test_hostinger_router_embeddings_drop_malformed_extra_header_names_under_drop_params(name: str): with respx.mock() as upstream: route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) litellm.embedding( model="hostinger_router/text-embedding-3-small", input=["Say hello"], api_key="hostinger-test-key", - extra_headers={name: configured, "X-Trace-Id": "trace-1"}, + extra_headers={name: "x", "X-Trace-Id": "trace-1"}, drop_params=True, ) request: Final = route.calls.last.request assert request.headers.get_list("host") == ["router.hostinger.com"] assert request.headers.get_list("x-trace-id") == ["trace-1"] - assert name not in request.headers + assert name.lower() not in request.headers.keys() + + +@pytest.mark.parametrize("configured", ["a\r\nHost: evil.example", "line\nbreak", "caf\u00e9", "a\x7fb"]) +def test_hostinger_router_embeddings_drop_extra_header_values_http_cannot_carry(configured: str): + with respx.mock() as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + extra_headers={"x-litellm-user_api_key_alias": configured, "X-Trace-Id": "trace-1"}, + ) + + request: Final = route.calls.last.request + assert request.headers.get_list("host") == ["router.hostinger.com"] + assert request.headers.get_list("x-trace-id") == ["trace-1"] + assert "x-litellm-user_api_key_alias" not in request.headers + + +@pytest.mark.parametrize(("configured", "sent"), [(" x ", "x"), ("\t", ""), (" a\tb ", "a\tb")]) +def test_hostinger_router_embeddings_trim_spaces_around_extra_header_values(configured: str, sent: str): + with respx.mock() as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + extra_headers={"X-Rig": configured}, + ) + + assert route.calls.last.request.headers.get_list("x-rig") == [sent] def test_hostinger_router_embeddings_never_borrow_another_providers_key(monkeypatch: pytest.MonkeyPatch): From 2cd57c64424e4005cab5b716e6919b014a725ff5 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 30 Oct 2026 06:03:45 -0700 Subject: [PATCH 12/14] fix(openai_like): ignore hop-by-hop extra_headers and trim line breaks around values TE, Upgrade, Connection, Keep-Alive, Proxy-Connection and Trailer in extra_headers are now ignored like Host, Content-Length and Transfer-Encoding, since litellm builds the request and TE: gzip fails HTTP/2 while Upgrade makes some upstreams hang. Line breaks at the ends of a value are trimmed along with spaces and tabs, so a secret read from a file with a trailing newline is sent instead of dropped. The drop warning now names the model. --- litellm/llms/openai_like/embedding/handler.py | 20 ++++++++++++++++--- .../test_hostinger_router_provider.py | 20 ++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/litellm/llms/openai_like/embedding/handler.py b/litellm/llms/openai_like/embedding/handler.py index 8212a7415aa..0a20bce0086 100644 --- a/litellm/llms/openai_like/embedding/handler.py +++ b/litellm/llms/openai_like/embedding/handler.py @@ -24,7 +24,19 @@ from ..common_utils import OpenAILikeBase, OpenAILikeError _KEY_HEADERS_ADAPTER: Final = TypeAdapter(Mapping[str, str]) _EXTRA_HEADERS_ADAPTER: Final = TypeAdapter(Mapping[str, object]) -_TRANSPORT_HEADER_NAMES: Final = frozenset({"host", "content-length", "transfer-encoding"}) +_TRANSPORT_HEADER_NAMES: Final = frozenset( + { + "host", + "content-length", + "transfer-encoding", + "connection", + "keep-alive", + "proxy-connection", + "te", + "trailer", + "upgrade", + } +) _HEADER_NAME: Final = re.compile(r"[!#$%&'*+\-.^_`|~0-9A-Za-z]+") _HEADER_VALUE: Final = re.compile(r"[\t\x20-\x7e]*") @@ -34,7 +46,7 @@ def _header_text(name: str, value: object) -> str | None: return None if _HEADER_NAME.fullmatch(name) is None: return None - return str(value).strip(" \t") + return str(value).strip(" \t\r\n") def _extra_headers_as_text(extra_headers: Mapping[str, object], model: str, drop_params: bool) -> Mapping[str, str]: @@ -54,7 +66,9 @@ def _extra_headers_as_text(extra_headers: Mapping[str, object], model: str, drop unsendable: Final = sorted(name for name, text in named.items() if _HEADER_VALUE.fullmatch(text) is None) if unsendable: verbose_logger.warning( - "extra_headers %s dropped, since a header value must be printable ASCII on one line", unsendable + "extra_headers %s dropped for model %s, since a header value must be printable ASCII on one line", + unsendable, + model, ) return MappingProxyType({name: text for name, text in named.items() if name not in unsendable}) diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py index 13597d6dd92..75da1fafe22 100644 --- a/tests/unit/llms/openai_like/test_hostinger_router_provider.py +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -300,7 +300,17 @@ def test_hostinger_router_embeddings_drop_non_text_extra_headers_under_drop_para assert set(json.loads(request.content)) == {"model", "input"} -TRANSPORT_EXTRA_HEADERS: Final = [("Host", "other.example"), ("content-length", "1"), ("Transfer-Encoding", "chunked")] +TRANSPORT_EXTRA_HEADERS: Final = [ + ("Host", "other.example"), + ("content-length", "1"), + ("Transfer-Encoding", "chunked"), + ("Connection", "close"), + ("Keep-Alive", "timeout=5"), + ("Proxy-Connection", "close"), + ("TE", "gzip"), + ("Trailer", "X-Checksum"), + ("Upgrade", "websocket"), +] @pytest.mark.parametrize(("name", "configured"), TRANSPORT_EXTRA_HEADERS) @@ -318,6 +328,7 @@ def test_hostinger_router_embeddings_ignore_transport_extra_headers(name: str, c assert request.headers.get_list("host") == ["router.hostinger.com"] assert request.headers.get_list("content-length") == [str(len(request.content))] assert "transfer-encoding" not in request.headers + assert configured not in request.headers.get_list(name) assert request.headers.get_list("x-trace-id") == ["trace-1"] @@ -376,8 +387,11 @@ def test_hostinger_router_embeddings_drop_extra_header_values_http_cannot_carry( assert "x-litellm-user_api_key_alias" not in request.headers -@pytest.mark.parametrize(("configured", "sent"), [(" x ", "x"), ("\t", ""), (" a\tb ", "a\tb")]) -def test_hostinger_router_embeddings_trim_spaces_around_extra_header_values(configured: str, sent: str): +@pytest.mark.parametrize( + ("configured", "sent"), + [(" x ", "x"), ("\t", ""), (" a\tb ", "a\tb"), ("env-secret\n", "env-secret"), ("\r\n x \r\n", "x")], +) +def test_hostinger_router_embeddings_trim_whitespace_around_extra_header_values(configured: str, sent: str): with respx.mock() as upstream: route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) litellm.embedding( From 6bb9d8f1b15899dc02d6deb1de9ac840381936a2 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 30 Oct 2026 08:15:22 -0700 Subject: [PATCH 13/14] fix(embeddings): keep one request's extra_headers out of the deployment's headers and ignore Expect embedding() merged a request's extra_headers into the headers dict it got from the deployment's litellm_params. The router only shallow-copies those params, so the merge wrote the caller's headers into the deployment itself, and later embeddings calls through that deployment sent them too. Build a new dict instead, and drop the None checks that can no longer be true. Also treat Expect as a transport header that hostinger_router embeddings never forwards, and name the model with %r in the dropped-value warning. --- litellm/llms/openai_like/embedding/handler.py | 3 +- litellm/main.py | 17 ++--------- .../test_hostinger_router_provider.py | 30 +++++++++++++++++++ 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/litellm/llms/openai_like/embedding/handler.py b/litellm/llms/openai_like/embedding/handler.py index 0a20bce0086..540feeca6e7 100644 --- a/litellm/llms/openai_like/embedding/handler.py +++ b/litellm/llms/openai_like/embedding/handler.py @@ -35,6 +35,7 @@ _TRANSPORT_HEADER_NAMES: Final = frozenset( "te", "trailer", "upgrade", + "expect", } ) _HEADER_NAME: Final = re.compile(r"[!#$%&'*+\-.^_`|~0-9A-Za-z]+") @@ -66,7 +67,7 @@ def _extra_headers_as_text(extra_headers: Mapping[str, object], model: str, drop unsendable: Final = sorted(name for name, text in named.items() if _HEADER_VALUE.fullmatch(text) is None) if unsendable: verbose_logger.warning( - "extra_headers %s dropped for model %s, since a header value must be printable ASCII on one line", + "extra_headers %s dropped for model %r, since a header value must be printable ASCII on one line", unsendable, model, ) diff --git a/litellm/main.py b/litellm/main.py index fa84de8b7d1..d5734bd3073 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -6890,11 +6890,7 @@ def embedding( azure_ad_token_provider: Final = kwargs.get("azure_ad_token_provider", None) aembedding: Final[bool | None] = kwargs.get("aembedding", None) extra_headers: Final = kwargs.get("extra_headers", None) - headers = kwargs.get("headers", None) or extra_headers - if headers is None: - headers = {} - if extra_headers is not None: - headers.update(extra_headers) + headers = {**(kwargs.get("headers") or {}), **(extra_headers or {})} # Inject proxy auth headers if configured if litellm.proxy_auth is not None: try: @@ -7058,7 +7054,7 @@ def embedding( # set API KEY api_key = api_key or litellm.api_key or litellm.openai_key or get_secret_str("OPENAI_API_KEY") - if headers is not None and headers != {}: + if headers: optional_params["extra_headers"] = headers requested_encoding_format: Final = ( @@ -7158,7 +7154,7 @@ def embedding( if api_key is None and not JSONProviderRegistry.supports_embeddings(custom_llm_provider): api_key = litellm.api_key or litellm.openai_like_key or get_secret_str("OPENAI_LIKE_API_KEY") - if headers is not None and headers != {}: + if headers: optional_params["extra_headers"] = headers ## EMBEDDING CALL @@ -7176,8 +7172,6 @@ def embedding( drop_params=drop_unsupported_params, ) elif custom_llm_provider == "oci": - if headers is None: - headers = {} response = base_llm_http_handler.embedding( model=model, input=input, @@ -7202,11 +7196,6 @@ def embedding( or litellm.api_key ) - # Use the merged headers variable (already merged at the top of the function) - # Don't overwrite it with just extra_headers - if headers is None: - headers = {} - response = base_llm_http_handler.embedding( model=model, input=input, diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py index 75da1fafe22..04878a28ad9 100644 --- a/tests/unit/llms/openai_like/test_hostinger_router_provider.py +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -310,6 +310,7 @@ TRANSPORT_EXTRA_HEADERS: Final = [ ("TE", "gzip"), ("Trailer", "X-Checksum"), ("Upgrade", "websocket"), + ("Expect", "100-continue"), ] @@ -404,6 +405,35 @@ def test_hostinger_router_embeddings_trim_whitespace_around_extra_header_values( assert route.calls.last.request.headers.get_list("x-rig") == [sent] +def test_hostinger_router_embeddings_extra_headers_stay_with_their_request(): + router: Final = litellm.Router( + model_list=[ + { + "model_name": "shared", + "litellm_params": { + "model": "hostinger_router/text-embedding-3-small", + "api_key": "hostinger-test-key", + "headers": {"X-Org-Id": "org-1"}, + }, + } + ] + ) + + with respx.mock() as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + router.embedding( + model="shared", input=["first"], extra_headers={"Authorization": "Bearer caller-a", "X-Leak": "a"} + ) + router.embedding(model="shared", input=["second"]) + + first: Final = route.calls[0].request + second: Final = route.calls[1].request + assert first.headers.get_list("x-leak") == ["a"] + assert second.headers.get_list("authorization") == ["Bearer hostinger-test-key"] + assert "x-leak" not in second.headers + assert second.headers.get_list("x-org-id") == ["org-1"] + + def test_hostinger_router_embeddings_never_borrow_another_providers_key(monkeypatch: pytest.MonkeyPatch): monkeypatch.delenv("HOSTINGER_ROUTER_API_KEY", raising=False) monkeypatch.setenv("OPENAI_LIKE_API_KEY", "other-provider-key") From 0d37407c63d48c53f8306f35d822618413b27912 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 30 Oct 2026 11:02:27 -0700 Subject: [PATCH 14/14] fix(embeddings): keep name and value pairs working in headers and answer 400 for other non-object values The previous commit merged headers and extra_headers with dict unpacking, which only takes a mapping, so a list of name and value pairs that dict.update used to accept now raised a TypeError and the proxy answered 500. Merge through dict() so pairs keep working, and answer 400 for any other value, or drop it under drop_params, as the litellm convention does for an unsupported param. --- litellm/main.py | 22 +++++++- .../test_hostinger_router_provider.py | 50 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/litellm/main.py b/litellm/main.py index d5734bd3073..ffd6cf66b54 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -6776,6 +6776,23 @@ async def aembedding(*args, **kwargs) -> EmbeddingResponse: ) +def _embedding_headers(param: str, configured: object, model: str, drop_params: bool) -> Mapping[str, object]: + if not configured: + return {} + if isinstance(configured, Mapping): + return dict(cast(Mapping[str, object], configured)) # cast-ok: header names from untyped request JSON + try: + return dict(cast(Iterable[tuple[str, object]], configured)) # cast-ok: name and value pairs from request JSON + except (TypeError, ValueError): + if drop_params: + return {} + raise litellm.UnsupportedParamsError( + message=f"{param} must be a JSON object of header names to values. " + "To drop it from the call, set `litellm.drop_params = True`.", + model=model, + ) + + # fmt: off # Overload for when aembedding=True (returns coroutine) @@ -6890,7 +6907,10 @@ def embedding( azure_ad_token_provider: Final = kwargs.get("azure_ad_token_provider", None) aembedding: Final[bool | None] = kwargs.get("aembedding", None) extra_headers: Final = kwargs.get("extra_headers", None) - headers = {**(kwargs.get("headers") or {}), **(extra_headers or {})} + headers = { + **_embedding_headers("headers", kwargs.get("headers"), model, drop_unsupported_params), + **_embedding_headers("extra_headers", extra_headers, model, drop_unsupported_params), + } # Inject proxy auth headers if configured if litellm.proxy_auth is not None: try: diff --git a/tests/unit/llms/openai_like/test_hostinger_router_provider.py b/tests/unit/llms/openai_like/test_hostinger_router_provider.py index 04878a28ad9..cbc16c8567a 100644 --- a/tests/unit/llms/openai_like/test_hostinger_router_provider.py +++ b/tests/unit/llms/openai_like/test_hostinger_router_provider.py @@ -434,6 +434,56 @@ def test_hostinger_router_embeddings_extra_headers_stay_with_their_request(): assert second.headers.get_list("x-org-id") == ["org-1"] +@pytest.mark.parametrize("param", ["headers", "extra_headers"]) +def test_hostinger_router_embeddings_send_headers_given_as_name_value_pairs(param: str): + with respx.mock() as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + **{param: [["X-Trace-Id", "trace-1"]]}, + ) + + request: Final = route.calls.last.request + assert request.headers.get_list("x-trace-id") == ["trace-1"] + assert request.headers.get_list("authorization") == ["Bearer hostinger-test-key"] + + +@pytest.mark.parametrize("param", ["headers", "extra_headers"]) +def test_hostinger_router_embeddings_refuse_headers_that_are_not_an_object(param: str): + with respx.mock(assert_all_called=False) as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + with pytest.raises(litellm.UnsupportedParamsError, match=rf"\b{param} must be a JSON object") as refused: + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + **{param: "X-Trace-Id: trace-1"}, + ) + + assert refused.value.status_code == 400 + assert route.call_count == 0 + + +@pytest.mark.parametrize("param", ["headers", "extra_headers"]) +def test_hostinger_router_embeddings_drop_headers_that_are_not_an_object_under_drop_params(param: str): + with respx.mock() as upstream: + route: Final = upstream.post("https://router.hostinger.com/v1/embeddings").respond(200, json=EMBEDDING_RESPONSE) + litellm.embedding( + model="hostinger_router/text-embedding-3-small", + input=["Say hello"], + api_key="hostinger-test-key", + drop_params=True, + **{param: "X-Trace-Id: trace-1"}, + ) + + request: Final = route.calls.last.request + assert "x-trace-id" not in request.headers + assert request.headers.get_list("authorization") == ["Bearer hostinger-test-key"] + assert set(json.loads(request.content)) == {"model", "input"} + + def test_hostinger_router_embeddings_never_borrow_another_providers_key(monkeypatch: pytest.MonkeyPatch): monkeypatch.delenv("HOSTINGER_ROUTER_API_KEY", raising=False) monkeypatch.setenv("OPENAI_LIKE_API_KEY", "other-provider-key")