diff --git a/litellm/proxy/usage_telemetry.py b/litellm/proxy/usage_telemetry.py index 08f8f651349..68e356f0781 100644 --- a/litellm/proxy/usage_telemetry.py +++ b/litellm/proxy/usage_telemetry.py @@ -221,11 +221,10 @@ _PUBLIC_MODELS: Final[frozenset[str]] = frozenset(GetModelCostMap.load_local_mod def _public_model_label(model: str, provider: str | None) -> str: """Only names shipped in the packaged pricing map are exported; anything else, including names operators registered for billing, becomes "other".""" - if model in _PUBLIC_MODELS: - return model - if provider is not None and f"{provider}/{model}" in _PUBLIC_MODELS: - return f"{provider}/{model}" - return "other" + candidates: Final = ( + (model, f"{provider}/{model}", model.removeprefix(f"{provider}/")) if provider is not None else (model,) + ) + return next((candidate for candidate in candidates if candidate in _PUBLIC_MODELS), "other") class _ConfigParamWhere(TypedDict): diff --git a/tests/test_litellm/proxy/test_usage_telemetry.py b/tests/test_litellm/proxy/test_usage_telemetry.py index 38ae3d0419c..78169a3aa65 100644 --- a/tests/test_litellm/proxy/test_usage_telemetry.py +++ b/tests/test_litellm/proxy/test_usage_telemetry.py @@ -194,6 +194,12 @@ def test_shipped_provider_prefixed_model_labels_as_itself() -> None: assert ut._public_model_label(model, provider) == shipped +def test_provider_prefixed_bare_shipped_model_labels_as_bare_name() -> None: + bare: Final = min(key for key in ut._PUBLIC_MODELS if "/" not in key and f"openai/{key}" not in ut._PUBLIC_MODELS) + assert ut._public_model_label(f"openai/{bare}", "openai") == bare + assert ut._public_model_label(f"openai/{bare}", None) == "other" + + async def test_success_event_with_missing_payload_records_nothing() -> None: recorder, reader = _recorder_with_reader()