mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
feat(providers): add Hopper models and pricing
This commit is contained in:
parent
d8f162ea22
commit
ab7979ed2a
8 changed files with 342 additions and 0 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -4436,6 +4436,7 @@ GenericBudgetConfigType = dict[str, BudgetConfig]
|
|||
|
||||
|
||||
class LlmProviders(str, Enum):
|
||||
HOPPER = "hopper"
|
||||
REFUSELESS = "refuseless"
|
||||
OPENAI = "openai"
|
||||
CHATGPT = "chatgpt"
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
111
tests/unit/llms/openai_like/test_hopper_provider.py
Normal file
111
tests/unit/llms/openai_like/test_hopper_provider.py
Normal file
|
|
@ -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()
|
||||
Loading…
Add table
Reference in a new issue