mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-02 07:13:02 +00:00
Merge e5dc70bb06 into dddbaa803d
This commit is contained in:
commit
20cd9a835e
10 changed files with 493 additions and 0 deletions
|
|
@ -411,6 +411,7 @@ Set `LITELLM_PROXY_API_BASE` and `LITELLM_PROXY_API_KEY` and every model call th
|
|||
| [Sambanova (`sambanova`)](https://docs.litellm.ai/docs/providers/sambanova) | ✅ | ✅ | ✅ | | | | | | | |
|
||||
| [ScaleDown (`scaledown`)](https://docs.litellm.ai/docs/providers/scaledown) | ✅ | | | | | | | | | |
|
||||
| [Snowflake (`snowflake`)](https://docs.litellm.ai/docs/providers/snowflake) | ✅ | ✅ | ✅ | | | | | | | |
|
||||
| [STACKIT (`stackit`)](https://docs.litellm.ai/docs/providers/stackit) | ✅ | ✅ | ✅ | | | | | | | |
|
||||
| [Strands Decider (`strands_decider`)](https://docs.litellm.ai/docs/providers) | | | | | | | | | | |
|
||||
| [Text Completion Codestral (`text-completion-codestral`)](https://docs.litellm.ai/docs/providers/codestral) | ✅ | ✅ | ✅ | | | | | | | |
|
||||
| [Text Completion OpenAI (`text-completion-openai`)](https://docs.litellm.ai/docs/providers/text_completion_openai) | ✅ | ✅ | ✅ | | | ✅ | ✅ | ✅ | ✅ | |
|
||||
|
|
|
|||
|
|
@ -1060,6 +1060,7 @@ openai_compatible_endpoints: Final[list[str]] = [
|
|||
"https://api.scx.ai/v1",
|
||||
"https://api.prisminference.com/v1",
|
||||
"https://api.reka.ai/v1",
|
||||
"https://api.openai-compat.model-serving.eu01.onstackit.cloud/v1",
|
||||
"https://gigachat.devices.sberbank.ru/api/v1",
|
||||
"https://api.openinfer.ai/v1",
|
||||
]
|
||||
|
|
@ -1141,6 +1142,7 @@ openai_compatible_providers: Final[list[str]] = [
|
|||
"prism",
|
||||
"sail",
|
||||
"reka",
|
||||
"stackit",
|
||||
]
|
||||
|
||||
OPENAI_AUDIO_TRANSCRIPTION_PROVIDERS: Final = frozenset({"openai"} | frozenset(openai_compatible_providers))
|
||||
|
|
|
|||
|
|
@ -249,5 +249,11 @@
|
|||
"/v1/responses",
|
||||
"/v1/messages"
|
||||
]
|
||||
},
|
||||
"stackit": {
|
||||
"base_url": "https://api.openai-compat.model-serving.eu01.onstackit.cloud/v1",
|
||||
"api_key_env": "STACKIT_API_KEY",
|
||||
"api_base_env": "STACKIT_API_BASE",
|
||||
"supported_endpoints": ["/v1/chat/completions"]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67899,6 +67899,94 @@
|
|||
"supports_reasoning": true,
|
||||
"supports_vision": false
|
||||
},
|
||||
"stackit/Qwen/Qwen3-VL-235B-A22B-Instruct-FP8": {
|
||||
"input_cost_per_token": 1.5e-06,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 200000,
|
||||
"max_output_tokens": 16384,
|
||||
"max_tokens": 16384,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 1.75e-06,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true,
|
||||
"supports_vision": true
|
||||
},
|
||||
"stackit/Qwen/Qwen3.8-27B": {
|
||||
"input_cost_per_token": 4.5e-07,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 262144,
|
||||
"max_output_tokens": 16384,
|
||||
"max_tokens": 16384,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 6.5e-07,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_vision": true
|
||||
},
|
||||
"stackit/Qwen/Qwen3.6-27B": {
|
||||
"deprecation_date": "2026-12-08",
|
||||
"input_cost_per_token": 4.5e-07,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 262144,
|
||||
"max_output_tokens": 16384,
|
||||
"max_tokens": 16384,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 6.5e-07,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_vision": true
|
||||
},
|
||||
"stackit/cortecs/Llama-3.3-70B-Instruct-FP8-Dynamic": {
|
||||
"input_cost_per_token": 4.5e-07,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 131072,
|
||||
"max_output_tokens": 4096,
|
||||
"max_tokens": 4096,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 6.5e-07,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true
|
||||
},
|
||||
"stackit/openai/gpt-oss-120b": {
|
||||
"input_cost_per_token": 4.5e-07,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 131072,
|
||||
"max_output_tokens": 8192,
|
||||
"max_tokens": 8192,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 6.5e-07,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true
|
||||
},
|
||||
"stackit/google/gemma-4-31B-it": {
|
||||
"input_cost_per_token": 4.5e-07,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 262144,
|
||||
"max_output_tokens": 4096,
|
||||
"max_tokens": 4096,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 6.5e-07,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_vision": true
|
||||
},
|
||||
"stackit/openai/gpt-oss-20b": {
|
||||
"input_cost_per_token": 1.5e-07,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 131072,
|
||||
"max_output_tokens": 8192,
|
||||
"max_tokens": 8192,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 2.5e-07,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true
|
||||
},
|
||||
"azure_ai/kimi-k2.7-code": {
|
||||
"cache_read_input_token_cost": 1.9e-07,
|
||||
"deprecation_date": "2027-04-16",
|
||||
|
|
|
|||
|
|
@ -2225,6 +2225,24 @@
|
|||
"interactions": true
|
||||
}
|
||||
},
|
||||
"stackit": {
|
||||
"display_name": "STACKIT (`stackit`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/stackit",
|
||||
"endpoints": {
|
||||
"chat_completions": true,
|
||||
"messages": true,
|
||||
"responses": true,
|
||||
"embeddings": false,
|
||||
"image_generations": false,
|
||||
"audio_transcriptions": false,
|
||||
"audio_speech": false,
|
||||
"moderations": false,
|
||||
"batches": false,
|
||||
"rerank": false,
|
||||
"a2a": false,
|
||||
"interactions": false
|
||||
}
|
||||
},
|
||||
"synthetic": {
|
||||
"display_name": "Synthetic (`synthetic`)",
|
||||
"endpoints": {
|
||||
|
|
|
|||
|
|
@ -3481,6 +3481,34 @@
|
|||
],
|
||||
"default_model_placeholder": "soniox/stt-async-v5"
|
||||
},
|
||||
{
|
||||
"provider": "STACKIT",
|
||||
"provider_display_name": "STACKIT",
|
||||
"litellm_provider": "stackit",
|
||||
"credential_fields": [
|
||||
{
|
||||
"key": "api_base",
|
||||
"label": "API Base",
|
||||
"placeholder": "https://api.openai-compat.model-serving.eu01.onstackit.cloud/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": "stackit/openai/gpt-oss-120b"
|
||||
},
|
||||
{
|
||||
"provider": "StrandsDecider",
|
||||
"provider_display_name": "Strands Decider",
|
||||
|
|
|
|||
|
|
@ -4586,6 +4586,7 @@ class LlmProviders(str, Enum):
|
|||
META = "meta"
|
||||
SAIL = "sail"
|
||||
REKA = "reka"
|
||||
STACKIT = "stackit"
|
||||
LITELLM_AGENT = "litellm_agent"
|
||||
CURSOR = "cursor"
|
||||
BEDROCK_MANTLE = "bedrock_mantle"
|
||||
|
|
|
|||
|
|
@ -67899,6 +67899,94 @@
|
|||
"supports_reasoning": true,
|
||||
"supports_vision": false
|
||||
},
|
||||
"stackit/Qwen/Qwen3-VL-235B-A22B-Instruct-FP8": {
|
||||
"input_cost_per_token": 1.5e-06,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 200000,
|
||||
"max_output_tokens": 16384,
|
||||
"max_tokens": 16384,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 1.75e-06,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true,
|
||||
"supports_vision": true
|
||||
},
|
||||
"stackit/Qwen/Qwen3.8-27B": {
|
||||
"input_cost_per_token": 4.5e-07,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 262144,
|
||||
"max_output_tokens": 16384,
|
||||
"max_tokens": 16384,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 6.5e-07,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_vision": true
|
||||
},
|
||||
"stackit/Qwen/Qwen3.6-27B": {
|
||||
"deprecation_date": "2026-12-08",
|
||||
"input_cost_per_token": 4.5e-07,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 262144,
|
||||
"max_output_tokens": 16384,
|
||||
"max_tokens": 16384,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 6.5e-07,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_vision": true
|
||||
},
|
||||
"stackit/cortecs/Llama-3.3-70B-Instruct-FP8-Dynamic": {
|
||||
"input_cost_per_token": 4.5e-07,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 131072,
|
||||
"max_output_tokens": 4096,
|
||||
"max_tokens": 4096,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 6.5e-07,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true
|
||||
},
|
||||
"stackit/openai/gpt-oss-120b": {
|
||||
"input_cost_per_token": 4.5e-07,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 131072,
|
||||
"max_output_tokens": 8192,
|
||||
"max_tokens": 8192,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 6.5e-07,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true
|
||||
},
|
||||
"stackit/google/gemma-4-31B-it": {
|
||||
"input_cost_per_token": 4.5e-07,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 262144,
|
||||
"max_output_tokens": 4096,
|
||||
"max_tokens": 4096,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 6.5e-07,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_vision": true
|
||||
},
|
||||
"stackit/openai/gpt-oss-20b": {
|
||||
"input_cost_per_token": 1.5e-07,
|
||||
"litellm_provider": "stackit",
|
||||
"max_input_tokens": 131072,
|
||||
"max_output_tokens": 8192,
|
||||
"max_tokens": 8192,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 2.5e-07,
|
||||
"source": "https://docs.stackit.cloud/products/data-and-ai/ai-model-serving/basics/available-shared-models/",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true
|
||||
},
|
||||
"azure_ai/kimi-k2.7-code": {
|
||||
"cache_read_input_token_cost": 1.9e-07,
|
||||
"deprecation_date": "2027-04-16",
|
||||
|
|
|
|||
|
|
@ -2513,6 +2513,24 @@
|
|||
"rerank": false
|
||||
}
|
||||
},
|
||||
"stackit": {
|
||||
"display_name": "STACKIT (`stackit`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/stackit",
|
||||
"endpoints": {
|
||||
"chat_completions": true,
|
||||
"messages": true,
|
||||
"responses": true,
|
||||
"embeddings": false,
|
||||
"image_generations": false,
|
||||
"audio_transcriptions": false,
|
||||
"audio_speech": false,
|
||||
"moderations": false,
|
||||
"batches": false,
|
||||
"rerank": false,
|
||||
"a2a": false,
|
||||
"interactions": false
|
||||
}
|
||||
},
|
||||
"synthetic": {
|
||||
"display_name": "Synthetic (`synthetic`)",
|
||||
"endpoints": {
|
||||
|
|
|
|||
243
tests/unit/llms/openai_like/test_stackit_provider.py
Normal file
243
tests/unit/llms/openai_like/test_stackit_provider.py
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
import json
|
||||
from pathlib import Path
|
||||
from typing import Final
|
||||
|
||||
import pytest
|
||||
import respx
|
||||
|
||||
import litellm
|
||||
from litellm.caching.llm_caching_handler import LLMClientCache
|
||||
|
||||
_BASE_URL: Final = "https://api.openai-compat.model-serving.eu01.onstackit.cloud/v1"
|
||||
_REPO_ROOT: Final = Path(litellm.__file__).parent.parent
|
||||
|
||||
_CHAT_COMPLETION: Final = {
|
||||
"id": "chatcmpl_stackit",
|
||||
"object": "chat.completion",
|
||||
"created": 1_790_000_000,
|
||||
"model": "openai/gpt-oss-120b",
|
||||
"choices": [
|
||||
{
|
||||
"index": 0,
|
||||
"message": {"role": "assistant", "content": "Hello from STACKIT"},
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
"usage": {"prompt_tokens": 4, "completion_tokens": 3, "total_tokens": 7},
|
||||
}
|
||||
|
||||
|
||||
def test_stackit_is_a_registered_provider():
|
||||
assert litellm.LlmProviders.STACKIT.value == "stackit"
|
||||
assert "stackit" in litellm.provider_list
|
||||
assert "stackit" in litellm.constants.openai_compatible_providers
|
||||
assert _BASE_URL in litellm.constants.openai_compatible_endpoints
|
||||
|
||||
|
||||
def test_stackit_provider_resolution(monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
monkeypatch.setenv("STACKIT_API_KEY", "stackit-test-key")
|
||||
monkeypatch.delenv("STACKIT_API_BASE", raising=False)
|
||||
|
||||
model, provider, api_key, api_base = get_llm_provider(
|
||||
model="stackit/openai/gpt-oss-120b",
|
||||
custom_llm_provider=None,
|
||||
api_base=None,
|
||||
api_key=None,
|
||||
)
|
||||
|
||||
assert model == "openai/gpt-oss-120b"
|
||||
assert provider == "stackit"
|
||||
assert api_key == "stackit-test-key"
|
||||
assert api_base == _BASE_URL
|
||||
|
||||
|
||||
def test_stackit_provider_keeps_explicit_credentials(monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
monkeypatch.setenv("STACKIT_API_KEY", "stackit-env-key")
|
||||
monkeypatch.setenv("STACKIT_API_BASE", "https://stackit.env.example/v1")
|
||||
|
||||
_, provider, api_key, api_base = get_llm_provider(
|
||||
model="stackit/openai/gpt-oss-120b",
|
||||
custom_llm_provider=None,
|
||||
api_base="https://stackit.internal.example/v1",
|
||||
api_key="stackit-explicit-key",
|
||||
)
|
||||
|
||||
assert provider == "stackit"
|
||||
assert api_key == "stackit-explicit-key"
|
||||
assert api_base == "https://stackit.internal.example/v1"
|
||||
|
||||
|
||||
def test_stackit_api_base_env_overrides_default(monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
monkeypatch.setenv("STACKIT_API_KEY", "stackit-env-key")
|
||||
monkeypatch.setenv("STACKIT_API_BASE", "https://stackit.env.example/v1")
|
||||
|
||||
_, provider, _, api_base = get_llm_provider(
|
||||
model="stackit/openai/gpt-oss-120b",
|
||||
custom_llm_provider=None,
|
||||
api_base=None,
|
||||
api_key=None,
|
||||
)
|
||||
|
||||
assert provider == "stackit"
|
||||
assert api_base == "https://stackit.env.example/v1"
|
||||
|
||||
|
||||
def test_stackit_api_base_autodetects_provider(monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
monkeypatch.setenv("STACKIT_API_KEY", "stackit-env-key")
|
||||
|
||||
# STACKIT model ids carry their own org prefix (openai/, google/, Qwen/, ...). "openai/..." on its own
|
||||
# would be routed to OpenAI, so autodetection is only meaningful for ids without a provider-like prefix.
|
||||
model, provider, api_key, api_base = get_llm_provider(
|
||||
model="Qwen/Qwen3.8-27B",
|
||||
custom_llm_provider=None,
|
||||
api_base=_BASE_URL,
|
||||
api_key=None,
|
||||
)
|
||||
|
||||
assert model == "Qwen/Qwen3.8-27B"
|
||||
assert provider == "stackit"
|
||||
assert api_key == "stackit-env-key"
|
||||
assert api_base == _BASE_URL
|
||||
|
||||
|
||||
def test_stackit_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())
|
||||
stackit = next(provider for provider in providers if provider["litellm_provider"] == "stackit")
|
||||
|
||||
assert stackit["provider"] == "STACKIT"
|
||||
assert stackit["provider_display_name"] == "STACKIT"
|
||||
assert stackit["default_model_placeholder"] == "stackit/openai/gpt-oss-120b"
|
||||
assert {field["key"]: field["required"] for field in stackit["credential_fields"]} == {
|
||||
"api_base": False,
|
||||
"api_key": True,
|
||||
}
|
||||
|
||||
|
||||
def test_stackit_supported_endpoints():
|
||||
expected: Final = {
|
||||
"chat_completions": True,
|
||||
"messages": True,
|
||||
"responses": True,
|
||||
"embeddings": False,
|
||||
"image_generations": False,
|
||||
"audio_transcriptions": False,
|
||||
"audio_speech": False,
|
||||
"moderations": False,
|
||||
"batches": False,
|
||||
"rerank": False,
|
||||
"a2a": False,
|
||||
"interactions": False,
|
||||
}
|
||||
backup_path = Path(litellm.__file__).parent / "provider_endpoints_support_backup.json"
|
||||
root_path = _REPO_ROOT / "provider_endpoints_support.json"
|
||||
|
||||
assert json.loads(backup_path.read_text())["providers"]["stackit"]["endpoints"] == expected
|
||||
assert json.loads(root_path.read_text())["providers"]["stackit"]["endpoints"] == expected
|
||||
|
||||
|
||||
def test_stackit_cost_map_entries():
|
||||
root = json.loads((_REPO_ROOT / "model_prices_and_context_window.json").read_text())
|
||||
backup = json.loads((Path(litellm.__file__).parent / "model_prices_and_context_window_backup.json").read_text())
|
||||
|
||||
for cost_map in (root, backup):
|
||||
stackit = {k: v for k, v in cost_map.items() if v.get("litellm_provider") == "stackit"}
|
||||
assert stackit, "no stackit entries in cost map"
|
||||
assert all(key.startswith("stackit/") for key in stackit)
|
||||
assert {v["mode"] for v in stackit.values()} == {"chat"}
|
||||
|
||||
# STACKIT price tiers (EUR per 1M tokens): standard 0.15/0.25, plus 0.45/0.65, premium 1.50/1.75
|
||||
gpt_oss_20b = stackit["stackit/openai/gpt-oss-20b"]
|
||||
assert gpt_oss_20b["input_cost_per_token"] == pytest.approx(0.15e-6)
|
||||
assert gpt_oss_20b["output_cost_per_token"] == pytest.approx(0.25e-6)
|
||||
|
||||
gpt_oss_120b = stackit["stackit/openai/gpt-oss-120b"]
|
||||
assert gpt_oss_120b["input_cost_per_token"] == pytest.approx(0.45e-6)
|
||||
assert gpt_oss_120b["output_cost_per_token"] == pytest.approx(0.65e-6)
|
||||
assert gpt_oss_120b["supports_reasoning"] is True
|
||||
assert gpt_oss_120b["supports_function_calling"] is True
|
||||
|
||||
qwen_vl = stackit["stackit/Qwen/Qwen3-VL-235B-A22B-Instruct-FP8"]
|
||||
assert qwen_vl["input_cost_per_token"] == pytest.approx(1.50e-6)
|
||||
assert qwen_vl["output_cost_per_token"] == pytest.approx(1.75e-6)
|
||||
assert qwen_vl["supports_vision"] is True
|
||||
|
||||
|
||||
def test_stackit_chat_completion_request():
|
||||
with respx.mock() as upstream:
|
||||
route: Final = upstream.post(f"{_BASE_URL}/chat/completions").respond(200, json=_CHAT_COMPLETION)
|
||||
response: Final = litellm.completion(
|
||||
model="stackit/openai/gpt-oss-120b",
|
||||
messages=[{"role": "user", "content": "Say hello"}],
|
||||
api_key="stackit-test-key",
|
||||
)
|
||||
|
||||
request: Final = route.calls.last.request
|
||||
body: Final = json.loads(request.content)
|
||||
assert route.call_count == 1
|
||||
assert str(request.url) == f"{_BASE_URL}/chat/completions"
|
||||
assert request.headers["authorization"] == "Bearer stackit-test-key"
|
||||
assert body["model"] == "openai/gpt-oss-120b"
|
||||
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
|
||||
assert response.choices[0].message.content == "Hello from STACKIT"
|
||||
|
||||
|
||||
def test_stackit_chat_completion_cost_uses_cost_map():
|
||||
with respx.mock() as upstream:
|
||||
upstream.post(f"{_BASE_URL}/chat/completions").respond(200, json=_CHAT_COMPLETION)
|
||||
response: Final = litellm.completion(
|
||||
model="stackit/openai/gpt-oss-120b",
|
||||
messages=[{"role": "user", "content": "Say hello"}],
|
||||
api_key="stackit-test-key",
|
||||
)
|
||||
|
||||
# 4 prompt tokens * 0.45e-6 + 3 completion tokens * 0.65e-6
|
||||
assert response._hidden_params["response_cost"] == pytest.approx(4 * 0.45e-6 + 3 * 0.65e-6)
|
||||
|
||||
|
||||
def test_stackit_responses_request_is_bridged_to_chat_completions():
|
||||
with respx.mock() as upstream:
|
||||
route: Final = upstream.post(f"{_BASE_URL}/chat/completions").respond(200, json=_CHAT_COMPLETION)
|
||||
response: Final = litellm.responses(
|
||||
model="stackit/openai/gpt-oss-120b",
|
||||
input="Say hello",
|
||||
api_key="stackit-test-key",
|
||||
)
|
||||
|
||||
request: Final = route.calls.last.request
|
||||
body: Final = json.loads(request.content)
|
||||
assert route.call_count == 1
|
||||
assert request.headers["authorization"] == "Bearer stackit-test-key"
|
||||
assert body["model"] == "openai/gpt-oss-120b"
|
||||
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
|
||||
assert response.output[0].content[0].text == "Hello from STACKIT"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_stackit_anthropic_messages_request_is_bridged_to_chat_completions(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(f"{_BASE_URL}/chat/completions").respond(200, json=_CHAT_COMPLETION)
|
||||
response: Final = await litellm.anthropic.messages.acreate(
|
||||
model="stackit/openai/gpt-oss-120b",
|
||||
messages=[{"role": "user", "content": "Say hello"}],
|
||||
max_tokens=32,
|
||||
api_key="stackit-test-key",
|
||||
)
|
||||
|
||||
request: Final = route.calls.last.request
|
||||
body: Final = json.loads(request.content)
|
||||
assert route.call_count == 1
|
||||
assert request.headers["authorization"] == "Bearer stackit-test-key"
|
||||
assert body["model"] == "openai/gpt-oss-120b"
|
||||
assert body["max_tokens"] == 32
|
||||
assert response["content"][0]["text"] == "Hello from STACKIT"
|
||||
Loading…
Add table
Reference in a new issue