Repository navigation
Conversation
…aracter embeddings per character - thread vertex_location through batch cost accounting so non-global batch jobs get the same regional-endpoint uplift as the online path - route per-character-priced Vertex embeddings (text-embedding-005, text-multilingual-embedding-002) to character billing, using the billableCharacterCount reported by the predict response - per-token embeddings (gemini-embedding-*) keep token pricing Fixes BerriAI#46880
Contributor
Merging this PR will not alter performance
|
…x embedding tests
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
The repo-wide type gate counts Unknown-type diagnostics: reading the stashed billable count through getattr on the partially-typed completion_response added one reportUnknownArgumentType, and the new billable-count read in the embedding transformation added reportUnknownMemberType/reportUnknownVariableType entries. Narrow the response with isinstance (the convention the next block already uses), read the count through the typed get_hidden_params helper, and cast the Vertex statistics dict instead of annotating it - explicit Any is not allowed here.
The strict-imports gate bans typing.cast imports without a reason; annotate the import with the payload's justification.
Mrun25
force-pushed
the
fix/vertex-embedding-batch-cost-46880
branch
from
October 17, 2026 06:23
4bf2eb7 to
23413eb
Compare
This was referenced Oct 20, 2026
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Problem this solves:
How it solves it:
User Flow
Before: a team running Gemini batch jobs on a regional Vertex endpoint logs spend lower than their Google invoice
vertex_location: us-central1with 1M input and 1M output tokens on Gemini 3.5 FlashAfter: the same batch logs the regional price
vertex_location: us-central1Relevant issues
Fixes #46880
This PR covers the two code fixes from the issue. The price-data JSON updates mentioned there are left to the maintainers, who own the pricing map.
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreScreenshots / Proof of Fix
Setup:
LITELLM_LOCAL_MODEL_COST_MAP=True,batch_cost_calculator/cost_per_tokencalled the same way the batch and embedding paths call them.Before (d5ce7db)
Regional Vertex batch billed without the uplift
batch_cost_calculatorfor a Gemini 3.5 Flash batch with 1M input and 1M output tokens that ran onus-central1prompt=$0.7500 completion=$4.5000 total=$5.2500— the global rate, no way to pass the job's locationPer-character embedding billed per token
cost_per_tokenfor atext-embedding-005embedding of 1,000,000 characters (250,000 tokens)prompt=$0.025000from token pricing; the character count the predict API returned is droppedAfter (f1b6610)
Regional Vertex batch billed without the uplift
vertex_location="us-central1"threaded from the batch jobtotal=$5.2500; withus-central1it istotal=$5.7750— the published non-global ratePer-character embedding billed per token
billableCharacterCountthroughprompt=$0.025000from character pricing ($2.5e-08 x 1,000,000), andgemini-embedding-001is unchanged atprompt=$0.037500per tokenType
🐛 Bug Fix
Caveats (if any)
Medium
Low
Final Attestation