mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-29 01:03:17 +00:00
* fix(cost-map): move six azure retirement dates to the dates the retirement schedule now states * Refresh Azure retirements and hosted model metadata Co-authored-by: hisamoto <176846725+hisamotodev@users.noreply.github.com> Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(cost-map): type cost map rows in retirement date tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Co-authored-by: kerry <kerry@berri.ai>
209 lines
8.9 KiB
Python
209 lines
8.9 KiB
Python
import datetime
|
|
import json
|
|
from pathlib import Path
|
|
from typing import Final
|
|
|
|
import pytest
|
|
from pydantic import TypeAdapter
|
|
|
|
import litellm
|
|
from litellm.cost_calculator import default_image_cost_calculator
|
|
from litellm.types.utils import ModelInfo
|
|
|
|
REPO_ROOT: Final = Path(__file__).parents[2]
|
|
|
|
CostMap = dict[str, dict[str, object]]
|
|
COST_MAP_ADAPTER: Final = TypeAdapter(CostMap)
|
|
|
|
ABSORBED_MODELS: Final = frozenset(
|
|
(
|
|
"together_ai/ByteDance/Seedream-5.0-lite",
|
|
"together_ai/Qwen/Qwen-Image-2.0",
|
|
"together_ai/Qwen/Qwen-Image-2.0-Pro",
|
|
"together_ai/Wan-AI/Wan2.6-image",
|
|
"together_ai/black-forest-labs/FLUX.1-kontext-max",
|
|
"together_ai/black-forest-labs/FLUX.1-kontext-pro",
|
|
"together_ai/black-forest-labs/FLUX.1.1-pro",
|
|
"together_ai/black-forest-labs/FLUX.2-flex",
|
|
"together_ai/black-forest-labs/FLUX.2-max",
|
|
"together_ai/black-forest-labs/FLUX.2-pro",
|
|
"together_ai/google/flash-image-3.1-lite",
|
|
"together_ai/nvidia/parakeet-tdt-0.6b-v3",
|
|
"together_ai/openai/whisper-large-v3",
|
|
)
|
|
)
|
|
|
|
SERVERLESS_CHAT_MODELS: Final = (
|
|
"together_ai/moonshotai/Kimi-K3",
|
|
"together_ai/zai-org/GLM-5.2",
|
|
"together_ai/zai-org/GLM-5.3",
|
|
"together_ai/zai-org/GLM-5.3-Flash",
|
|
"together_ai/deepseek-ai/DeepSeek-V4-Pro-0813",
|
|
"together_ai/deepseek-ai/DeepSeek-V4-Flash-0731",
|
|
"together_ai/MiniMaxAI/MiniMax-M3",
|
|
"together_ai/thinkingmachines/Inkling",
|
|
"together_ai/thinkingmachines/Inkling-Small",
|
|
"together_ai/Qwen/Qwen3.8-2.4T-A95B",
|
|
"together_ai/Qwen/Qwen3.7-Max",
|
|
"together_ai/Qwen/Qwen3.7-Plus",
|
|
"together_ai/Qwen/Qwen3.6-Plus",
|
|
"together_ai/Qwen/Qwen3.5-9B",
|
|
"together_ai/meta-models/Muse-Glimmer-30B",
|
|
"together_ai/google/gemma-4-31B-it",
|
|
"together_ai/arize-ai/qwen-2-1.5b-instruct",
|
|
"together_ai/Prism-ML/Ternary-Bonsai-27B",
|
|
"together_ai/openai/gpt-oss-120b",
|
|
"together_ai/openai/gpt-oss-20b",
|
|
"together_ai/meta-llama/Llama-3.3-70B-Instruct-Turbo",
|
|
)
|
|
|
|
DEPRECATED_MODELS: Final = {
|
|
"together_ai/nvidia/nemotron-3-ultra-550b-a55b": "2026-08-27",
|
|
"together_ai/pearl-ai/gemma-4-31b-it": "2026-08-27",
|
|
"together_ai/deepseek-ai/DeepSeek-V4-Pro": "2026-08-27",
|
|
"together_ai/moonshotai/Kimi-K2.7-Code": "2026-08-27",
|
|
"together_ai/google/gemma-3n-E4B-it": "2026-08-25",
|
|
"together_ai/meta-llama/Llama-Guard-4-12B": "2026-08-25",
|
|
"together_ai/Qwen/Qwen3-235B-A22B-Instruct-2507-tput": "2026-07-10",
|
|
"together_ai/Qwen/Qwen3.5-397B-A17B": "2026-06-29",
|
|
"together_ai/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8": "2026-06-04",
|
|
"together_ai/moonshotai/Kimi-K2.5": "2026-05-21",
|
|
"together_ai/deepseek-ai/DeepSeek-R1": "2026-05-14",
|
|
"together_ai/deepseek-ai/DeepSeek-V3.1": "2026-05-14",
|
|
"together_ai/Qwen/Qwen3-235B-A22B-Thinking-2507": "2026-04-16",
|
|
"together_ai/mistralai/Mixtral-8x7B-Instruct-v0.1": "2026-04-16",
|
|
"together_ai/zai-org/GLM-4.5-Air-FP8": "2026-04-02",
|
|
"together_ai/zai-org/GLM-4.7": "2026-04-02",
|
|
"together_ai/mistralai/Mistral-Small-24B-Instruct-2501": "2026-04-02",
|
|
"together_ai/Qwen/Qwen3-Next-80B-A3B-Instruct": "2026-04-02",
|
|
"together_ai/meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8": "2026-03-31",
|
|
"together_ai/meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo": "2026-03-06",
|
|
"together_ai/moonshotai/Kimi-K2-Instruct-0905": "2026-03-06",
|
|
"together_ai/meta-llama/Llama-3.2-3B-Instruct-Turbo": "2026-03-06",
|
|
"together_ai/Qwen/Qwen3-Next-80B-A3B-Thinking": "2026-02-25",
|
|
"together_ai/meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo": "2026-02-25",
|
|
"together_ai/Qwen/Qwen3-235B-A22B-fp8-tput": "2026-02-06",
|
|
"together_ai/meta-llama/Llama-4-Scout-17B-16E-Instruct": "2026-02-06",
|
|
"together_ai/Qwen/Qwen2.5-72B-Instruct-Turbo": "2026-02-06",
|
|
"together_ai/meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo": "2026-02-06",
|
|
"together_ai/deepseek-ai/DeepSeek-R1-0528-tput": "2026-02-03",
|
|
"together_ai/meta-llama/Llama-3.3-70B-Instruct-Turbo-Free": "2025-11-13",
|
|
}
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def cost_map() -> CostMap:
|
|
with open(REPO_ROOT / "model_prices_and_context_window.json") as f:
|
|
return COST_MAP_ADAPTER.validate_python(json.load(f))
|
|
|
|
|
|
def _successor(info: dict[str, object]) -> str | None:
|
|
metadata = info.get("metadata")
|
|
if not isinstance(metadata, dict):
|
|
return None
|
|
successor = metadata.get("successor")
|
|
return successor if isinstance(successor, str) else None
|
|
|
|
|
|
def test_together_backup_cost_map_in_sync(cost_map: CostMap):
|
|
with open(REPO_ROOT / "litellm" / "model_prices_and_context_window_backup.json") as f:
|
|
backup = COST_MAP_ADAPTER.validate_python(json.load(f))
|
|
together_main = {k: v for k, v in cost_map.items() if k.startswith("together_ai/")}
|
|
together_backup = {k: v for k, v in backup.items() if k.startswith("together_ai/")}
|
|
assert together_backup == together_main
|
|
|
|
|
|
CACHED_INPUT_MODELS: Final = (
|
|
"together_ai/moonshotai/Kimi-K3",
|
|
"together_ai/zai-org/GLM-5.2",
|
|
"together_ai/meta-models/Muse-Glimmer-30B",
|
|
"together_ai/Qwen/Qwen3.8-2.4T-A95B",
|
|
"together_ai/deepseek-ai/DeepSeek-V4-Pro-0813",
|
|
"together_ai/deepseek-ai/DeepSeek-V4-Flash-0731",
|
|
"together_ai/thinkingmachines/Inkling",
|
|
"together_ai/MiniMaxAI/MiniMax-M3",
|
|
"together_ai/thinkingmachines/Inkling-Small",
|
|
"together_ai/moonshotai/Kimi-K2.7-Code",
|
|
"together_ai/deepseek-ai/DeepSeek-V4-Pro",
|
|
"together_ai/nvidia/nemotron-3-ultra-550b-a55b",
|
|
"together_ai/Qwen/Qwen3.7-Max",
|
|
)
|
|
|
|
|
|
def test_together_prompt_caching_flag_implies_cache_read_rate(cost_map: CostMap):
|
|
for model, info in cost_map.items():
|
|
if model.startswith("together_ai/") and info.get("supports_prompt_caching"):
|
|
assert "cache_read_input_token_cost" in info, f"{model} flags caching without a cache read rate"
|
|
|
|
|
|
@pytest.mark.parametrize("model", ["together_ai/thinkingmachines/Inkling", "together_ai/thinkingmachines/inkling"])
|
|
def test_inkling_alias_preserves_registry_metadata_and_pricing(model: str, cost_map: CostMap) -> None:
|
|
canonical: Final = cost_map["together_ai/thinkingmachines/Inkling"]
|
|
assert cost_map[model] == canonical
|
|
input_rate: Final = TypeAdapter(float).validate_python(canonical["input_cost_per_token"])
|
|
output_rate: Final = TypeAdapter(float).validate_python(canonical["output_cost_per_token"])
|
|
|
|
response: Final = litellm.ModelResponse(
|
|
model=model, usage=litellm.Usage(prompt_tokens=100, completion_tokens=50)
|
|
)
|
|
|
|
assert litellm.completion_cost(completion_response=response) == pytest.approx(
|
|
100 * input_rate + 50 * output_rate
|
|
)
|
|
assert litellm.supports_audio_input(model=model) == canonical.get("supports_audio_input", False)
|
|
assert litellm.supports_vision(model=model) == canonical.get("supports_vision", False)
|
|
assert litellm.supports_reasoning(model=model) == canonical.get("supports_reasoning", False)
|
|
|
|
|
|
def _together_rows(cost_map: CostMap, mode: str) -> tuple[tuple[str, dict[str, object]], ...]:
|
|
return tuple(
|
|
(model, info)
|
|
for model, info in cost_map.items()
|
|
if model in ABSORBED_MODELS and info.get("mode") == mode
|
|
)
|
|
|
|
|
|
# Published serverless removals or redirects by July 29, 2026:
|
|
# https://docs.together.ai/docs/deprecations and https://docs.together.ai/docs/changelog
|
|
@pytest.mark.parametrize(
|
|
"model",
|
|
(
|
|
"together_ai/BAAI/bge-base-en-v1.5",
|
|
"together_ai/zai-org/GLM-4.6",
|
|
"together_ai/deepseek-ai/DeepSeek-R1-0528",
|
|
"together_ai/mistralai/Ministral-3-14B-Instruct-2512",
|
|
"together_ai/mistralai/Mistral-7B-Instruct-v0.3",
|
|
"together_ai/meta-llama/Llama-3.2-1B-Instruct",
|
|
"together_ai/meta-llama/Llama-3.2-3B-Instruct",
|
|
"together_ai/Qwen/Qwen2-1.5B-Instruct",
|
|
"together_ai/Qwen/Qwen2.5-14B-Instruct",
|
|
"together_ai/Qwen/Qwen2.5-72B-Instruct",
|
|
),
|
|
)
|
|
def test_together_retired_serverless_rows_keep_a_deprecation_date(model: str, cost_map: CostMap) -> None:
|
|
value: Final = cost_map[model].get("deprecation_date")
|
|
assert isinstance(value, str) and datetime.date.fromisoformat(value) <= datetime.date(2026, 7, 29)
|
|
|
|
|
|
def test_together_image_rows_price_through_the_cost_calculator(cost_map: CostMap):
|
|
rows: Final = _together_rows(cost_map, "image_generation")
|
|
assert rows
|
|
for model, info in rows:
|
|
assert (
|
|
default_image_cost_calculator(
|
|
model=model,
|
|
custom_llm_provider="together_ai",
|
|
size="1024x1024",
|
|
model_info=ModelInfo(**info), # pyright: ignore[reportArgumentType] # untyped cost map JSON
|
|
)
|
|
> 0
|
|
), f"{model} has no usable image price"
|
|
|
|
|
|
def test_together_transcription_rows_carry_a_per_second_rate(cost_map: CostMap):
|
|
rows: Final = _together_rows(cost_map, "audio_transcription")
|
|
assert rows
|
|
for model, info in rows:
|
|
assert isinstance(rate := info.get("input_cost_per_second"), float) and rate > 0, (
|
|
f"{model} has no usable transcription price"
|
|
)
|