From 13414f35d23c25e65987c7db793c9ffc0b926343 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 15 Sep 2026 21:14:14 +0000 Subject: [PATCH] test(vertex): load local pricing in embedding billing tests The gemini-embedding-2 batch embedding tests assert exact dollar amounts using the in-repo pricing schema. Without LITELLM_LOCAL_MODEL_COST_MAP=True, litellm.model_cost is fetched from main, which now bills those modalities per-token instead. That mismatch drove the Vertex AI unit tests to fail with prompt_cost of 0.0 or the per-token figure rather than the expected per-image / per-second amount. Add an autouse fixture that pins the cost map to the in-repo copy so the billing assertions stay deterministic on this branch. --- .../test_batch_embed_content_transformation.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_litellm/llms/vertex_ai/gemini_embeddings/test_batch_embed_content_transformation.py b/tests/test_litellm/llms/vertex_ai/gemini_embeddings/test_batch_embed_content_transformation.py index 86b3f0976ab..0b8ce25d1c6 100644 --- a/tests/test_litellm/llms/vertex_ai/gemini_embeddings/test_batch_embed_content_transformation.py +++ b/tests/test_litellm/llms/vertex_ai/gemini_embeddings/test_batch_embed_content_transformation.py @@ -10,6 +10,7 @@ Covers: import pytest +import litellm from litellm.litellm_core_utils.llm_cost_calc.utils import generic_cost_per_token from litellm.llms.vertex_ai.gemini_embeddings.batch_embed_content_transformation import ( _build_part_for_input, @@ -27,6 +28,15 @@ IMAGE_DATA_URI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+ GCS_URL = "gs://my-bucket/image.png" +@pytest.fixture(autouse=True) +def _local_model_cost_map(monkeypatch): + monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True") + monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url="")) + litellm.get_model_info.cache_clear() + yield + litellm.get_model_info.cache_clear() + + class TestIsMultimodalInput: def test_text_only_string(self): assert _is_multimodal_input("hello world") is False