* fix(vertex): preserve Gemini Embedding 2 usageMetadata for cost tracking
* style(vertex): apply ruff format to batch_embed_content_transformation
* fix(vertex): bill files/ image refs in Gemini embedContent at per-image rate
Resolved files/... references whose mime type is an image were not detected
by _is_image_element, so image_count stayed 0 and generic_cost_per_token fell
back to the text token rate instead of input_cost_per_image. Thread the
resolved_files mapping into the usage builder so resolved image references are
counted and billed per image. Also modernize the _flatten_input return
annotation to satisfy the ruff UP006 strict gate.
* fix(vertex): bill Gemini embedding audio per-second and stop video+audio double-billing
Audio-only embedContent responses set audio_tokens, but generic_cost_per_token only
charges audio via input_cost_per_audio_token. gemini-embedding-2 prices audio via
input_cost_per_audio_per_second, so spend stayed at $0. Plumb a new
audio_length_seconds field through PromptTokensDetailsWrapper, parse it in
_parse_prompt_tokens_details, and bill it from _calculate_input_cost. The vertex
embedding transformation derives audio_length_seconds from audio_tokens using
the documented 32 tokens/sec Gemini rate.
The 1-token text floor that protects video billing only fired when no other
modality was billable, but audio presence flipped that flag, leaving text_tokens
at zero for video+audio responses. generic_cost_per_token then rewrote
text_tokens to prompt_tokens minus audio_tokens (the video token count),
charging video tokens as text on top of the per-second video cost. The rewrite
trigger is text_tokens == 0 and image_count == 0; align the floor with that
trigger and ignore audio_tokens.
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Allows wrapping multiple inputs in a nested list to produce a single
combined embedding (text + image = 1 vector). Flat lists continue to
produce separate embeddings per input (OpenAI-compatible default).
Examples:
input=["text", "image"] → 2 separate embeddings
input=[["text", "image"]] → 1 combined embedding
input=[["text", "image"], "x"] → 2 embeddings (1 combined + 1 separate)
When multiple inputs were passed to the Gemini embedding endpoint and any
contained multimodal data (images, audio, etc.), LiteLLM incorrectly used
the `embedContent` endpoint which combines all inputs into a single
aggregated embedding. Now uses `batchEmbedContents` with each input as a
separate request, returning N embeddings for N inputs as expected.
Also fixes hardcoded index=0 in batch embedding responses.