litellm/tests/e2e/model_matrix.py
mateo-berri 09f2a9528a
test(e2e): centralize model pins in model_matrix.py and enforce freshness in CI
Model IDs were hardcoded across the e2e suite, so every provider
deprecation meant a scatter-shot edit and stale models (gemini-2.5-flash,
gpt-4o-mini) kept running in CI. Tests now import role-named pins from
tests/e2e/model_matrix.py, and a bump is a one-file change plus the
compose gateway config.

check_e2e_model_freshness.py (wired into test-code-quality) fails when a
pin is missing from model_prices_and_context_window.json, is within 30
days of its deprecation_date, drifts from the docker-compose gateway
config, or when a test hardcodes a versioned model literal again.

Bumps: gemini-2.5-flash -> gemini-3.5-flash, gpt-4o-mini -> gpt-5.4-mini
2026-07-08 07:15:58 +00:00

66 lines
2 KiB
Python

"""Single source of truth for every model the e2e suite drives.
Bump a model version here instead of editing individual tests. Constants are
named for the role a model plays, never its version, so a bump touches this
file (plus docker-compose.yml, which cannot import Python) and nothing else.
tests/code_coverage_tests/check_e2e_model_freshness.py fails CI when a pin
disappears from model_prices_and_context_window.json, approaches its
deprecation_date, drifts from the docker-compose gateway config, or when a
test hardcodes a model literal instead of importing a pin.
"""
from dataclasses import dataclass
@dataclass(frozen=True, slots=True)
class ModelPin:
provider: str
model_id: str
gateway_alias: str = ""
pricing_key: str = ""
@property
def backend(self) -> str:
return f"{self.provider}/{self.model_id}"
@property
def alias(self) -> str:
return self.gateway_alias or self.model_id
@property
def canonical(self) -> str:
return self.pricing_key or self.backend
GEMINI_CHAT = ModelPin("gemini", "gemini-3.5-flash")
OPENAI_CHAT = ModelPin("openai", "gpt-5.5")
OPENAI_CHAT_MINI = ModelPin("openai", "gpt-5.4-mini")
ANTHROPIC_CHAT = ModelPin("anthropic", "claude-haiku-4-5")
OPENAI_EMBEDDING = ModelPin(
"openai", "text-embedding-3-small", gateway_alias="openai-text-embedding-3-small"
)
OPENAI_TTS = ModelPin("openai", "gpt-4o-mini-tts")
VERTEX_CHAT = ModelPin("vertex_ai", "gemini-3.5-flash")
AZURE_BATCH = ModelPin("azure", "gpt-4.1-mini-batch", pricing_key="azure/gpt-4.1-mini")
BEDROCK_ANTHROPIC_CHAT = ModelPin("bedrock", "us.anthropic.claude-haiku-4-5-20251001-v1:0")
COHERE_RERANK = ModelPin("cohere", "rerank-v3.5")
GATEWAY_MODELS: tuple[ModelPin, ...] = (
OPENAI_CHAT,
ANTHROPIC_CHAT,
GEMINI_CHAT,
OPENAI_EMBEDDING,
)
ALL_PINS: tuple[ModelPin, ...] = (
GEMINI_CHAT,
OPENAI_CHAT,
OPENAI_CHAT_MINI,
ANTHROPIC_CHAT,
OPENAI_EMBEDDING,
OPENAI_TTS,
VERTEX_CHAT,
AZURE_BATCH,
BEDROCK_ANTHROPIC_CHAT,
COHERE_RERANK,
)