From ab7979ed2a23813f334b8ba29fcd9aacc8e86311 Mon Sep 17 00:00:00 2001 From: Jashwanth Pedapudi <76832118+jashwanth-12@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:56:13 -0700 Subject: [PATCH] feat(providers): add Hopper models and pricing --- litellm/llms/openai_like/providers.json | 12 ++ ...odel_prices_and_context_window_backup.json | 69 +++++++++++ .../provider_endpoints_support_backup.json | 26 ++++ .../provider_create_fields.json | 28 +++++ litellm/types/utils.py | 1 + model_prices_and_context_window.json | 69 +++++++++++ provider_endpoints_support.json | 26 ++++ .../llms/openai_like/test_hopper_provider.py | 111 ++++++++++++++++++ 8 files changed, 342 insertions(+) create mode 100644 tests/unit/llms/openai_like/test_hopper_provider.py diff --git a/litellm/llms/openai_like/providers.json b/litellm/llms/openai_like/providers.json index ad47b334ed4..6d26e08b4d3 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -262,6 +262,18 @@ "/v1/messages" ] }, + "hopper": { + "base_url": "https://api.withhopper.com/v1", + "api_key_env": "HOPPER_API_KEY", + "api_base_env": "HOPPER_API_BASE", + "provider_info": { + "supports_function_calling": true + }, + "supported_endpoints": [ + "/v1/chat/completions", + "/v1/messages" + ] + }, "refuseless": { "base_url": "https://api.refuseless.com/v1", "api_key_env": "REFUSELESS_API_KEY", diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index c6bbb63b6fc..0f92bb94fdc 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -39408,6 +39408,75 @@ "/v1/images/generations" ] }, + "hopper/gemma-4-31b": { + "cache_read_input_token_cost": 1.2e-07, + "input_cost_per_token": 3e-07, + "litellm_provider": "hopper", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 4.0000000000000003e-07, + "source": "https://withhopper.com/mcp", + "supported_endpoints": [ + "/v1/chat/completions", + "/v1/messages" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": false, + "supports_tool_choice": true, + "supports_vision": false + }, + "hopper/deepseek-v4.1-flash-1017": { + "cache_read_input_token_cost": 7e-09, + "input_cost_per_token": 9e-08, + "litellm_provider": "hopper", + "max_input_tokens": 1048576, + "max_output_tokens": 384000, + "mode": "chat", + "output_cost_per_token": 8.5e-07, + "reasoning_effort_levels": [ + "low", + "high", + "max" + ], + "source": "https://withhopper.com/mcp", + "supported_endpoints": [ + "/v1/chat/completions", + "/v1/messages" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "hopper/deepseek-v4.1-flash-1017-abliterated": { + "cache_read_input_token_cost": 3e-08, + "input_cost_per_token": 3e-07, + "litellm_provider": "hopper", + "max_input_tokens": 393216, + "max_output_tokens": 384000, + "mode": "chat", + "output_cost_per_token": 1.2e-06, + "reasoning_effort_levels": [ + "low", + "high", + "max" + ], + "source": "https://withhopper.com/mcp", + "supported_endpoints": [ + "/v1/chat/completions", + "/v1/messages" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, "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 1d487f33835..8521206ebb6 100644 --- a/litellm/provider_endpoints_support_backup.json +++ b/litellm/provider_endpoints_support_backup.json @@ -2085,6 +2085,32 @@ "generateContent": false } }, + "hopper": { + "display_name": "Hopper (`hopper`)", + "url": "https://docs.litellm.ai/docs/providers/hopper", + "endpoints": { + "chat_completions": true, + "responses": true, + "text_completion": true, + "embeddings": false, + "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 + } + }, "hyperbolic": { "display_name": "Hyperbolic (`hyperbolic`)", "url": "https://docs.litellm.ai/docs/providers/hyperbolic", diff --git a/litellm/proxy/public_endpoints/provider_create_fields.json b/litellm/proxy/public_endpoints/provider_create_fields.json index 04e6c5d8ba9..a0f8d62e4b7 100644 --- a/litellm/proxy/public_endpoints/provider_create_fields.json +++ b/litellm/proxy/public_endpoints/provider_create_fields.json @@ -1903,6 +1903,34 @@ ], "default_model_placeholder": "gpt-3.5-turbo" }, + { + "provider": "HOPPER", + "provider_display_name": "Hopper", + "litellm_provider": "hopper", + "credential_fields": [ + { + "key": "api_key", + "label": "API Key", + "placeholder": null, + "tooltip": null, + "required": true, + "field_type": "password", + "options": null, + "default_value": null + }, + { + "key": "api_base", + "label": "API Base", + "placeholder": "https://api.withhopper.com/v1", + "tooltip": "Optional. Leave blank to use the provider's default endpoint.", + "required": false, + "field_type": "text", + "options": null, + "default_value": null + } + ], + "default_model_placeholder": "hopper/deepseek-v4.1-flash-1017" + }, { "provider": "HUGGINGFACE", "provider_display_name": "Huggingface", diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 1e59ec0c2cb..d0842f38f45 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -4436,6 +4436,7 @@ GenericBudgetConfigType = dict[str, BudgetConfig] class LlmProviders(str, Enum): + HOPPER = "hopper" REFUSELESS = "refuseless" OPENAI = "openai" CHATGPT = "chatgpt" diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index c6bbb63b6fc..0f92bb94fdc 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -39408,6 +39408,75 @@ "/v1/images/generations" ] }, + "hopper/gemma-4-31b": { + "cache_read_input_token_cost": 1.2e-07, + "input_cost_per_token": 3e-07, + "litellm_provider": "hopper", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 4.0000000000000003e-07, + "source": "https://withhopper.com/mcp", + "supported_endpoints": [ + "/v1/chat/completions", + "/v1/messages" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": false, + "supports_tool_choice": true, + "supports_vision": false + }, + "hopper/deepseek-v4.1-flash-1017": { + "cache_read_input_token_cost": 7e-09, + "input_cost_per_token": 9e-08, + "litellm_provider": "hopper", + "max_input_tokens": 1048576, + "max_output_tokens": 384000, + "mode": "chat", + "output_cost_per_token": 8.5e-07, + "reasoning_effort_levels": [ + "low", + "high", + "max" + ], + "source": "https://withhopper.com/mcp", + "supported_endpoints": [ + "/v1/chat/completions", + "/v1/messages" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "hopper/deepseek-v4.1-flash-1017-abliterated": { + "cache_read_input_token_cost": 3e-08, + "input_cost_per_token": 3e-07, + "litellm_provider": "hopper", + "max_input_tokens": 393216, + "max_output_tokens": 384000, + "mode": "chat", + "output_cost_per_token": 1.2e-06, + "reasoning_effort_levels": [ + "low", + "high", + "max" + ], + "source": "https://withhopper.com/mcp", + "supported_endpoints": [ + "/v1/chat/completions", + "/v1/messages" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, "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 1d487f33835..8521206ebb6 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -2085,6 +2085,32 @@ "generateContent": false } }, + "hopper": { + "display_name": "Hopper (`hopper`)", + "url": "https://docs.litellm.ai/docs/providers/hopper", + "endpoints": { + "chat_completions": true, + "responses": true, + "text_completion": true, + "embeddings": false, + "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 + } + }, "hyperbolic": { "display_name": "Hyperbolic (`hyperbolic`)", "url": "https://docs.litellm.ai/docs/providers/hyperbolic", diff --git a/tests/unit/llms/openai_like/test_hopper_provider.py b/tests/unit/llms/openai_like/test_hopper_provider.py new file mode 100644 index 00000000000..216c5a495a2 --- /dev/null +++ b/tests/unit/llms/openai_like/test_hopper_provider.py @@ -0,0 +1,111 @@ +from typing import Final + +import httpx +import pytest +import respx +from pydantic import JsonValue, TypeAdapter + +import litellm +from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider +from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler +from litellm.types.utils import Choices, ModelResponse + +MODELS: Final = ("deepseek-v4.1-flash-1017", "gemma-4-31b", "deepseek-v4.1-flash-1017-abliterated") +JSON_OBJECT: Final = TypeAdapter(dict[str, JsonValue]) + + +def test_hopper_uses_provider_credentials_and_allows_explicit_overrides(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setenv("HOPPER_API_KEY", "hopper-environment-key") + monkeypatch.setenv("HOPPER_API_BASE", "https://hopper.test/v1") + monkeypatch.setenv("OPENAI_API_KEY", "unrelated-key") + assert get_llm_provider(model="hopper/deepseek-v4.1-flash-1017") == ( + "deepseek-v4.1-flash-1017", + "hopper", + "hopper-environment-key", + "https://hopper.test/v1", + ) + assert get_llm_provider( + model="hopper/deepseek-v4.1-flash-1017", api_key="explicit-key", api_base="https://override.test/v1" + ) == ("deepseek-v4.1-flash-1017", "hopper", "explicit-key", "https://override.test/v1") + + +@pytest.mark.parametrize("model", MODELS) +def test_hopper_chat_routes_model_and_discounts_cached_input(model: str, local_model_cost_map: None) -> None: + with respx.mock() as upstream: + route: Final = upstream.post("https://api.withhopper.com/v1/chat/completions").respond( + 200, + json={ + "id": "chatcmpl-test", + "object": "chat.completion", + "created": 1, + "model": model, + "choices": [ + {"index": 0, "message": {"role": "assistant", "content": "READY"}, "finish_reason": "stop"} + ], + "usage": { + "prompt_tokens": 100, + "completion_tokens": 5, + "total_tokens": 105, + "prompt_tokens_details": {"cached_tokens": 80}, + }, + }, + ) + response: Final = litellm.completion( + model=f"hopper/{model}", + api_key="hopper-test-key", + messages=[{"role": "user", "content": "Reply READY"}], + reasoning_effort="low", + max_tokens=64, + ) + assert route.calls.last.request.headers["authorization"] == "Bearer hopper-test-key" + body: Final = JSON_OBJECT.validate_json(route.calls.last.request.content) + assert body["model"] == model + assert body["reasoning_effort"] == "low" + assert body["messages"] == [{"role": "user", "content": "Reply READY"}] + assert isinstance(response, ModelResponse) + assert isinstance(response.choices[0], Choices) + assert response.choices[0].message.content == "READY" + rates: Final = litellm.model_cost[f"hopper/{model}"] + expected: Final = ( + 20 * rates["input_cost_per_token"] + + 80 * rates["cache_read_input_token_cost"] + + 5 * rates["output_cost_per_token"] + ) + assert litellm.completion_cost(completion_response=response) == pytest.approx(expected) + + +@pytest.mark.asyncio +@pytest.mark.parametrize("model", MODELS) +async def test_hopper_messages_preserves_thinking_and_cache_usage(model: str, local_model_cost_map: None) -> None: + client: Final = AsyncHTTPHandler(transport=httpx.AsyncHTTPTransport()) + try: + with respx.mock() as upstream: + route: Final = upstream.post("https://api.withhopper.com/v1/messages").respond( + 200, + json={ + "id": "msg-test", + "type": "message", + "role": "assistant", + "model": model, + "content": [{"type": "text", "text": "READY"}], + "stop_reason": "end_turn", + "stop_sequence": None, + "usage": {"input_tokens": 20, "cache_read_input_tokens": 80, "output_tokens": 5}, + }, + ) + response: Final = await litellm.anthropic.messages.acreate( + model=f"hopper/{model}", + api_key="hopper-test-key", + max_tokens=64, + messages=[{"role": "user", "content": "Reply READY"}], + thinking={"type": "disabled"}, + client=client, + ) + body: Final = JSON_OBJECT.validate_json(route.calls.last.request.content) + assert route.calls.last.request.headers["authorization"] == "Bearer hopper-test-key" + assert body["model"] == model + assert body["thinking"] == {"type": "disabled"} + assert response["content"] == [{"type": "text", "text": "READY"}] + assert response["usage"] == {"input_tokens": 20, "cache_read_input_tokens": 80, "output_tokens": 5} + finally: + await client.close()