Skip to content

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]

test(vertex): cover malformed batch usage details

kerry7761d044509e
diff --git a/tests/test_litellm/llms/vertex_ai/batches/test_transformation.py b/tests/test_litellm/llms/vertex_ai/batches/test_transformation.py
index 232c6413e78..e6126b02790 100644
--- a/tests/test_litellm/llms/vertex_ai/batches/test_transformation.py
+++ b/tests/test_litellm/llms/vertex_ai/batches/test_transformation.py
@@ -17,9 +17,9 @@ from unittest.mock import patch
import pytest
-
from litellm.llms.vertex_ai.batches.transformation import ( # noqa: E402
VertexAIBatchTransformation,
+ vertex_prompt_tokens_details,
)
from litellm.llms.vertex_ai.common_utils import ( # noqa: E402
VertexAIError,
@@ -41,6 +41,22 @@ ENDPOINT_INPUT_FILE = (
)
+def test_vertex_prompt_tokens_details_rejects_malformed_details():
+ assert vertex_prompt_tokens_details({"promptTokensDetails": [1]}) is None
+ assert vertex_prompt_tokens_details({"promptTokensDetails": [{"modality": "AUDIO"}]}) is None
+ assert (
+ vertex_prompt_tokens_details(
+ {
+ "promptTokensDetails": [
+ {"modality": "AUDIO", "tokenCount": 1},
+ "malformed",
+ ]
+ }
+ )
+ is None
+ )
+
+
# =========================================================================== #
# transform_openai_batch_request_to_vertex_ai_batch_request
# =========================================================================== #