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_internal_staging' into enforce-rpm-tpm-on-model-add
ryan-crabbe-berria85036ec3efa
diff --cc litellm/proxy/management_endpoints/model_management_endpoints.pyindex d9030f42f69,3242c6f6084..7654622c8b8--- a/litellm/proxy/management_endpoints/model_management_endpoints.py+++ b/litellm/proxy/management_endpoints/model_management_endpoints.py@@@ -239,39 -252,7 +252,39 @@@ def _raise_on_strategy_router_write_vio)+ENFORCE_RPM_TPM_ON_MODEL_ADD_SETTING: Final = "enforce_rpm_tpm_on_model_add"+_REQUIRED_RATE_LIMIT_FIELDS: Final = ("rpm", "tpm")+++def _raise_if_rate_limits_required_but_missing(*, litellm_params: GenericLiteLLMParams, enforced: bool) -> None:+ """Require both rpm and tpm (each a positive value) when the operator opts in via config.yaml.++ Off by default, so deployments keep adding models without limits. When+ ``enforce_rpm_tpm_on_model_add: true`` is set under general_settings, a model added+ without both rpm and tpm set to a positive value is rejected rather than stored+ unbounded (or effectively excluded from routing by a zero/negative limit).+ """+ if not enforced:+ return+ missing: Final = tuple(+ field+ for field in _REQUIRED_RATE_LIMIT_FIELDS+ if (value := getattr(litellm_params, field)) is None or value <= 0+ )+ if not missing:+ return+ raise ProxyException(+ message=(+ f"{' and '.join(missing)} must be set to a positive value when "+ f"'{ENFORCE_RPM_TPM_ON_MODEL_ADD_SETTING}' is enabled in general_settings"+ ),+ type=ProxyErrorTypes.validation_error.value,+ code=status.HTTP_400_BAD_REQUEST,+ param=f"litellm_params.{missing[0]}",+ )++- _PTU_MODEL_INFO_FIELDS: Final = ("ptu_count", "cost_per_ptu_per_hour", "ptu_effective_from", "ptu_effective_to")+ _PTU_PRICED_PAIR: Final = frozenset({"ptu_count", "cost_per_ptu_per_hour"})def _explicitly_cleared_ptu_fields(model_info: ModelInfo | None) -> frozenset[str]:@@@ -1598,12 -1748,7 +1780,12 @@@ async def add_new_modelexisting_params=None,)+ _raise_if_rate_limits_required_but_missing(+ litellm_params=model_params.litellm_params,+ enforced=bool(general_settings.get(ENFORCE_RPM_TPM_ON_MODEL_ADD_SETTING, False)),+ )+- model_response: LiteLLM_ProxyModelTable | None = None+ model_response: prisma_models.LiteLLM_ProxyModelTable | LiteLLM_ProxyModelTable | None = None# update DBincoming_model_info: Final = model_params.model_info.model_dump(exclude_none=True)_raise_if_ptu_cost_attribution_disabled(incoming_model_info)