The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Merge branch 'litellm_block_unpriced_models' of https://github.com/BerriAI/litellm into litellm_block_unpriced_models
mateo-berri7f539e388c3c
diff --cc litellm/proxy/auth/auth_checks.pyindex 6f41fde4b88,78330a344fb..ede1b1a0a03--- a/litellm/proxy/auth/auth_checks.py+++ b/litellm/proxy/auth/auth_checks.py@@@ -493,18 -479,23 +482,23 @@@ def _entry_has_priced_metric(entry: Mapreturn False+ def _entry_declares_price(entry: Mapping[str, object]) -> bool:+ return any("cost_per" in key for key in entry)++def _model_group_has_pricing(model: str, llm_router: "Router") -> bool:"""- Check every deployment behind a model group for a positive price on any billed- metric (tokens, characters, seconds, pages, images, queries, ...), so models that- are billed by a non-token metric are not treated as unpriced.+ A model group counts as priced when a deployment overrides any *cost_per* field in its+ litellm_params, even at zero, or when its resolved model info carries a positive price on+ any billed metric (tokens, characters, seconds, pages, images, queries, ...), so models+ billed by a non-token metric are not treated as unpriced."""- for deployment in llm_router.get_model_list(model_name=model) or []:- litellm_params = deployment.get("litellm_params") or {}+ for deployment in llm_router.get_model_list(model_name=model) or ():+ litellm_params = deployment.get("litellm_params") or _EMPTY_COST_ENTRY- if _entry_has_priced_metric(litellm_params):+ if _entry_declares_price(litellm_params):return True- model_id = (deployment.get("model_info") or {}).get("id")+ model_id = (deployment.get("model_info") or _EMPTY_COST_ENTRY).get("id")if model_id is None:continue