diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.py index d9710d0c1a4..b84f1b1356f 100644 --- a/litellm/cost_calculator.py +++ b/litellm/cost_calculator.py @@ -1817,6 +1817,10 @@ def ocr_cost( pages_processed = response.usage_info.pages_processed if pages_processed is None: + verbose_logger.warning( + "ocr_cost: pages_processed is None for model=%s; returning 0 cost", + model, + ) return 0.0, 0.0 ocr_cost_per_page: float = 0.0 diff --git a/litellm/llms/vertex_ai/vertex_llm_base.py b/litellm/llms/vertex_ai/vertex_llm_base.py index 787b45df15c..b029e9220f2 100644 --- a/litellm/llms/vertex_ai/vertex_llm_base.py +++ b/litellm/llms/vertex_ai/vertex_llm_base.py @@ -359,9 +359,11 @@ class VertexBase: def _get_async_refresh_lock(self, credential_cache_key: tuple) -> asyncio.Lock: """Get or create an asyncio.Lock for the given credential cache key.""" - return self._async_refresh_locks.setdefault( - credential_cache_key, asyncio.Lock() - ) + lock = self._async_refresh_locks.get(credential_cache_key) + if lock is None: + lock = asyncio.Lock() + self._async_refresh_locks[credential_cache_key] = lock + return lock def _try_get_cached_token( self,