litellm/tests/test_litellm/proxy/pass_through_endpoints
Sameer Kankute c2efe9e422
fix(vertex-ai): fix zero cost/usage on completed Vertex AI batch jobs (#27912)
* fix(vertex-ai): fix zero cost/usage on completed Vertex AI batch jobs

Vertex batch jobs recorded 0 spend and 0 tokens after PR #25627 added
automatic transformation of GCS predictions.jsonl to OpenAI format.

Two bugs fixed:

1. batch_utils.py: the Vertex-specific cost/usage reader
   (calculate_vertex_ai_batch_cost_and_usage) was always invoked and
   reads raw usageMetadata fields that no longer exist in the
   OpenAI-shaped output. Now the reader is only used when
   disable_vertex_batch_output_transformation=True; otherwise the
   generic path handles the already-transformed OpenAI-shaped content.

2. cost_calculator.py: batch_cost_calculator skipped the global
   litellm.get_model_info() lookup when a model_info dict was passed
   in, even when that dict had no pricing fields (e.g. deployment
   metadata with only id/db_model). It now falls back to the global
   pricing table when the provided model_info has no pricing data.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Update litellm/cost_calculator.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* fix(cost-calculator): use not-any guard for pricing fallback in batch_cost_calculator

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(cost-calculator): treat explicit zero batch pricing as set in model_info

The fallback to litellm.get_model_info() used truthy checks on pricing
fields, so 0.0 was treated as missing and replaced by global rates.
Use `is not None` like elsewhere in cost calculation. Add regression test.

Co-authored-by: Sameer Kankute <Sameerlite@users.noreply.github.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: Sameer Kankute <Sameerlite@users.noreply.github.com>
2026-05-15 04:47:02 -07:00
..
llm_provider_handlers fix(proxy): inherit caller identity in passthrough batch managed-object 2026-04-29 16:25:13 -07:00
test_llm_pass_through_endpoints.py fix(vertex passthrough): log :embedContent and :batchEmbedContents responses (#26146) 2026-04-24 16:07:11 -07:00
test_method_specific_routing.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_pass_through_endpoints.py fix(passthrough): strip Server/Date/Connection from upstream response headers 2026-04-24 16:56:44 -07:00
test_passthrough_auth_default.py fix(passthrough): default auth=True; drop enterprise gate on the safe option 2026-04-29 23:10:59 +00:00
test_passthrough_endpoints_common_utils.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_passthrough_guardrails_field_targeting.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_passthrough_guardrails.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_passthrough_post_call_guardrails.py fix(proxy): invoke post-call guardrails on pass-through endpoint responses (#20270) (#26262) 2026-04-27 08:58:22 +05:30
test_streaming_handler_interrupt.py refactor: trim explanatory comments from streaming-flush fix 2026-04-30 02:39:28 +00:00
test_vertex_ai_batch_passthrough.py fix(vertex-ai): fix zero cost/usage on completed Vertex AI batch jobs (#27912) 2026-05-15 04:47:02 -07:00
test_vertex_passthrough_load_balancing.py Merge pull request #25256 from BerriAI/litellm_ishaan_april6 2026-04-17 16:26:45 -07:00