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
test(cost_map): assert runtime reloads refresh loaded_at
mateo-berri946d6f665ed8
diff --git a/tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py b/tests/test_litellm/litellm_core_utils/test_get_model_cost_map.pyindex 18794ea7eec..f72d175d579 100644--- a/tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py+++ b/tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py@@ -335,6 +335,7 @@ def test_get_model_cost_map_stamps_loaded_at(monkeypatch):import functoolsimport random+from datetime import datetime, timezoneimport httpx@@ -554,6 +555,27 @@ async def test_refetch_local_override_reports_the_bundled_blob_id_without_an_etaassert get_model_cost_map_provenance() == {"source_revision": _bundled_blob_id(), "etag": None}+async def test_refetch_stamps_loaded_at_on_remote_and_local_reloads(monkeypatch):+ from litellm.litellm_core_utils import get_model_cost_map as module++ client, _ = _mock_client([httpx.Response(200, content=_real_map_bytes())])+ monkeypatch.setattr(module._cost_map_source_info, "loaded_at", None)+ before_remote = datetime.now(timezone.utc)+ await refetch_model_cost_map(url=_URL, sleep=_SleepRecorder(), rng=random.Random(0), client=client)+ remote_loaded_at = module.get_model_cost_map_loaded_at()+ assert remote_loaded_at is not None+ assert before_remote <= remote_loaded_at <= datetime.now(timezone.utc)++ monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")+ monkeypatch.setattr(module._cost_map_source_info, "loaded_at", None)+ before_local = datetime.now(timezone.utc)+ await refetch_model_cost_map(url=_URL, sleep=_SleepRecorder(), rng=random.Random(0))+ local_loaded_at = module.get_model_cost_map_loaded_at()+ assert local_loaded_at is not None+ assert before_local <= local_loaded_at <= datetime.now(timezone.utc)++# ---------------------------------------------------------------------------# get_model_cost_map: the boot-time load retries transient failures like a reload does# ---------------------------------------------------------------------------